forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeposit_service.go
88 lines (78 loc) · 1.8 KB
/
deposit_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package binance
import (
"context"
"encoding/json"
)
// ListDepositsService list deposits
type ListDepositsService struct {
c *Client
asset *string
status *int
startTime *int64
endTime *int64
}
// Asset set asset
func (s *ListDepositsService) Asset(asset string) *ListDepositsService {
s.asset = &asset
return s
}
// Status set status
func (s *ListDepositsService) Status(status int) *ListDepositsService {
s.status = &status
return s
}
// StartTime set startTime
func (s *ListDepositsService) StartTime(startTime int64) *ListDepositsService {
s.startTime = &startTime
return s
}
// EndTime set endTime
func (s *ListDepositsService) EndTime(endTime int64) *ListDepositsService {
s.endTime = &endTime
return s
}
// Do send request
func (s *ListDepositsService) Do(ctx context.Context, opts ...RequestOption) (deposits []*Deposit, err error) {
r := &request{
method: "POST",
endpoint: "/wapi/v1/getDepositHistory.html",
secType: secTypeSigned,
}
m := params{}
if s.asset != nil {
m["asset"] = *s.asset
}
if s.status != nil {
m["status"] = *s.status
}
if s.startTime != nil {
m["startTime"] = *s.startTime
}
if s.endTime != nil {
m["endTime"] = *s.endTime
}
r.setParams(m)
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return
}
res := new(DepositHistoryResponse)
err = json.Unmarshal(data, res)
if err != nil {
return
}
return res.Deposits, nil
}
// DepositHistoryResponse define deposit history
type DepositHistoryResponse struct {
Success bool `json:"success"`
Deposits []*Deposit `json:"depositList"`
}
// Deposit define deposit info
type Deposit struct {
InsertTime int64 `json:"insertTime"`
Amount float64 `json:"amount"`
Asset string `json:"asset"`
Status int `json:"status"`
TxID string `json:"txId"`
}