HTTP transport behaviour for LatticeStripe.
The default transport uses Finch (LatticeStripe.Transport.Finch).
To use a different HTTP client, implement this behaviour and pass
transport: MyTransport to Client.new!/1.
Example
defmodule MyApp.Transport do
@behaviour LatticeStripe.Transport
@impl true
def request(%{method: method, url: url, headers: headers, body: body, opts: opts}) do
# Your HTTP client call here
{:ok, %{status: 200, headers: [], body: "..."}}
end
endContract
The callback receives a plain map with these keys:
method- HTTP method atom (:get,:post,:delete)url- Full URL string ("https://api.stripe.com/v1/customers")headers- List of{name, value}string tuplesbody- Request body string ornilopts- Keyword list with transport-specific options (e.g.,finch: MyFinch, timeout: 30_000)
Returns {:ok, response_map} or {:error, reason} where response_map has:
status- HTTP status integerheaders- List of{name, value}string tuplesbody- Response body string
Summary
Types
Callbacks
@callback request(request_map()) :: {:ok, response_map()} | {:error, term()}