View Source ExFiskal.Config (ExFiskal v1.2.0)
Configuration management for ExFiskal OTP application.
This module provides utilities for managing application-wide configuration such as certificate data, fiscalization endpoints, and other settings.
Configuration Options
You can configure ExFiskal in your config.exs:
config :ex_fiskal,
environment: :production,
timeout: 30_000,
endpoint_url: "https://cis.porezna-uprava.hr:8449/FiskalizacijaService"Available Settings
:environment- Either:productionor:demo. Defaults to:production.:timeout- Request timeout in milliseconds. Defaults to 30_000 (30 seconds).:endpoint_url- The fiscalization service endpoint URL.:certificate_path- Optional path to certificate file.:certificate_password- Optional certificate password.
Runtime Configuration
You can also configure settings at runtime:
ExFiskal.Config.put(:timeout, 60_000)
ExFiskal.Config.get(:timeout)
Summary
Functions
Returns the certificate password if configured.
Returns the certificate path if configured.
Returns whether the application is running in demo mode.
Returns the endpoint URL based on the configured environment.
Returns the configured environment (:production or :demo).
Gets a configuration value for the given key.
Gets a configuration value for the given key, raising if not found.
Returns whether the application is running in production mode.
Puts a configuration value for the given key at runtime.
Returns the timeout value in milliseconds.
Functions
@spec certificate_password() :: String.t() | nil
Returns the certificate password if configured.
Examples
iex> ExFiskal.Config.certificate_password()
"my_password"
@spec certificate_path() :: String.t() | nil
Returns the certificate path if configured.
Examples
iex> ExFiskal.Config.certificate_path()
"/path/to/certificate.p12"
@spec demo?() :: boolean()
Returns whether the application is running in demo mode.
Examples
iex> ExFiskal.Config.demo?()
false
@spec endpoint_url() :: String.t()
Returns the endpoint URL based on the configured environment.
Examples
iex> ExFiskal.Config.endpoint_url()
"https://cis.porezna-uprava.hr:8449/FiskalizacijaService"
@spec environment() :: :production | :demo
Returns the configured environment (:production or :demo).
Defaults to :production if not configured.
Examples
iex> ExFiskal.Config.environment()
:production
Gets a configuration value for the given key.
Examples
iex> ExFiskal.Config.get(:timeout)
30_000
iex> ExFiskal.Config.get(:timeout, 5_000)
30_000
iex> ExFiskal.Config.get(:unknown_key, :default_value)
:default_value
Gets a configuration value for the given key, raising if not found.
Examples
iex> ExFiskal.Config.get!(:timeout)
30_000
@spec production?() :: boolean()
Returns whether the application is running in production mode.
Examples
iex> ExFiskal.Config.production?()
true
Puts a configuration value for the given key at runtime.
Examples
iex> ExFiskal.Config.put(:timeout, 60_000)
:ok
@spec timeout() :: non_neg_integer()
Returns the timeout value in milliseconds.
Defaults to 30 seconds if not configured.
Examples
iex> ExFiskal.Config.timeout()
30_000