Small stateless helpers shared across the Triple client.
Summary
Functions
Drops keys whose value is nil from a map. Used when building JSON
request bodies so optional/unset fields are omitted entirely rather than
sent as explicit nulls.
Generates a random UUID v4 string. Handy for populating transaction_id
when you don't already have a natural unique identifier on hand — Triple
requires it to be unique per caller, but doesn't care what it looks like.
Functions
Drops keys whose value is nil from a map. Used when building JSON
request bodies so optional/unset fields are omitted entirely rather than
sent as explicit nulls.
Examples
iex> Triple.Util.compact(%{a: 1, b: nil, c: "x"})
%{a: 1, c: "x"}
@spec generate_transaction_id() :: String.t()
Generates a random UUID v4 string. Handy for populating transaction_id
when you don't already have a natural unique identifier on hand — Triple
requires it to be unique per caller, but doesn't care what it looks like.
Examples
iex> uuid = Triple.Util.generate_transaction_id()
iex> String.match?(
...> uuid,
...> ~r/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
...> )
true