Client configuration for the Wise Platform API.
Build a config struct using new/1 and pass it to every service call,
or register it as a named config using Wise.Application.
Required
At least one of :personal_token, :client_id+:client_secret,
or :access_token must be provided.
Example
config = Wise.Config.new!(
personal_token: System.fetch_env!("WISE_API_TOKEN"),
sandbox: true
)
{:ok, profiles} = Wise.Services.Profiles.list(config)
Summary
Types
@type auth_mode() :: :personal_token | :client_credentials | :user_token
@type on_token_refresh() :: (refresh_token :: String.t() -> {:ok, %{ access_token: String.t(), refresh_token: String.t(), expires_at: DateTime.t() }} | {:error, term()})
@type t() :: %Wise.Config{ access_token: String.t() | nil, auth_mode: auth_mode(), base_url: String.t(), circuit_breaker: GenServer.server() | nil, client_id: String.t() | nil, client_secret: String.t() | nil, max_retries: non_neg_integer(), on_token_refresh: on_token_refresh() | nil, personal_token: String.t() | nil, rate_limiter: GenServer.server() | nil, recv_timeout: pos_integer(), refresh_token: String.t() | nil, request_hooks: [function()], response_hooks: [function()], retry_base_delay: pos_integer(), retry_max_delay: pos_integer(), timeout: pos_integer(), token_expires_at: DateTime.t() | nil, user_agent: String.t() }
Functions
@spec current_token(t()) :: {:ok, String.t()} | {:error, Wise.Error.t()}
@spec current_token(t()) :: {:ok, String.t()} | {:error, atom()}
Returns the current Bearer token, refreshing if necessary.
Creates a new config struct.
Returns {:ok, config} or {:error, reason}.
Like new/1 but raises on invalid configuration.