-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
56 lines (49 loc) · 1.31 KB
/
account.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
package kugo
import (
"encoding/json"
"errors"
"net/http"
)
// SpotAccount GET /api/v1/accounts
func (kc *Kucoin) SpotAccount(currency, _type string) ([]AccountsData, error) {
uri := UriSpotAccount
p := map[string]string{}
if len(currency) != 0 {
p["currency"] = currency
}
if len(_type) != 0 {
p["type"] = _type
}
resp, err := kc.do(kc.spotEndpoint, http.MethodGet, uri, p)
if err != nil {
return nil, err
}
respStruct := &AccountsResponse{}
if err = json.Unmarshal(resp.Body(), &respStruct); err != nil {
return nil, err
}
if respStruct.Code != "200000" && respStruct.Code != "200" || len(respStruct.Msg) != 0 {
return nil, errors.New(respStruct.Msg)
}
return respStruct.Data, nil
}
// FutureAccount GET /api/v1/account-overview
func (kc *Kucoin) FutureAccount(currency string) (*FutureAccountData, error) {
uri := UriFutureAccount
p := map[string]string{}
if len(currency) != 0 {
p["currency"] = currency
}
resp, err := kc.do(kc.futureEndpoint, http.MethodGet, uri, p)
if err != nil {
return nil, err
}
respStruct := &FutureAccountResponse{}
if err = json.Unmarshal(resp.Body(), &respStruct); err != nil {
return nil, err
}
if respStruct.Code != "200000" && respStruct.Code != "200" || len(respStruct.Msg) != 0 {
return nil, errors.New(respStruct.Msg)
}
return &respStruct.Data, nil
}