Cielo.Utils (Cielo v0.1.8) View Source
This module is a helper, providing helper functions
Link to this section Summary
Functions
Helper function for retrieving cielo environment values
Helper function for retrieving cielo environment values, but will raise an exception if values are missing.
Convert cielo map response to atom keyed map.
Convert atom keyed map for a Cielo's valid map.
Helper function for setting cielo
application environment
variables.
Link to this section Functions
Specs
Helper function for retrieving cielo environment values
Example
iex> Cielo.Utils.get_env(:random_value)
** (Cielo.ConfigError) missing config for :random_value
iex> Cielo.Utils.get_env(:random_value, "random")
"random"
iex> Application.put_env(:cielo, :random_value, "not-random")
...> value = Cielo.Utils.get_env(:random_value)
...> Application.delete_env(:cielo, :random_value)
...> value
"not-random"
iex> System.put_env("RANDOM", "not-random")
...> Application.put_env(:cielo, :system_value, {:system, "RANDOM"})
...> value = Cielo.Utils.get_env(:system_value)
...> System.delete_env("RANDOM")
...> value
"not-random"
Specs
Helper function for retrieving cielo environment values, but will raise an exception if values are missing.
Example
iex> Cielo.Utils.get_env!(:random_value)
** (Cielo.ConfigError) missing config for :random_value
iex> Cielo.Utils.get_env!(:random_value, "random")
"random"
iex> Application.put_env(:cielo, :random_value, "not-random")
...> value = Cielo.Utils.get_env!(:random_value)
...> Application.delete_env(:cielo, :random_value)
...> value
"not-random"
iex> System.put_env("RANDOM", "not-random")
...> Application.put_env(:cielo, :system_value, {:system, "RANDOM"})
...> value = Cielo.Utils.get_env!(:system_value)
...> System.delete_env("RANDOM")
...> value
"not-random"
Convert cielo map response to atom keyed map.
Examples
iex> %{"MerchantOrderId" => "7c17771a-1b66-494f-bb73-517f236dc9fe"} |> map_from_cielo()
%{merchant_order_id: "7c17771a-1b66-494f-bb73-517f236dc9fe"}
iex> %{merchant_order_id: "7c17771a-1b66-494f-bb73-517f236dc9fe"} |> map_from_cielo()
%{merchant_order_id: "7c17771a-1b66-494f-bb73-517f236dc9fe"}
Convert atom keyed map for a Cielo's valid map.
Examples
iex> %{merchant_order_id: "7c17771a-1b66-494f-bb73-517f236dc9fe"} |> map_from_cielo()
%{"MerchantOrderId" => "7c17771a-1b66-494f-bb73-517f236dc9fe"}
iex> %{"MerchantOrderId" => "7c17771a-1b66-494f-bb73-517f236dc9fe"} |> map_from_cielo()
%{"MerchantOrderId" => "7c17771a-1b66-494f-bb73-517f236dc9fe"}
Specs
Helper function for setting cielo
application environment
variables.
Example
iex> Cielo.put_env(:thingy, "thing")
...> Cielo.Utils.get_env(:thingy)
"thing"