Poodle.Config (poodle v1.0.0)

View Source

Configuration management for the Poodle SDK.

Supports configuration via environment variables and application config.

Summary

Functions

Get the current configuration.

Get the current configuration, raising on error.

Get the maximum content size allowed.

Validate configuration.

Types

t()

@type t() :: %Poodle.Config{
  api_key: String.t(),
  base_url: String.t(),
  debug: boolean(),
  finch_name: atom(),
  timeout: pos_integer()
}

Functions

get(opts \\ [])

@spec get(keyword()) :: {:ok, t()} | {:error, String.t()}

Get the current configuration.

Configuration is resolved in the following order:

  1. Explicitly passed options
  2. Application configuration
  3. Environment variables
  4. Default values

Examples

iex> Poodle.Config.get()
{:ok, %Poodle.Config{...}}

iex> Poodle.Config.get(api_key: "custom_key")
{:ok, %Poodle.Config{api_key: "custom_key", ...}}

get!(opts \\ [])

@spec get!(keyword()) :: t()

Get the current configuration, raising on error.

Examples

iex> Poodle.Config.get!()
%Poodle.Config{...}

max_content_size()

@spec max_content_size() :: pos_integer()

Get the maximum content size allowed.

validate(config)

@spec validate(t()) :: :ok | {:error, String.t()}

Validate configuration.

Examples

iex> config = %Poodle.Config{api_key: "key", base_url: "https://api.example.com"}
iex> Poodle.Config.validate(config)
:ok