Weavr.Config (Weavr v1.0.0)

Copy Markdown View Source

Account-level configuration for talking to the Weavr Multi API: which environment to call, and the api-key that identifies your Weavr account on every request.

Weavr documents distinct Sandbox and Live environments with separate base URLs and separate API keys — Sandbox does not touch real banking rails and additionally exposes simulator endpoints for triggering events like incoming bank transfers. Mixing up Sandbox/Live credentials and base URLs is a common integration mistake, so new/1 requires :environment explicitly rather than defaulting to one or the other.

Examples

config = Weavr.Config.new(
  api_key: System.fetch_env!("WEAVR_API_KEY"),
  environment: :sandbox
)

# Or for the back-office product:
config = Weavr.Config.new(
  api_key: System.fetch_env!("WEAVR_BACKOFFICE_API_KEY"),
  environment: :live,
  product: :multi_backoffice
)

# Or pointing at a fully custom base URL (e.g. a local mock server in tests):
config = Weavr.Config.new(
  api_key: "test-key",
  base_url: "http://localhost:4000/multi"
)

Summary

Types

environment()

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

product()

@type product() :: :multi | :multi_backoffice

t()

@type t() :: %Weavr.Config{
  api_key: String.t(),
  base_url: String.t(),
  connect_timeout: pos_integer(),
  environment: environment() | nil,
  max_retries: non_neg_integer(),
  product: product(),
  recv_timeout: pos_integer()
}

Functions

new(opts)

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

Builds a new Weavr.Config.

Required

  • :api_key - your Weavr account API key

One of

  • :environment - :sandbox or :live, used to derive :base_url for the standard Weavr environments
  • :base_url - an explicit base URL, overriding environment-based derivation entirely (useful for tests against a local mock, or if Weavr provisions a custom domain for your account)

Optional

  • :product - :multi (default) or :multi_backoffice
  • :max_retries - defaults to 2
  • :connect_timeout - milliseconds, defaults to 5_000
  • :recv_timeout - milliseconds, defaults to 30_000

Raises Weavr.Error.InvalidRequest if neither :environment nor :base_url is given, or if :api_key is missing.