File tree 4 files changed +130
-47
lines changed
4 files changed +130
-47
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,21 @@ func (c *CurrencyService) List(req *currency.ListRequest) (*currency.ListRespons
52
52
}
53
53
return res , nil
54
54
}
55
+
56
+ func (c * CurrencyService ) Rates (req * currency.RatesRequest ) (* currency.RatesResponse , error ) {
57
+ res := new (currency.RatesResponse )
58
+ err := new (Error )
59
+ r , e := c .resty .R ().
60
+ SetResult (res ).
61
+ SetError (err ).
62
+ Get ("/rates" )
63
+ if e != nil {
64
+ return nil , & Error {
65
+ Message : e .Error (),
66
+ }
67
+ }
68
+ if isError (r .StatusCode ()) {
69
+ return nil , err
70
+ }
71
+ return res , nil
72
+ }
Original file line number Diff line number Diff line change 1
1
package currency
2
2
3
3
import (
4
- "time"
4
+ "time"
5
5
)
6
6
7
7
type (
8
- Currency struct {
9
- Name string `json:"name"`
10
- Code string `json:"code"`
11
- Symbol string `json:"symbol"`
12
- }
13
-
14
- ConvertRequest struct {
15
- Amount float64
16
- From string
17
- To string
18
- }
19
-
20
- ConvertResponse struct {
21
- Time time.Time `json:"time"`
22
- Amount float64 `json:"amount"`
23
- }
24
-
25
- ListRequest struct {
26
- }
27
-
28
- ListResponse struct {
29
- Currencies []* Currency `json:"currencies"`
30
- }
8
+ Currency struct {
9
+ Name string `json:"name"`
10
+ Code string `json:"code"`
11
+ Symbol string `json:"symbol"`
12
+ }
13
+
14
+ ConvertRequest struct {
15
+ Amount float64
16
+ From string
17
+ To string
18
+ }
19
+
20
+ ConvertResponse struct {
21
+ Time time.Time `json:"time"`
22
+ Amount float64 `json:"amount"`
23
+ }
24
+
25
+ ListRequest struct {
26
+ }
27
+
28
+ ListResponse struct {
29
+ Currencies []* Currency `json:"currencies"`
30
+ }
31
+
32
+ RatesRequest struct {
33
+ }
34
+
35
+ RatesResponse struct {
36
+ Time time.Time `json:"time"`
37
+ Base string `json:"base"`
38
+ Rates map [string ]float64 `json:"rates"`
39
+ }
31
40
)
Original file line number Diff line number Diff line change @@ -23,3 +23,10 @@ func TestClient_List(t *testing.T) {
23
23
assert .NotZero (t , len (res .Currencies ))
24
24
}
25
25
}
26
+
27
+ func TestClient_Rates (t * testing.T ) {
28
+ res , err := cs .Rates (& currency.RatesRequest {})
29
+ if assert .Nil (t , err ) {
30
+ assert .NotZero (t , len (res .Rates ))
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments