-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
96 lines (82 loc) · 2.1 KB
/
types.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package capis
type (
// Rate is a generic representation from capis.
Rate struct {
Value float64 `json:"value"`
Description string `json:"description"`
}
// RatePeriod is a generic representation from capis.
RatePeriod struct {
Rate
Period Months `json:"period"`
}
// Months is a generic representation from capis.
Months struct {
Value int64 `json:"value"`
Description string `json:"description"`
}
// Years is a generic representation from capis.
Years struct {
Value int64 `json:"value"`
Description string `json:"description"`
}
// Money is a generic representation from capis.
Money struct {
Currency string `json:"currency"`
Amount int64 `json:"amount"`
Description string `json:"description"`
}
// Fee is a generic representation from capis.
Fee struct {
Fixed *Money `json:"fixed,omitempty"`
Variable float64 `json:"variable,omitempty"`
Description string `json:"description"`
}
)
// NewRate returns a new struct representing Rate.
func NewRate(v float64, d string) Rate {
return Rate{v, d}
}
// NewRatePeriod returns a new struct representing RatePeriod.
func NewRatePeriod(v float64, d string, m Months) RatePeriod {
return RatePeriod{
Rate: NewRate(v, d),
Period: m,
}
}
// NewMonths returns a new struct representing Months.
func NewMonths(m int64, d string) Months {
return Months{
Value: m,
Description: d,
}
}
// NewYears returns a new struct representing Years.
func NewYears(y int64, d string) Years {
return Years{
Value: y,
Description: d,
}
}
// NewMoney returns a new struct representing Money.
func NewMoney(c string, a int64, d string) Money {
return Money{
Currency: c,
Amount: a,
Description: d,
}
}
// NewFixedFee returns a new struct representing FixedFee.
func NewFixedFee(money *Money, description string) Fee {
return Fee{
Fixed: money,
Description: description,
}
}
// NewVariableFee returns a new struct representing VariableFee.
func NewVariableFee(pcent float64, description string) Fee {
return Fee{
Variable: pcent,
Description: description,
}
}