forked from ccxt/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstituents_service.go
48 lines (40 loc) · 995 Bytes
/
constituents_service.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
package futures
import (
"context"
"encoding/json"
"net/http"
)
type ConstituentsService struct {
c *Client
symbol string // for example, BTCUSDT
}
type ConstituentsServiceRsp struct {
Symbol string `json:"symbol"`
Time uint64 `json:"time"`
Constituents []*Constituents `json:"constituents"`
}
type Constituents struct {
Exchange string `json:"exchange"`
Symbol string `json:"symbol"`
}
func (s *ConstituentsService) Symbol(symbol string) *ConstituentsService {
s.symbol = symbol
return s
}
func (s *ConstituentsService) Do(ctx context.Context, opts ...RequestOption) (res *ConstituentsServiceRsp, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/fapi/v1/constituents",
}
r.setParam("symbol", s.symbol)
data, _, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(ConstituentsServiceRsp)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}