nbggovge

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package nbggovge provides functionality for fetching currency rates from nbg.gov.ge API.

Index

Constants

This section is empty.

Variables

View Source
var ErrCodeNotFound = errors.New("code not found in set")

ErrCodeNotFound returned when specified code could not be found in set.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Rates returns ratesResponse for today by default for a list of currency codes set up by options.
	Rates(ctx context.Context, opts ...option.RatesOption) (Rates, error)
}

Client is a contract for nbg.gov.ge API.

func New

func New() Client

New returns nbg.gov.ge API client.

func NewWithHTTPClient

func NewWithHTTPClient(c HTTPClient) Client

NewWithHTTPClient returns nbg.gov.ge API client with specified http client.

type Currency

type Currency struct {
	Code          string  `json:"code"`
	Quantity      int64   `json:"quantity"`
	RateFormated  string  `json:"rateFormated"`
	DiffFormated  string  `json:"diffFormated"`
	Rate          float64 `json:"rate"`
	Name          string  `json:"name"`
	Diff          float64 `json:"diff"`
	Date          string  `json:"date"`
	ValidFromDate string  `json:"validFromDate"`
}

Currency represents rates for one currency.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is and interface for mocking sending http requests.

type Rates

type Rates struct {
	Date       string     `json:"date"`
	Currencies []Currency `json:"currencies"`
}

Rates represents set of rates.

func (Rates) CurrencyByCode

func (r Rates) CurrencyByCode(code string) (Currency, error)

CurrencyByCode returns Currency from set by specified code. When no currency in set - ErrCodeNotFound returned.

Directories

Path Synopsis
Package currencies contains currency codes constants.
Package currencies contains currency codes constants.
Package internal holds internal logic and parameters for requests.
Package internal holds internal logic and parameters for requests.
Package mock provides mock implementations of nbggovge.Client.
Package mock provides mock implementations of nbggovge.Client.
Package option represents options pattern for Rates request.
Package option represents options pattern for Rates request.

Jump to

Keyboard shortcuts

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