-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccountInfo.go
48 lines (35 loc) · 923 Bytes
/
accountInfo.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 wazirx_client
import (
"context"
"encoding/json"
"net/http"
helpers "github.com/yuvan11/wazirx-go/wazirx-client/Helpers"
api "github.com/yuvan11/wazirx-go/wazirx-client/endpoints"
)
type AccountInfoService struct {
C *Client
}
type AccountInfo struct {
AccountType string `json:"accountType"`
CanTrade bool `json:"canTrade"`
CanWithdraw bool `json:"canWithdraw"`
UpdateTime int64 `json:"updateTime"`
}
func (s *AccountInfoService) FetchAccountInfo(ctx context.Context) (*AccountInfo, error) {
r := &Request{
Method: http.MethodGet,
Endpoint: api.ACCOUNT,
SecType: SecTypeSigned,
RecvWindow: 10000,
TimeStamp: helpers.CurrentTimestamp(),
}
data, err := s.C.HandleAPI(ctx, r)
if err != nil {
return &AccountInfo{}, err
}
result := new(AccountInfo)
if err := json.Unmarshal(data, &result); err != nil {
return &AccountInfo{}, err
}
return result, nil
}