-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistorical_opts.go
52 lines (44 loc) · 1.4 KB
/
historical_opts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package oxr
import (
"strings"
"time"
)
type historicalParams struct {
date time.Time
baseCurrency string
destinationCurrencies string
showAlternative bool
prettyPrint bool
}
// HistoricalOption allows the client to specify values for a historical request.
type HistoricalOption func(*historicalParams)
// HistoricalForBaseCurrency sets the base currency for the historical request.
func HistoricalForBaseCurrency(currency string) HistoricalOption {
return func(p *historicalParams) {
p.baseCurrency = currency
}
}
// HistoricalForDestinationCurrencies sets the destination currency for the historical request.
func HistoricalForDestinationCurrencies(currencies []string) HistoricalOption {
return func(p *historicalParams) {
p.destinationCurrencies = strings.Join(currencies, ",")
}
}
// HistoricalWithAlternatives sets whether to include alternative currencies.
func HistoricalWithAlternatives(active bool) HistoricalOption {
return func(p *historicalParams) {
p.showAlternative = active
}
}
// HistoricalForDate sets the date of the rate to be requested.
func HistoricalForDate(date time.Time) HistoricalOption {
return func(p *historicalParams) {
p.date = date
}
}
// HistoricalWithPrettyPrint sets whether to minify the response.
func HistoricalWithPrettyPrint(active bool) HistoricalOption {
return func(p *historicalParams) {
p.prettyPrint = active
}
}