forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pay_service.go
80 lines (71 loc) · 1.97 KB
/
pay_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
package binance
import (
"context"
"net/http"
)
// PayTransactionService retrieve the fiat deposit/withdraw history
type PayTradeHistoryService struct {
c *Client
startTimestamp *int64
endTimestamp *int64
limit *int32
}
// StartTimestamp set startTimestamp
func (s *PayTradeHistoryService) StartTimestamp(startTimestamp int64) *PayTradeHistoryService {
s.startTimestamp = &startTimestamp
return s
}
// EndTimestamp set endTimestamp
func (s *PayTradeHistoryService) EndTimestamp(endTimestamp int64) *PayTradeHistoryService {
s.endTimestamp = &endTimestamp
return s
}
// Rows set rows
func (s *PayTradeHistoryService) Limit(limit int32) *PayTradeHistoryService {
s.limit = &limit
return s
}
// Do send request
func (s *PayTradeHistoryService) Do(ctx context.Context, opts ...RequestOption) (*PayTradeHistory, error) {
r := &request{
method: http.MethodGet,
endpoint: "/sapi/v1/pay/transactions",
secType: secTypeSigned,
}
if s.startTimestamp != nil {
r.setParam("startTimestamp", *s.startTimestamp)
}
if s.endTimestamp != nil {
r.setParam("endTimestamp", *s.endTimestamp)
}
if s.limit != nil {
r.setParam("limit", *s.limit)
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res := PayTradeHistory{}
if err = json.Unmarshal(data, &res); err != nil {
return nil, err
}
return &res, nil
}
type PayTradeHistory struct {
Code string `json:"code"`
Message string `json:"message"`
Data []PayTradeItem `json:"data"`
Success bool `json:"success"`
}
type PayTradeItem struct {
OrderType string `json:"orderType"`
TransactionID string `json:"transactionId"`
TransactionTime int64 `json:"transactionTime"`
Amount string `json:"amount"`
Currency string `json:"currency"`
FundsDetail []FundsDetail `json:"fundsDetail"`
}
type FundsDetail struct {
Currency string `json:"currency"`
Amount string `json:"amount"`
}