Cyphi.Client.Response (Cyphi v0.1.0)
Handles the decoding and casting of HTTP responses into Elixir structs.
This module serves as the final step in the request pipeline. It matches the
response status code against a provided response_spec (generated by the
OpenAPI client) to determine how to process the body.
Decoding Strategy
- Structs (200/201): Validates and casts raw JSON maps into typed Elixir structs using
Cyphi.Client.Caster. - Lists: Automatically handles lists of items by mapping the decoding logic over the collection.
- Raw Bodies (202/204): Returns the raw body for Accepted or No Content responses where no schema is strictly defined.
- Errors: Returns generic error tuples for unhandled status codes (e.g., 404, 500).
Summary
Functions
Decodes a successful Req.Response based on the HTTP status and response spec.
Functions
@spec decode( {:ok, Req.Response.t()}, map() ) :: {:ok, term()} | {:error, term()}
Decodes a successful Req.Response based on the HTTP status and response spec.