AirtelMoney.Config (airtel_money v0.1.0)

Copy Markdown View Source

Configuration validation using NimbleOptions.

Validates the Airtel Money SDK configuration.

Summary

Functions

Returns the balance endpoint.

Returns the API base URL based on the environment.

Returns the collections endpoint.

Returns the disbursements endpoint.

Returns the current configuration from the application environment.

Returns the OAuth token endpoint.

Returns the transaction status endpoint.

Validates the configuration.

Functions

balance_url(config)

@spec balance_url(map()) :: String.t()

Returns the balance endpoint.

For DRC market (CD), uses /standard/v2/users/balance For other markets, uses /merchant/v1/balance

base_url(config)

@spec base_url(map()) :: String.t()

Returns the API base URL based on the environment.

For DRC market (CD), uses openapi.airtel.cd For other markets, uses openapi.airtel.africa

collections_url(config)

@spec collections_url(map()) :: String.t()

Returns the collections endpoint.

For DRC market (CD), uses /merchant/v2/payments/ For other markets, uses /merchant/v1/payments

disbursements_url(config)

@spec disbursements_url(map()) :: String.t()

Returns the disbursements endpoint.

For DRC market (CD), uses /standard/v2/disbursements/ For other markets, uses /openapi/moneytransfer/v2/credit

get!()

@spec get!() :: map()

Returns the current configuration from the application environment.

Raises if configuration is invalid.

token_url(config)

@spec token_url(map()) :: String.t()

Returns the OAuth token endpoint.

transaction_status_url(config, transaction_id)

@spec transaction_status_url(map(), String.t()) :: String.t()

Returns the transaction status endpoint.

For DRC market (CD), uses /standard/v1/payments/{id} For other markets, uses /merchant/v1/payments/{id}

validate(opts)

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

Validates the configuration.

Examples

iex> AirtelMoney.Config.validate(client_id: "test", client_secret: "secret", country: "CD", currency: "CDF")
{:ok, %{client_id: "test", client_secret: "secret", country: "CD", currency: "CDF", environment: :sandbox, timeout: 15000}}

iex> AirtelMoney.Config.validate([])
{:error, "required :client_id option not found, received options: []"}