Current section

Files

Jump to
braintree lib braintree.ex
Raw

lib/braintree.ex

defmodule Braintree do
@moduledoc """
A native Braintree client library for Elixir. Only a subset of the API is
supported and this is a work in progress. That said, it is already uned in
production, and any modules that have been implemented can be used.
For general reference please see:
https://developers.braintreepayments.com/reference/overview
"""
defmodule ConfigError do
@moduledoc """
Raised at runtime when a config variable is missing.
"""
defexception [:message]
def exception(value) do
message = "missing config for :#{value}"
%ConfigError{message: message}
end
end
@doc """
Convenience function for retrieving braintree specfic environment values, but
will raise an exception if values are missing.
## Example
iex> Braintree.get_env(:random_value)
** (Braintree.ConfigError) missing config for :random_value
"""
@spec get_env(atom, any) :: any
def get_env(key, default \\ nil) do
Application.get_env(:braintree, key, default) || raise ConfigError, key
end
end