StarlingBank.HTTP.Client (StarlingBank v1.0.0)

Copy Markdown View Source

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/5xx responses
  • :telemetry instrumentation ([: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

method()

@type method() :: :get | :post | :put | :patch | :delete

result()

@type result() ::
  {:ok, map() | list() | binary() | nil} | {:error, StarlingBank.Error.t()}

Functions

request(config, method, path, opts \\ [])

@spec request(StarlingBank.Config.t(), method(), String.t(), keyword()) :: result()