provider

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseProvider

type BaseProvider struct {
}

BaseProvider implements base provider functionality

func (*BaseProvider) BuildEntity

func (b *BaseProvider) BuildEntity(endpoint string, providerCode string, baseCurrency string, quotedCurrency string, rate float64, rateTime time.Time, providerTime time.Time) *entity.CurrencyRate

BuildEntity builds entity with given rates

func (*BaseProvider) GetRateGenerationTime

func (b *BaseProvider) GetRateGenerationTime(timeStr string) time.Time

GetRateGenerationTime returns time, when provider generates history rates for today and we can fetch it.

func (*BaseProvider) IsRequestValid

func (b *BaseProvider) IsRequestValid(p RatesProvider, ratesRequest model.RatesRequest) (bool, error)

IsRequestValid validates API call to provider.

type RatesProvider

type RatesProvider interface {
	GetCode() string
	GetConfig() model.ProviderConfig
	GetHistoricalRates(ratesRequest model.RatesRequest) (model.RatesResponse, error)
	GetLatestRates(ratesRequest model.RatesRequest) (model.RatesResponse, error)
	PreloadRates(date time.Time, save bool) (map[string]float64, map[string]float64, time.Time, error)
	GetRateGenerationTime() time.Time
	GetSupportedCurrencies() []string
	IsRequestValid(ratesRequest model.RatesRequest) (bool, error)
	GetLocation() *time.Location
	BuildEntity(endpoint string, baseCurrency string, quotedCurrency string, rate float64, rateDate time.Time, providerDate time.Time) *entity.CurrencyRate
}

RatesProvider for all currency rates providers

type Registry

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

Registry is providers container

func BuildRegistry

func BuildRegistry() (*Registry, error)

BuildRegistry constructor

func (*Registry) AddProvider

func (r *Registry) AddProvider(provider RatesProvider)

AddProvider add provider instance to Registry

func (*Registry) GetProvider

func (r *Registry) GetProvider(code string) (RatesProvider, error)

GetProvider returns provider's instance from Registry by code

Directories

Path Synopsis
Package emirates implements emirates provider related code
Package emirates implements emirates provider related code
Package fixer implements fixer.io provider related code
Package fixer implements fixer.io provider related code

Jump to

Keyboard shortcuts

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