nbpapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoExchangeRateForGivenDay = errors.New("no exchange rate for given date")

ErrNoExchangeRateForGivenDay represents a failure where there are no published rates for a given day

View Source
var ErrNoRatesForCurrency = errors.New("currency without published rates")

ErrNoRatesForCurrency represents a failure where NBP doesn't publish exchange rates for the given currency

Functions

This section is empty.

Types

type Client

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

Client is a low-level client over the NBP rates API

func Init

func Init(client httpClient) *Client

Init returns *Rates instance with net/http.DefaultClient

func (*Client) Get

func (c *Client) Get(curr string, day time.Time) (*Rates, error)

Get returns the currency exchange rate for a given date from NBP table A

type DailyRate

type DailyRate struct {
	No            string          `json:"no"`
	EffectiveDate string          `json:"effectiveDate"`
	Mid           decimal.Decimal `json:"mid"`
}

DailyRate represent a rate for a single day

type ErrApiCallUnsuccessful

type ErrApiCallUnsuccessful struct {
	Code int
	Body string
}

ErrApiCallUnsuccessful represents a generic unsuccessful API call

func (ErrApiCallUnsuccessful) Error

func (e ErrApiCallUnsuccessful) Error() string

type Rates

type Rates struct {
	Table    string      `json:"table"`
	Currency string      `json:"currency"`
	Code     string      `json:"code"`
	Rates    []DailyRate `json:"rates"`
}

Rates represents the return value of the NBP rates API

Jump to

Keyboard shortcuts

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