Increase.Decode (Increase v1.0.0)

Copy Markdown View Source

Shared decoding helpers used by every generated Increase.* struct's decode/1 function. Not meant to be called directly in application code -- see the individual resource struct modules (e.g. Increase.Accounts.Account) instead.

Summary

Functions

Parses an ISO 8601 date string (YYYY-MM-DD) into a Date. Same fallback behavior as datetime/1.

Parses an ISO 8601 datetime string into a DateTime. Returns nil unchanged (for nullable fields that are absent), and falls back to the raw value unchanged if it doesn't parse as a valid datetime -- since the API is the source of truth and a parse failure here shouldn't crash decoding of an otherwise-valid response.

Decodes a list of nested objects with the given decoder function. Passes nil through unchanged (some list fields are themselves nullable) and decodes each element of a present list.

Decodes a single nested object with the given decoder function. Passes nil through unchanged (for nullable nested objects that are absent).

Functions

date(value)

@spec date(String.t() | nil) :: Date.t() | String.t() | nil

Parses an ISO 8601 date string (YYYY-MM-DD) into a Date. Same fallback behavior as datetime/1.

datetime(value)

@spec datetime(String.t() | nil) :: DateTime.t() | String.t() | nil

Parses an ISO 8601 datetime string into a DateTime. Returns nil unchanged (for nullable fields that are absent), and falls back to the raw value unchanged if it doesn't parse as a valid datetime -- since the API is the source of truth and a parse failure here shouldn't crash decoding of an otherwise-valid response.

list(raw, decoder)

@spec list([map()] | nil, (map() -> struct())) :: [struct()] | nil

Decodes a list of nested objects with the given decoder function. Passes nil through unchanged (some list fields are themselves nullable) and decodes each element of a present list.

struct(raw, decoder)

@spec struct(map() | nil, (map() -> struct())) :: struct() | nil

Decodes a single nested object with the given decoder function. Passes nil through unchanged (for nullable nested objects that are absent).