CorvoNfse.Client (Corvo NFS-e v0.1.1)

Copy Markdown View Source

Configuration for a Corvo NFS-e API connection.

Build one with CorvoNfse.new/1 (or %CorvoNfse.Client{} directly) and pass it as the first argument to every resource function.

client = CorvoNfse.new(api_key: "corvo_test_...")
CorvoNfse.Resources.Health.live(client)

Options

  • :api_key - required unless CORVO_API_KEY is set. Sent as the X-API-Key header (never Authorization: Bearer).
  • :base_url - defaults to CORVO_BASE_URL, then to the public https://api.corvo.tech. Trailing slashes are stripped. Plain http:// is only accepted for loopback/private hosts unless allow_insecure_http: true.
  • :prefix - API prefix segment, defaults to CORVO_API_PREFIX or "v1". Pass "" for installs without a prefix. Surrounding slashes are trimmed.
  • :receive_timeout - per-request receive timeout in milliseconds, defaults to 30_000.
  • :allow_insecure_http - allow http:// for public hosts (default false).
  • :finch - Finch pool name, defaults to CorvoNfse.Finch (started with the application).
  • :http - HTTP adapter module, defaults to CorvoNfse.HTTP.Finch.

Construction problems (missing API key, invalid base URL) raise ArgumentError; API, network and timeout failures are never raised - they come back as {:error, %CorvoNfse.Error{}}.

Summary

Types

Accepted options for new/1.

t()

Functions

Builds a client from options with environment fallbacks.

Types

option()

@type option() ::
  {:api_key, String.t()}
  | {:base_url, String.t()}
  | {:prefix, String.t() | nil}
  | {:receive_timeout, pos_integer()}
  | {:allow_insecure_http, boolean()}
  | {:finch, atom()}
  | {:http, module()}

Accepted options for new/1.

t()

@type t() :: %CorvoNfse.Client{
  allow_insecure_http: boolean(),
  api_key: String.t(),
  base_url: String.t(),
  finch: atom(),
  http: module(),
  prefix: String.t(),
  receive_timeout: pos_integer()
}

Functions

new(opts \\ [])

@spec new([option()]) :: t()

Builds a client from options with environment fallbacks.

Raises ArgumentError when the configuration is unusable.