currency

package
v0.0.0-...-795d1ad Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code struct {
	// e.g United States Dollar
	Currency string `json:"currency"`
	// e.g USD
	Name string `json:"name"`
}

type CodesRequest

type CodesRequest struct {
}

type CodesResponse

type CodesResponse struct {
	Codes []Code `json:"codes"`
}

type ConvertRequest

type ConvertRequest struct {
	// optional amount to convert e.g 10.0
	Amount float64 `json:"amount"`
	// base code to convert from e.g USD
	From string `json:"from"`
	// target code to convert to e.g GBP
	To string `json:"to"`
}

type ConvertResponse

type ConvertResponse struct {
	// converted amount e.g 7.10
	Amount float64 `json:"amount"`
	// the base code e.g USD
	From string `json:"from"`
	// conversion rate e.g 0.71
	Rate float64 `json:"rate"`
	// the target code e.g GBP
	To string `json:"to"`
}

type CurrencyService

type CurrencyService struct {
	// contains filtered or unexported fields
}

func NewCurrencyService

func NewCurrencyService(token string) *CurrencyService

func (*CurrencyService) Codes

func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error)

Codes returns the supported currency codes for the API

func (*CurrencyService) Convert

func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error)

Convert returns the currency conversion rate between two pairs e.g USD/GBP

func (*CurrencyService) History

func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error)

Returns the historic rates for a currency on a given date

func (*CurrencyService) Rates

func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error)

Rates returns the currency rates for a given code e.g USD

type HistoryRequest

type HistoryRequest struct {
	// currency code e.g USD
	Code string `json:"code"`
	// date formatted as YYYY-MM-DD
	Date string `json:"date"`
}

type HistoryResponse

type HistoryResponse struct {
	// The code of the request
	Code string `json:"code"`
	// The date requested
	Date string `json:"date"`
	// The rate for the day as code:rate
	Rates map[string]float64 `json:"rates"`
}

type RatesRequest

type RatesRequest struct {
	// The currency code to get rates for e.g USD
	Code string `json:"code"`
}

type RatesResponse

type RatesResponse struct {
	// The code requested e.g USD
	Code string `json:"code"`
	// The rates for the given code as key-value pairs code:rate
	Rates map[string]float64 `json:"rates"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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