File tree Expand file tree Collapse file tree 4 files changed +130
-47
lines changed Expand file tree Collapse file tree 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
5252 }
5353 return res , nil
5454}
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 11package currency
22
33import (
4- "time"
4+ "time"
55)
66
77type (
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+ }
3140)
Original file line number Diff line number Diff line change @@ -23,3 +23,10 @@ func TestClient_List(t *testing.T) {
2323 assert .NotZero (t , len (res .Currencies ))
2424 }
2525}
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