vista_client v0.1.2 VistaClient.Extractors
Helper functions to extract and convert certain attributes from a parsed JSOM map. For example, IDs are transmitted as strings by VISTA, so we're converting them to integers.
Synopsis
iex> VistaClient.Extractors.extract_id %{"ID" => "1001"}
{:ok, 1001}
iex> VistaClient.Extractors.extract_id %{"id" => 1001}
{:error, :unparsable_id}
Link to this section Summary
Functions
Given the "SessionAttributesNames" field fron a Session map, takes the list and returns a tuple containing the attributes as in there and a version string.
Naive string-to-datetime conversion. Assumes lack of timezone info.
Naive string-to-datetime conversion. Assumes lack of timezone info.
Extracts the id from a map with an "ID" field containing an ID string
Link to this section Types
Link to this section Functions
extract_attributes(map)
extract_attributes(map_with_atttrs()) :: {:ok, {version(), attributes()}} | {:error, :unparsable_session_attributes}
Given the "SessionAttributesNames" field fron a Session map, takes the list and returns a tuple containing the attributes as in there and a version string.
The version string is the attribute with highest priority in the list of known version attributes. Unknown attributes will be discarded.
extract_date(datetime)
extract_date(map, key)
Naive string-to-datetime conversion. Assumes lack of timezone info.
Examples
iex> Elixir.VistaClient.Extractors.extract_date("2019-02-26T20:00:00")
{:ok, ~D[2019-02-26]}
extract_datetime(string)
extract_datetime(map, key)
Naive string-to-datetime conversion. Assumes lack of timezone info.
Examples
iex> Elixir.VistaClient.Extractors.extract_datetime("2019-02-26T20:00:00")
{:ok, ~N[2019-02-26 20:00:00]}
extract_id(map, id_field \\ "ID")
extract_id(map_with_id(), String.t()) :: {:ok, id()} | {:error, :unparsable_id}
Extracts the id from a map with an "ID" field containing an ID string