Nadia. Parser
(nadia v1.5.0)
View Source
Provides parser logics for API results.
Summary
Functions
parse result field of decoded API response json.
Args
Parses a webhook-style Telegram update payload.
Parses a webhook-style Telegram update payload and raises on invalid input.
Parses multiple Telegram update payloads.
Functions
parse result field of decoded API response json.
Args:
result-resultfield of decoded API response jsonmethod- name of API method
@spec parse_update(Nadia.Model.Update.t() | map() | binary()) :: {:ok, Nadia.Model.Update.t()} | {:error, term()}
Parses a webhook-style Telegram update payload.
Accepts either a decoded map with string or atom keys, an existing
%Nadia.Model.Update{}, or a raw JSON object binary. Unknown fields are
ignored in the same way as API response parsing.
@spec parse_update!(Nadia.Model.Update.t() | map() | binary()) :: Nadia.Model.Update.t()
Parses a webhook-style Telegram update payload and raises on invalid input.
Raw JSON binaries are decoded with Jason.decode!/1; decoded values must be
maps or %Nadia.Model.Update{} structs.
@spec parse_updates([Nadia.Model.Update.t() | map()] | map() | binary()) :: {:ok, [Nadia.Model.Update.t()]} | {:error, term()}
Parses multiple Telegram update payloads.
Accepts a list of decoded update maps or structs, a JSON array binary, or a
decoded/encoded Bot API response envelope containing a "result" update
list.