ExFattureincloud.Client (ExFattureincloud v0.1.0)

Copy Markdown View Source

Immutable configuration for one integration/account.

Options to new/1:

  • :token — access token or zero-arity provider returning the current token, {:ok, token} or {:error, %ExFattureincloud.Error{}}. Omit for OAuth calls; authenticated requests then return an error.
  • :base_url — defaults to https://api-v2.fattureincloud.it.
  • :user_agent — defaults to FattureInCloud/2.1.3/Go-SDK, matching the official Go SDK's compatibility header. Override for your integration.
  • :receive_timeout — milliseconds, default 15,000.
  • :max_retries — additional attempts for GET/HEAD only, default 2.
  • :retry_delay — initial backoff in milliseconds, default 500, with jitter.
  • :max_retry_delay — maximum permitted wait, default 30,000 ms. A server Retry-After above this budget returns the error without retrying early.
  • :req_options — Req options, e.g. connect_options, finch, plug or a custom adapter. Redirects and Req's own retries are always disabled.

Token providers are evaluated once per outgoing attempt. Clients keep no global credentials. Optional managed renewal is available through ExFattureincloud.OAuth.TokenManager; applications supply its storage callbacks. Inspection of the client excludes credentials and Req options.

Summary

Types

t()

A zero-arity provider evaluated before each outgoing HTTP attempt.

A token provider's result, including structured authorization failures.

Functions

Creates and validates an immutable client configuration. Invalid options raise ArgumentError.

Types

t()

@type t() :: %ExFattureincloud.Client{
  base_url: String.t(),
  max_retries: non_neg_integer(),
  max_retry_delay: non_neg_integer(),
  receive_timeout: pos_integer(),
  req_options: keyword(),
  retry_delay: non_neg_integer(),
  token: nil | String.t() | token_provider(),
  user_agent: String.t()
}

token_provider()

@type token_provider() :: (-> token_result())

A zero-arity provider evaluated before each outgoing HTTP attempt.

token_result()

@type token_result() ::
  String.t() | {:ok, String.t()} | {:error, ExFattureincloud.Error.t()}

A token provider's result, including structured authorization failures.

Functions

new(options \\ [])

@spec new(keyword()) :: t()

Creates and validates an immutable client configuration. Invalid options raise ArgumentError.