fetchers

package
v0.0.0-...-8bbfd3c Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrencyBeaconFetcher

type CurrencyBeaconFetcher struct {
	APIKey string
	// contains filtered or unexported fields
}

func NewCurrencyBeaconFetcher

func NewCurrencyBeaconFetcher(apiKey string) *CurrencyBeaconFetcher

func (*CurrencyBeaconFetcher) FetchRate

func (c *CurrencyBeaconFetcher) FetchRate(
	ctx context.Context, ccFrom, ccTo string,
) (rate.Rate, error)

func (*CurrencyBeaconFetcher) SetNext

func (c *CurrencyBeaconFetcher) SetNext(r RateFetcher)

func (*CurrencyBeaconFetcher) String

func (c *CurrencyBeaconFetcher) String() string

func (*CurrencyBeaconFetcher) SupportedCurrencies

func (c *CurrencyBeaconFetcher) SupportedCurrencies(ctx context.Context) []string

type NBURateFetcher

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

NBURateFetcher is a RateFetcher implementation that fetches rates from the National Bank of Ukraine API docs: https://bank.gov.ua/ua/open-data/api-dev NOTE: CurrencyTo can only be "UAH", as the NBU API only supports fetching rates for UAH

Example usage:

fetcher := NewNBURateFetcher()
rate, err := fetcher.FetchRate(context.Background(), "USD", "UAH")
if err != nil {
	log.Fatal(err)
}
fmt.Println(rate)

func NewNBURateFetcher

func NewNBURateFetcher() *NBURateFetcher

func (*NBURateFetcher) FetchRate

func (n *NBURateFetcher) FetchRate(ctx context.Context, ccFrom, ccTo string) (rate.Rate, error)

func (*NBURateFetcher) SetNext

func (n *NBURateFetcher) SetNext(next RateFetcher)

func (*NBURateFetcher) String

func (n *NBURateFetcher) String() string

func (*NBURateFetcher) SupportedCurrencies

func (n *NBURateFetcher) SupportedCurrencies(_ context.Context) []string

type RateFetcher

type RateFetcher interface {
	FetchRate(ctx context.Context, ccFrom, ccTo string) (rate.Rate, error)
	SetNext(next RateFetcher)
}

RateFetcher is an interface that defines the general behavior of a rate fetcher. This fetcher interfaces presumes the use of Chain of Responsibility pattern.

Jump to

Keyboard shortcuts

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