Thin, instrumented HTTP wrapper used by every resource module.
Responsibilities:
- Bearer token authentication
- Base URL / environment (production vs sandbox) resolution
- JSON encode/decode (via
Jason), with passthrough for binary (non-JSON) responses such as statements and receipt attachments - Exponential backoff retry on network errors and
429/5xxresponses :telemetryinstrumentation ([:starling_bank, :request, :start | :stop | :exception])- Normalizing all failures into
StarlingBank.Error
The actual socket work is delegated to a StarlingBank.HTTP.Transport
implementation (config.transport), which defaults to a zero-dependency
:httpc-based transport but can be swapped out (e.g. in tests).
Summary
Types
@type method() :: :get | :post | :put | :patch | :delete
@type result() :: {:ok, map() | list() | binary() | nil} | {:error, StarlingBank.Error.t()}
Functions
@spec request(StarlingBank.Config.t(), method(), String.t(), keyword()) :: result()