Documentation ¶
Index ¶
Constants ¶
View Source
const ( Eur = "EUR" Usd = "USD" )
View Source
const ( ExchangeRateRefresh = 8 * time.Hour ExchangeRateUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml" HistoricalExchangeRateUrl = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml" ExchangeRateDateKey = "currency_exchange_last_refresh" HistoricalExchangeRateDateKey = "currency_exchange_historical_last_refresh" )
View Source
const YMDLayout = "2006-01-02"
Variables ¶
View Source
var Currencies = map[string]string{ Eur: "€", Usd: "$", }
Functions ¶
func NewCurrencyModule ¶
func NewCurrencyModule() kernel.ModuleFactory
Types ¶
type ExchangeResponse ¶
type HistoricalBody ¶
type HistoricalBody struct {
Content []Content `xml:"Cube"`
}
type HistoricalExchangeResponse ¶
type HistoricalExchangeResponse struct { Subject string `xml:"subject"` Sender Sender `xml:"Sender"` Body HistoricalBody `xml:"Cube"` }
type Module ¶
type Module struct { kernel.BackgroundModule kernel.ServiceStage // contains filtered or unexported fields }
type Service ¶
type Service interface { HasCurrency(ctx context.Context, currency string) (bool, error) HasCurrencyAtDate(ctx context.Context, currency string, date time.Time) (bool, error) ToEur(ctx context.Context, value float64, fromCurrency string) (float64, error) ToEurAtDate(ctx context.Context, value float64, fromCurrency string, date time.Time) (float64, error) ToUsd(ctx context.Context, value float64, fromCurrency string) (float64, error) ToUsdAtDate(ctx context.Context, value float64, fromCurrency string, date time.Time) (float64, error) ToCurrency(ctx context.Context, toCurrency string, value float64, fromCurrency string) (float64, error) ToCurrencyAtDate(ctx context.Context, toCurrency string, value float64, fromCurrency string, date time.Time) (float64, error) }
type UpdaterService ¶
type UpdaterService interface { EnsureRecentExchangeRates(ctx context.Context) error EnsureHistoricalExchangeRates(ctx context.Context) error }
func NewUpdater ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.