MollieEx.Client (mollie_ex v0.3.0)

Copy Markdown View Source

Explicit client configuration for MollieEx API calls.

A client is immutable and carries all user-visible SDK configuration. Resource modules receive it explicitly instead of reading process state, application environment, or environment variables.

Use new!/1 for boot-time configuration that should fail fast:

client =
  MollieEx.Client.new!(
    api_key: System.fetch_env!("MOLLIE_API_KEY")
  )

Use new/1 when configuration is dynamic and invalid values should be returned as {:error, %MollieEx.Error{}}.

Summary

Functions

Builds a MollieEx client from explicit options.

Builds a MollieEx client or raises %MollieEx.Error{} for invalid config.

Types

auth()

(since 0.1.0)
@type auth() ::
  {:api_key, credential()}
  | {:oauth, credential()}
  | {:organization_token, credential()}
  | {:token_provider, module(), atom(), list()}

credential()

(since 0.1.0)
@type credential() :: String.t() | (-> String.t())

t()

(since 0.1.0)
@type t() :: %MollieEx.Client{
  auth: auth(),
  base_url: String.t(),
  connect_timeout: pos_integer(),
  finch_name: atom() | nil,
  max_retries: non_neg_integer(),
  max_retry_after: pos_integer(),
  pool_timeout: pos_integer(),
  profile_id: String.t() | nil,
  receive_timeout: pos_integer(),
  request_timeout: pos_integer(),
  telemetry_prefix: [atom()],
  testmode: boolean() | nil,
  transport: transport(),
  user_agent: String.t(),
  user_agent_suffix: String.t() | nil
}

transport()

(since 0.1.0)
@type transport() :: :finch | {:req_test, atom()}

Functions

new(opts)

(since 0.1.0)
@spec new(keyword() | map()) :: {:ok, t()} | {:error, MollieEx.Error.t()}

Builds a MollieEx client from explicit options.

Exactly one auth mode must be configured. This function validates static configuration only; function credentials and token providers are not called during construction.

Supported auth options are :api_key, :oauth_token, :organization_token, and :token_provider.

new!(opts)

(since 0.1.0)
@spec new!(keyword()) :: t()

Builds a MollieEx client or raises %MollieEx.Error{} for invalid config.