View Source CFSync.Entry.Extractors (CFSync v0.3.0)
Utility functions to extract data from contenful JSON.
Link to this section Summary
Types
Entry's payload as provided to CFSync.Entry.Fields.new/1
Functions
Returns value of field_name as an atom.
Returns value of field_name as a binary.
Returns value of field_name as a boolean.
Returns value of field_name as a Date.
Returns value of field_name as a DateTime.
Returns value of field_name as a CFSync.Link.
Returns value of field_name as a list of CFSync.Link.
Returns value of field_name as a list.
Returns value of field_name as a map.
Returns value of field_name as a number.
Returns value of field_name as CFSync.RichText tree.
Link to this section Types
@opaque data()
Entry's payload as provided to CFSync.Entry.Fields.new/1
Link to this section Functions
Returns value of field_name as an atom.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)mappingis a map of"value" => :atomused to find which atom correspond to the field's value
Returns default on failure (field empty, no mapping...)
Returns value of field_name as a binary.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a string...)
Returns value of field_name as a boolean.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a boolean...)
Returns value of field_name as a Date.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, invalid format, invalid date...)
@spec extract_datetime(data(), String.t(), nil | DateTime.t()) :: nil | DateTime.t()
Returns value of field_name as a DateTime.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, invalid format, invalid datetime...)
@spec extract_link(data(), String.t(), nil | CFSync.Link.t()) :: nil | CFSync.Link.t()
Returns value of field_name as a CFSync.Link.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a link...)
@spec extract_links(data(), String.t(), nil | [CFSync.Link.t()]) :: nil | [CFSync.Link.t()]
Returns value of field_name as a list of CFSync.Link.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a list...)
Returns value of field_name as a list.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a list...)
Returns value of field_name as a map.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a map...)
Returns value of field_name as a number.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Be careful with the result as it can be either an integer or float, depending of it's value. A contentful decimal value of 1.0 will be stored as 1 in the JSON and read as an integer by JASON.
Returns default on failure (field empty, not a number...)
@spec extract_rich_text(data(), String.t(), nil | CFSync.RichText.t()) :: nil | CFSync.RichText.t()
Returns value of field_name as CFSync.RichText tree.
datais the entry's payload as provided toCFSync.Entry.Fields.new/1field_nameis the field's id in Contentful (ie. What is configured in Contentful app)
Returns default on failure (field empty, not a richtext...)