-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime_series_opts.go
60 lines (51 loc) · 1.63 KB
/
time_series_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
53
54
55
56
57
58
59
60
package oxr
import (
"strings"
"time"
)
type timeSeriesParams struct {
startDate time.Time
endDate time.Time
baseCurrency string
destinationCurrencies string
showAlternative bool
prettyPrint bool
}
// TimeSeriesOption allows the client to specify values for a TimeSeries request.
type TimeSeriesOption func(params *timeSeriesParams)
// TimeSeriesForBaseCurrency sets the base currency to be used.
func TimeSeriesForBaseCurrency(currency string) TimeSeriesOption {
return func(p *timeSeriesParams) {
p.baseCurrency = currency
}
}
// TimeSeriesForDestinationCurrencies sets the destination currencies to be included in the response.
func TimeSeriesForDestinationCurrencies(currencies []string) TimeSeriesOption {
return func(p *timeSeriesParams) {
p.destinationCurrencies = strings.Join(currencies, ",")
}
}
// TimeSeriesWithAlternatives sets whether to include alternative currencies in the response.
func TimeSeriesWithAlternatives(active bool) TimeSeriesOption {
return func(p *timeSeriesParams) {
p.showAlternative = active
}
}
// TimeSeriesForStartDate sets the start date of the period.
func TimeSeriesForStartDate(start time.Time) TimeSeriesOption {
return func(p *timeSeriesParams) {
p.startDate = start
}
}
// TimeSeriesForEndDate sets the end date of the period.
func TimeSeriesForEndDate(end time.Time) TimeSeriesOption {
return func(p *timeSeriesParams) {
p.endDate = end
}
}
// TimeSeriesWithPrettyPrint sets whether to minify the response.
func TimeSeriesWithPrettyPrint(active bool) TimeSeriesOption {
return func(p *timeSeriesParams) {
p.prettyPrint = active
}
}