forked from adshao/go-binance
/
pay_service.go
107 lines (98 loc) · 2.94 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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"`
PayerInfo *PayerInfo `json:"payerInfo"`
ReceiverInfo *ReceiverInfo `json:"receiverInfo"`
FundsDetail []FundsDetail `json:"fundsDetail"`
}
type FundsDetail struct {
Currency string `json:"currency"`
Amount string `json:"amount"`
}
type PayerInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Email string `json:"email"`
BinanceId int `json:"binanceId"`
AccountId int `json:"accountId"`
CountryCode int `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
MobileCode string `json:"mobileCode"`
UnmaskData bool `json:"unmaskData"`
}
type ReceiverInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Email string `json:"email,omitempty"`
BinanceId int `json:"binanceId,omitempty"`
AccountId int `json:"accountId"`
CountryCode int `json:"countryCode,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
MobileCode string `json:"mobileCode,omitempty"`
UnmaskData bool `json:"unmaskData"`
Extend struct {
PhoneOrEmailChanged bool `json:"phoneOrEmailChanged"`
} `json:"extend,omitempty"`
}