LINE. Bot. Deserializer
(line_bot_sdk v0.1.0)
Copy Markdown
Helper functions for deserializing responses into models.
Summary
Functions
Decode a JSON response body into a struct.
Update the provided model with a deserialization of a nested value.
Evaluate the response from a Req request.
Build a struct of module from a raw string-keyed map.
Types
@type response_mapping() :: [{status_code(), false | %{} | module()}]
@type status_code() :: :default | 100..599
Functions
@spec decode(Req.Response.t() | map(), module() | false | %{}) :: struct() | map() | Req.Response.t()
Decode a JSON response body into a struct.
Parameters
response- The Req.Response struct or a mapmodule- The module to decode the response body into (orfalseto skip decoding)
Returns
The decoded struct, map, or response.
@spec deserialize( struct(), atom(), :date | :datetime | :list | :map | :struct, module() ) :: struct()
Update the provided model with a deserialization of a nested value.
@spec evaluate_response( {:ok, Req.Response.t()} | {:error, term()}, response_mapping() ) :: {:ok, struct() | Req.Response.t()} | {:error, Req.Response.t() | term()}
Evaluate the response from a Req request.
Parameters
result- The result from Req.request/2mapping- A list of{status_code, module}tuples for response decoding
Returns
{:ok, struct}or{:ok, Req.Response.t()}on success{:error, term}on failure
Build a struct of module from a raw string-keyed map.
Used by generated decode/1 discriminator dispatch clause to construct
a concrete struct without triggering discriminator re-dispatch.