Lettermint.Query (Lettermint v2.0.0)

Copy Markdown View Source

Serializes query maps to the API's bracket syntax, exactly as the Node SDK.

iex> Lettermint.Query.encode(%{page: %{size: 10}, filter: %{status: "verified"}, sort: ["-created_at"]})
"filter%5Bstatus%5D=verified&page%5Bsize%5D=10&sort=-created_at"
  • nested maps (or keyword lists) become bracketed names: page[size];
  • lists of values are joined with commas: sort=-created_at,domain;
  • lists of maps are indexed: filter[tags][0][name]=a;
  • booleans are 1 or 0; DateTime, NaiveDateTime and Date are ISO 8601;
  • nil values and empty lists are left out.

Keys of a map are sent in sorted order; keyword lists keep their order. Names and values are form-encoded like URLSearchParams.

Summary

Functions

Encodes a query map. Raises Lettermint.ConfigError for values that cannot be sent.

Functions

encode(query)

@spec encode(map() | keyword() | nil) :: String.t()

Encodes a query map. Raises Lettermint.ConfigError for values that cannot be sent.