savvy v0.1.0 Savvy View Source

SDK for Savvy https://www.savvy.io

You need to export the following environment variables:

export SAVVY_URL="https://api.test.savvy.io"

export SAVVY_SECRET="YOUSAVVYSECRECT"

export SAVVY_CALLBACK="http://localhost"

Link to this section Summary

Functions

Create payment request and get payment address

Get a list of enabled currencies

Get exchange rates for one currency

Get the current average market rates

Link to this section Functions

Link to this function

create_payment(crypto, lock_address_timeout \\ 3600) View Source
create_payment(bitstring(), integer()) ::
  map() | {:error, bitstring()} | {:error, [map()]}

Create payment request and get payment address.

crypto: Crypto currency to accept (eth, btc, bch, ltc, dash, btg, etc)

Examples

iex> Savvy.create_payment("xxx")
{:error,
   [%{"data" => "xxx", "message" => "unsupported blockchain or ERC20 token"}]}
Link to this function

get_currencies() View Source
get_currencies() :: map() | {:error, bitstring()}

Get a list of enabled currencies

Link to this function

get_rate(fiat_code, crypto, unix_time \\ -1) View Source
get_rate(bitstring(), bitstring(), integer()) ::
  map() | {:error, bitstring()} | {:error, [map()]}

Get exchange rates for one currency

Examples

iex> Savvy.get_rate("xxx", "btc")
{:error, [%{"data" => "xxx", "message" => "unsupported currency"}]}

iex> Savvy.get_rate("usd", "xxx")
{:error, [%{"data" => "xxx", "message" => "unsupported chain type"}]}

iex> Savvy.get_rate("usd", "btc", 1)
{:error,
  [%{"data" => nil, "message" => "Exchanges was not found for this period"}]}

iex> Savvy.get_rate("usd", "btc", 1546300800)
%{
    "bitfinex" => 3832.8,
    "bittrex" => 3700.6162327800002,
    "coinmarketcap" => 3742.70033544,
    "hitbtc" => 3719.27,
    "mid" => 3738.0038736560005,
    "poloniex" => 3694.63280006
}
Link to this function

get_rates(fiat_code, unix_time \\ -1) View Source
get_rates(bitstring(), integer()) ::
  map() | {:error, bitstring()} | {:error, [map()]}

Get the current average market rates.

fiat_code: Fiat currency (usd, eur, cad, etc)

Examples

iex> Savvy.get_rates("xxx")
{:error, [%{"data" => "xxx", "message" => "unsupported currency"}]}

iex> Savvy.get_rates("usd", 1)
{:error,
   [%{"data" => nil, "message" => "Exchanges was not found for this period"}]}