-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_opts.go
39 lines (33 loc) · 1.01 KB
/
convert_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
package oxr
type convertParams struct {
value float64
baseCurrency string
destinationCurrency string
prettyPrint bool
}
// ConvertOption allows the client to specify values for a conversion request.
type ConvertOption func(*convertParams)
// ConvertForBaseCurrency sets the base currency for a conversion.
func ConvertForBaseCurrency(currency string) ConvertOption {
return func(p *convertParams) {
p.baseCurrency = currency
}
}
// ConvertForDestinationCurrency sets the destination currency for a conversion.
func ConvertForDestinationCurrency(currency string) ConvertOption {
return func(p *convertParams) {
p.destinationCurrency = currency
}
}
// ConvertWithValue sets the value to be converted.
func ConvertWithValue(value float64) ConvertOption {
return func(p *convertParams) {
p.value = value
}
}
// ConvertWithPrettyPrint sets whether to minify the response.
func ConvertWithPrettyPrint(active bool) ConvertOption {
return func(p *convertParams) {
p.prettyPrint = active
}
}