emirates

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package emirates implements emirates provider related code

Index

Constants

View Source
const Code = "emirates"

Code emirates provider code

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiResponse

type ApiResponse struct {
	// HTML table in json field
	Table string `json:"table"`

	// Currency rates last updated time
	LastUpdated string `json:"last_updated"`
}

type Provider

type Provider struct {
	provider.BaseProvider
	// contains filtered or unexported fields
}

Provider implements emirates provider structure

func New

func New(db *gorm.DB, config *model.ApplicationConfig) *Provider

New constructor

func (Provider) BuildEntity

func (p Provider) BuildEntity(endpoint string, baseCurrency string, quotedCurrency string, rate float64, rateDate time.Time, providerDate time.Time) *entity.CurrencyRate

BuildEntity builds entity with given rates

func (Provider) GetCode

func (p Provider) GetCode() string

GetCode returns provider code

func (Provider) GetConfig

func (p Provider) GetConfig() model.ProviderConfig

GetConfig returns provider config

func (Provider) GetHistoricalRates

func (p Provider) GetHistoricalRates(serviceRequest model.RatesRequest) (model.RatesResponse, error)

GetHistoricalRates searches for rates in internal DB, fetch from provider API if needed and saves to internal DB

func (Provider) GetLatestRates

func (p Provider) GetLatestRates(serviceRequest model.RatesRequest) (model.RatesResponse, error)

GetLatestRates provides yesterday-defined rate for today latest rate if time < 23:00

func (Provider) GetLocation

func (p Provider) GetLocation() *time.Location

GetLocation returns location for current provider

func (Provider) GetRateGenerationTime

func (p Provider) GetRateGenerationTime() time.Time

GetRateGenerationTime returns historical rates generated time on provider side

func (Provider) GetSupportedCurrencies

func (p Provider) GetSupportedCurrencies() []string

GetSupportedCurrencies returns list of currencies, supported by provider

func (Provider) IsRequestValid

func (p Provider) IsRequestValid(ratesRequest model.RatesRequest) (bool, error)

IsRequestValid validates API call to provider.

func (Provider) PreloadRates

func (p Provider) PreloadRates(dateObject time.Time, save bool) (map[string]float64, map[string]float64, time.Time, error)

PreloadRates fetch (all rates for date) and save if not

Jump to

Keyboard shortcuts

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