FactorialHR.Config (factorial_hr v0.2.0)

Copy Markdown View Source

Configuration normalization for FactorialHR.

The library accepts explicit keyword options and has a small environment fallback for scripts. Host applications should normally pass credentials from their own configuration layer instead of relying on process environment.

Summary

Functions

Builds a normalized configuration struct from keyword options or a map.

Types

auth_mode()

@type auth_mode() :: :api_key | :bearer

t()

@type t() :: %FactorialHR.Config{
  api_version: String.t(),
  auth_mode: auth_mode(),
  author_id: integer() | String.t() | nil,
  base_url: String.t(),
  company_id: integer() | String.t() | nil,
  receive_timeout: pos_integer(),
  req_options: keyword(),
  token: String.t()
}

Functions

new(config)

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

Builds a normalized configuration struct from keyword options or a map.

Supported options:

  • :api_key, :access_token or :token
  • :auth_mode / :auth as :api_key, "api_key", :bearer, or "bearer"
  • :base_url or :api_url
  • :api_version
  • :company_id, :author_id
  • :req_options
  • :receive_timeout

If no token is supplied, FACTORIAL_API_KEY, FACTORIAL_ACCESS_TOKEN, and FACTORIAL_API_TOKEN are checked in that order.