Shared helpers for converting idiomatic Elixir param maps (snake_case atom
keys) into the camelCase JSON shape the Paysafe API expects, with nil
values stripped recursively.
Used internally by every API module. Not typically called directly, but public so that custom extensions can reuse the same conventions.
Summary
Functions
Convert a single snake_case atom or string key to a camelCase string.
Recursively convert snake_case atom (or string) keys to camelCase string keys.
Recursively strip nil values from maps and lists, leaving the rest intact.
Convenience: camelize keys then strip nils in one pass.
Camelize keys of a keyword list (used for query string params).
Functions
Convert a single snake_case atom or string key to a camelCase string.
Examples
iex> Paysafe.ParamEncoder.camelize(:merchant_ref_num)
"merchantRefNum"
Recursively convert snake_case atom (or string) keys to camelCase string keys.
Examples
iex> Paysafe.ParamEncoder.camelize_keys(%{card_expiry: %{month: 12, year: 2030}})
%{"cardExpiry" => %{"month" => 12, "year" => 2030}}
Recursively strip nil values from maps and lists, leaving the rest intact.
Examples
iex> Paysafe.ParamEncoder.deep_clean(%{"a" => 1, "b" => nil})
%{"a" => 1}
Convenience: camelize keys then strip nils in one pass.
This is the function nearly every API module calls before sending a
request body to Paysafe.Client.
Camelize keys of a keyword list (used for query string params).