View Source Lob.Util (lob_elixir v2.0.0)
Module responsible for transforming arguments for requests.
Link to this section Summary
Functions
Transforms a map to a tuple recognized by HTTPoison/hackney for use as a multipart request body.
Transforms a map to a list of tuples recognized by HTTPoison/hackeny for use as request headers.
Transforms a map of request params to a URL encoded query string.
Link to this section Functions
Specs
Transforms a map to a tuple recognized by HTTPoison/hackney for use as a multipart request body.
Example
iex> Lob.Util.build_body(%{description: "body", to: %{name: "Larry", species: "Lobster"}, front: %{local_path: "a/b/c"}}) {:multipart, [{"description", "body"}, {:file, "a/b/c", {"form-data", [name: "front", filename: "a/b/c"]}, []}, {"to[name]", "Larry"}, {"to[species]", "Lobster"}]}
Specs
Transforms a map to a list of tuples recognized by HTTPoison/hackeny for use as request headers.
Example
iex> Lob.Util.build_headers(%{"Idempotency-Key" => "abc123", "Lob-Version" => "2017-11-08"}) [{"Idempotency-Key", "abc123"}, {"Lob-Version", "2017-11-08"}]
Specs
Transforms a map of request params to a URL encoded query string.
Example
iex> Lob.Util.build_query_string(%{count: 1, include: ["total_count"], metadata: %{name: "Larry"}}) "count=1&include%5B%5D=total_count&metadata%5Bname%5D=Larry"