currencylayer

package
v0.0.0-...-b8e8dbd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountFree = iota
	AccountBasic
	AccountPro
	AccountEnterprise

	APIEndpointURL        = "http://apilayer.net/api/"
	APIEndpointURLSSL     = "https://apilayer.net/api/"
	APIEndpointList       = "list"
	APIEndpointLive       = "live"
	APIEndpointHistorical = "historical"
	APIEndpointConversion = "convert"
	APIEndpointTimeframe  = "timeframe"
	APIEndpointChange     = "change"
)

const declarations consist of endpoints and APIKey privileges

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeRate

type ChangeRate struct {
	Success bool `json:"success"`
	Error   struct {
		Code int    `json:"code"`
		Info string `json:"info"`
	} `json:"error"`
	Terms     string             `json:"terms"`
	Privacy   string             `json:"privacy"`
	Change    bool               `json:"change"`
	StartDate string             `json:"start_date"`
	EndDate   string             `json:"end_date"`
	Source    string             `json:"source"`
	Quotes    map[string]Changes `json:"quotes"`
}

ChangeRate is the response type that holds rate change data.

type Changes

type Changes struct {
	StartRate float64 `json:"start_rate"`
	EndRate   float64 `json:"end_rate"`
	Change    float64 `json:"change"`
	ChangePCT float64 `json:"change_pct"`
}

Changes is a sub-type of ChangeRate that holds the actual changes of rates.

type ConversionRate

type ConversionRate struct {
	Success bool `json:"success"`
	Error   struct {
		Code int    `json:"code"`
		Info string `json:"info"`
	} `json:"error"`
	Privacy string `json:"privacy"`
	Terms   string `json:"terms"`
	Query   struct {
		From   string  `json:"from"`
		To     string  `json:"to"`
		Amount float64 `json:"amount"`
	} `json:"query"`
	Info struct {
		Timestamp int64   `json:"timestamp"`
		Quote     float64 `json:"quote"`
	} `json:"info"`
	Historical bool    `json:"historical"`
	Date       string  `json:"date"`
	Result     float64 `json:"result"`
}

ConversionRate is a response type holding a converted rate.

type CurrencyLayer

type CurrencyLayer struct {
	base.Base
}

CurrencyLayer is a foreign exchange rate provider at https://currencylayer.com NOTE default base currency is USD when using a free account. Has automatic upgrade to a SSL connection.

func (*CurrencyLayer) Convert

func (c *CurrencyLayer) Convert(from, to, date string, amount float64) (float64, error)

Convert converts one currency amount to another currency amount.

func (*CurrencyLayer) GetHistoricalData

func (c *CurrencyLayer) GetHistoricalData(date string, currencies []string, source string) (map[string]float64, error)

GetHistoricalData returns historical exchange rate data for every past day of the last 16 years.

func (*CurrencyLayer) GetRates

func (c *CurrencyLayer) GetRates(baseCurrency, symbols string) (map[string]float64, error)

GetRates is a wrapper function to return rates for GoCryptoTrader

func (*CurrencyLayer) GetSupportedCurrencies

func (c *CurrencyLayer) GetSupportedCurrencies() (map[string]string, error)

GetSupportedCurrencies returns supported currencies

func (*CurrencyLayer) GetliveData

func (c *CurrencyLayer) GetliveData(currencies, source string) (map[string]float64, error)

GetliveData returns live quotes for foreign exchange currencies

func (*CurrencyLayer) QueryCurrencyChange

func (c *CurrencyLayer) QueryCurrencyChange(startDate, endDate, base string, currencies []string) (map[string]Changes, error)

QueryCurrencyChange returns the change (both margin and percentage) of one or more currencies, relative to a Source Currency, within a specific time-frame (optional).

func (*CurrencyLayer) QueryTimeFrame

func (c *CurrencyLayer) QueryTimeFrame(startDate, endDate, base string, currencies []string) (map[string]interface{}, error)

QueryTimeFrame returns historical exchange rates for a time-period. (maximum range: 365 days)

func (*CurrencyLayer) SendHTTPRequest

func (c *CurrencyLayer) SendHTTPRequest(endPoint string, values url.Values, result interface{}) error

SendHTTPRequest sends a HTTP request, if account is not free it automatically upgrades request to SSL.

func (*CurrencyLayer) Setup

func (c *CurrencyLayer) Setup(config base.Settings)

Setup sets appropriate values for CurrencyLayer

type HistoricalRates

type HistoricalRates struct {
	Success bool `json:"success"`
	Error   struct {
		Code int    `json:"code"`
		Info string `json:"info"`
	} `json:"error"`
	Terms      string             `json:"terms"`
	Privacy    string             `json:"privacy"`
	Historical bool               `json:"historical"`
	Date       string             `json:"date"`
	Timestamp  int64              `json:"timestamp"`
	Source     string             `json:"source"`
	Quotes     map[string]float64 `json:"quotes"`
}

HistoricalRates is a response type holding rates priced from the past.

type LiveRates

type LiveRates struct {
	Success bool `json:"success"`
	Error   struct {
		Code int    `json:"code"`
		Info string `json:"info"`
	} `json:"error"`
	Terms     string             `json:"terms"`
	Privacy   string             `json:"privacy"`
	Timestamp int64              `json:"timestamp"`
	Source    string             `json:"source"`
	Quotes    map[string]float64 `json:"quotes"`
}

LiveRates is a response type holding rates priced now.

type SupportedCurrencies

type SupportedCurrencies struct {
	Success bool `json:"success"`
	Error   struct {
		Code int    `json:"code"`
		Info string `json:"info"`
	} `json:"error"`
	Terms      string            `json:"terms"`
	Privacy    string            `json:"privacy"`
	Currencies map[string]string `json:"currencies"`
}

SupportedCurrencies holds supported currency information

type TimeFrame

type TimeFrame struct {
	Success bool `json:"success"`
	Error   struct {
		Code int    `json:"code"`
		Info string `json:"info"`
	} `json:"error"`
	Terms     string                 `json:"terms"`
	Privacy   string                 `json:"privacy"`
	Timeframe bool                   `json:"timeframe"`
	StartDate string                 `json:"start_date"`
	EndDate   string                 `json:"end_date"`
	Source    string                 `json:"source"`
	Quotes    map[string]interface{} `json:"quotes"`
}

TimeFrame is a response type holding exchange rates for a time period

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL