Monzo.HTTP (monzo_client v1.0.0)

Copy Markdown View Source

Core HTTP request engine shared by every resource module: URL/query/body encoding, bearer auth, jittered exponential-backoff retries on transient (429/5xx/network) failures, and a single automatic refresh-and-retry on 401s when the client has a token store configured.

This module is considered internal; resource modules like Monzo.Accounts are the intended public API.

Summary

Functions

Executes a request against the Monzo API described by opts, using the given Monzo.Client for configuration (base URL, adapter, token store, retry policy, etc), and returns the JSON-decoded response body.

Types

body_encoding()

@type body_encoding() :: :none | :form | :json

method()

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

request_opts()

@type request_opts() :: [
  method: method(),
  path: String.t(),
  query: %{optional(String.t()) => term()} | keyword(),
  encoding: body_encoding(),
  form: %{optional(String.t()) => term()},
  json: term(),
  access_token: String.t() | nil,
  idempotent: boolean() | nil
]

Functions

request(client, opts)

@spec request(Monzo.Client.t(), request_opts()) ::
  {:ok, term()} | {:error, Exception.t()}

Executes a request against the Monzo API described by opts, using the given Monzo.Client for configuration (base URL, adapter, token store, retry policy, etc), and returns the JSON-decoded response body.