Picnic.Config (Picnic v0.1.0)

Copy Markdown View Source

Resolves client configuration.

All values are plain data and every one of them can be overridden through Picnic.Client.new/1, so an API change on Picnic's side — a bumped path version, a new required header — is a configuration change for users of this library, never a code change.

Resolution order for each setting:

  1. options passed to Picnic.Client.new/1
  2. application environment for :ex_picnic (defaults only — the core never reads app env at request time)
  3. the built-in defaults below

The default base URL is https://storefront-prod.<country>.picnicinternational.com/api/<version>; pass :base_url to replace it wholesale (the :api_version and :country settings are then ignored for URL building).

Summary

Functions

Builds the default base URL for a country and API version.

Resolves the full configuration map from the given options, the :ex_picnic application environment, and built-in defaults — in that order of precedence.

Types

t()

@type t() :: %{
  country: :nl | :de | :fr,
  api_version: String.t(),
  base_url: String.t(),
  client_id: integer(),
  headers: %{required(String.t()) => String.t()},
  req_options: keyword()
}

Functions

base_url(country, api_version)

@spec base_url(:nl | :de | :fr, String.t()) :: String.t()

Builds the default base URL for a country and API version.

resolve(opts \\ [])

@spec resolve(keyword()) :: t()

Resolves the full configuration map from the given options, the :ex_picnic application environment, and built-in defaults — in that order of precedence.