forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_flexible_loan_borrow_history.go
111 lines (92 loc) · 2.75 KB
/
get_flexible_loan_borrow_history.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
108
109
110
111
package binance
import (
"context"
"net/http"
)
type GetFlexibleLoanBorrowHistoryService struct {
c *Client
loanCoin *string
collateralCoin *string
startTime *int64
endTime *int64
current *int64
limit *int64
}
type GetFlexibleLoanBorrowHistoryResp struct {
Rows []FlexibleLoanBorrowHistory `json:"rows"`
Total int64 `json:"total"`
}
type FlexibleLoanBorrowHistory struct {
LoanCoin string `json:"loanCoin"`
InitialLoanAmount string `json:"initialLoanAmount"`
CollateralCoin string `json:"collateralCoin"`
InitialCollateralAmount string `json:"initialCollateralAmount"`
BorrowTime interface{} `json:"borrowTime"`
Status FlexibleBorrowStatus `json:"status"`
}
// LoanCoin set loanCoin
func (s *GetFlexibleLoanBorrowHistoryService) LoanCoin(loanCoin string) *GetFlexibleLoanBorrowHistoryService {
s.loanCoin = &loanCoin
return s
}
// CollateralCoin set collateralCoin
func (s *GetFlexibleLoanBorrowHistoryService) CollateralCoin(coll string) *GetFlexibleLoanBorrowHistoryService {
s.collateralCoin = &coll
return s
}
// Current set current
func (s *GetFlexibleLoanBorrowHistoryService) Current(current int64) *GetFlexibleLoanBorrowHistoryService {
s.current = ¤t
return s
}
// Limit set limit
func (s *GetFlexibleLoanBorrowHistoryService) Limit(limit int64) *GetFlexibleLoanBorrowHistoryService {
s.limit = &limit
return s
}
// StartTime set startTime
func (s *GetFlexibleLoanBorrowHistoryService) StartTime(startTime int64) *GetFlexibleLoanBorrowHistoryService {
s.startTime = &startTime
return s
}
// EndTime set endTime
func (s *GetFlexibleLoanBorrowHistoryService) EndTime(endTime int64) *GetFlexibleLoanBorrowHistoryService {
s.endTime = &endTime
return s
}
// Do send request
func (s *GetFlexibleLoanBorrowHistoryService) Do(ctx context.Context, opts ...RequestOption) (res *GetFlexibleLoanBorrowHistoryResp, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/sapi/v2/loan/flexible/borrow/history",
secType: secTypeSigned,
}
if s.loanCoin != nil {
r.setParam("loanCoin", *s.loanCoin)
}
if s.collateralCoin != nil {
r.setParam("collateralCoin", *s.collateralCoin)
}
if s.current != nil {
r.setParam("current", *s.current)
}
if s.limit != nil {
r.setParam("limit", *s.limit)
}
if s.startTime != nil {
r.setParam("startTime", *s.startTime)
}
if s.endTime != nil {
r.setParam("endTime", *s.endTime)
}
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
}
res = new(GetFlexibleLoanBorrowHistoryResp)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}