The HTTP adapter behaviour.
The default adapter is Lettermint.Adapter.Req. Pass another one with the
:adapter client option, as a module or as {module, options}; options
is passed to request/2 ([] for a bare module).
An adapter sends one request and returns the response. It must not follow
redirects and must not retry: the SDK handles 3xx responses as
Lettermint.RedirectError, so that tokens never reach another host. The
SDK enforces the client timeout over the whole call; the adapter should use
request.timeout for its own timeouts too.
A request is a map:
:method::get,:post,:put,:patchor:delete:url: the full URL, including the encoded query string:headers: a list of{name, value}with lowercase names:body: the encoded JSON body, ornil:timeout: the timeout in milliseconds
Return {:ok, %{status: status, headers: headers, body: body}}, where
headers is a list of {name, value} or a map of name to a value or a list
of values, and body is a binary. Return {:error, reason} when no response
arrived; reason is kept in Lettermint.ConnectionError. A reason of
:timeout, or an exception with reason: :timeout, becomes
Lettermint.TimeoutError.
Summary
Types
@type request() :: %{ method: :get | :post | :put | :patch | :delete, url: String.t(), headers: [{String.t(), String.t()}], body: binary() | nil, timeout: pos_integer() }