Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateConverter ¶
type RateConverter struct {
// contains filtered or unexported fields
}
RateConverter holds the currencies conversion rates dictionnary
func NewRateConverter ¶
func NewRateConverter( httpClient httpClient, syncSourceURL string, fetchingInterval time.Duration, ) *RateConverter
NewRateConverter returns a new RateConverter
func NewRateConverterWithNotifier ¶
func NewRateConverterWithNotifier( httpClient httpClient, syncSourceURL string, fetchingInterval time.Duration, updateNotifier chan<- int, ) *RateConverter
NewRateConverterWithNotifier returns a new RateConverter it allow to pass an update chan in which the number of ticks will be passed after each tick allowing clients to listen on updates Do not use this method
func (*RateConverter) LastUpdated ¶
func (rc *RateConverter) LastUpdated() time.Time
LastUpdated returns time when currencies rates were updated
func (*RateConverter) StopPeriodicFetching ¶
func (rc *RateConverter) StopPeriodicFetching()
StopPeriodicFetching stops the periodic fetching while keeping the latest currencies rates map
func (*RateConverter) Update ¶
func (rc *RateConverter) Update() error
Update updates the internal currencies rates from remote sources
type Rates ¶
type Rates struct { DataAsOf time.Time `json:"dataAsOf"` Conversions map[string]map[string]float64 `json:"conversions"` }
Rates holds data as represented on http://currency.prebid.org/latest.json note that `DataAsOfRaw` field is needed when parsing remote JSON as the date format if not standard and requires custom parsing to be properly set as Golang time.Time
func (*Rates) GetRate ¶
GetRate returns the conversion rate between two currencies returns an error in case the conversion rate between the two given currencies is not in the currencies rates map
func (*Rates) UnmarshalJSON ¶
UnmarshalJSON unmarshal raw JSON bytes to Rates object