Common.Payload (etl_core v0.1.55)
Module oriented to common functions for working with payloads
Summary
Functions
Extract the value
of the key defined in the map
Extract the information and attach it to the defined map. If it does not appear, it gives the default value in each case.
Group the maps with equal value in a certain field
Functions
Link to this function
extract_data(payload, tag, list \\ [], default_value \\ nil)
Extract the value
of the key defined in the map
Parameters:
- payload: Map. Container of the information (<key, value>) that is required.
- tag: String. Key to search within the map.
- list: List of String. List of tags to search in depth, by structure chaining.
- default_value: t(). Default value, in case it cannot be found. If not defined, it takes value nil.
Return:
- t() | nil. If the defined labels are correct, it returns the desired value; otherwise nil.
Link to this function
extract_with_format(payload, attr_list, eliminate_null_value \\ true)
Extract the information and attach it to the defined map. If it does not appear, it gives the default value in each case.
###Parameters:
- payload_: Map. Payload.
- attr_list. List of InfoAttr. Fields to search for in the payload.
- eliminate_null_value: Boolean. Indicates if you want to eliminate fields with null values.
Return:
- list of {attr.id, values_extracted_from_the_payload} | empty list
Link to this function
reduce_by(list, fields)
Group the maps with equal value in a certain field
Parameters:
- list: List of map. Data.
- fields: Set of fields to set the identifier of each set. The identifier is the concatenation of each one, and the character '_'.
Return:
- {A, B} where
A Map where values is a list of values of `list` such that they share the same value in the defined field
B List of t() coincides with A.key()