Nombaone.Client (Nomba One v0.1.0)

View Source

The API client — configuration plus the HTTP engine's context.

Build one with Nombaone.new/2 (a thin delegate to new/2 here) and thread it as the first argument to every resource call. The struct is plain data and safe to share across processes.

Options

  • :api_key — your secret key (nbo_sandbox_… / nbo_live_…). Defaults to the NOMBAONE_API_KEY environment variable. Server-side only.
  • :base_url — override the API origin (no /v1). Defaults to the host matching the key's environment. Required if the key prefix is unknown.
  • :timeout — per-attempt timeout in milliseconds. Default 30_000.
  • :max_retries — automatic retry budget. Default 2 (3 attempts total).
  • :transport — a Nombaone.Transport module. Default Nombaone.Transport.HTTPC.
  • :transport_options — an opaque term passed to the transport.
  • :default_headers — a map of headers added to every request.

The read-only :mode and :base_url fields are derived at construction.

Summary

Types

The environment the key (and everything created with it) lives in.

t()

Functions

The built-in host for each environment.

Build a client. See the module doc for options. Raises ArgumentError on a missing or unrecognized key (a configuration mistake should fail loudly, at construction — not on the first request).

Types

mode()

@type mode() :: :sandbox | :live

The environment the key (and everything created with it) lives in.

t()

@type t() :: %Nombaone.Client{
  api_key: String.t(),
  base_url: String.t(),
  default_headers: map(),
  max_retries: non_neg_integer(),
  mode: mode(),
  timeout: non_neg_integer(),
  transport: module(),
  transport_options: term()
}

Functions

base_urls()

@spec base_urls() :: %{required(mode()) => String.t()}

The built-in host for each environment.

new(api_key_or_options \\ [], options \\ [])

@spec new(
  String.t() | keyword(),
  keyword()
) :: t()

Build a client. See the module doc for options. Raises ArgumentError on a missing or unrecognized key (a configuration mistake should fail loudly, at construction — not on the first request).