-
Notifications
You must be signed in to change notification settings - Fork 0
/
latest_opts.go
43 lines (36 loc) · 1.09 KB
/
latest_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
package oxr
import (
"strings"
)
type latestParams struct {
baseCurrency string
destinationCurrencies string
showAlternative bool
prettyPrint bool
}
// LatestOption allows the client to specify values for a latest request.
type LatestOption func(params *latestParams)
// LatestForBaseCurrency sets the base currency.
func LatestForBaseCurrency(currency string) LatestOption {
return func(p *latestParams) {
p.baseCurrency = currency
}
}
// LatestForDestinationCurrencies sets the destination currencies to be included in the response.
func LatestForDestinationCurrencies(currencies []string) LatestOption {
return func(p *latestParams) {
p.destinationCurrencies = strings.Join(currencies, ",")
}
}
// LatestWithAlternatives sets whether to include alternative currencies.
func LatestWithAlternatives(active bool) LatestOption {
return func(p *latestParams) {
p.showAlternative = active
}
}
// LatestWithPrettyPrint sets whether to minify the response.
func LatestWithPrettyPrint(active bool) LatestOption {
return func(p *latestParams) {
p.prettyPrint = active
}
}