forked from adshao/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lending_interest_service.go
106 lines (96 loc) · 2.72 KB
/
lending_interest_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
package binance
import (
"context"
"encoding/json"
)
// ListLendingInterestService fetches the saving purchases
type ListLendingInterestService struct {
c *Client
lendingType *string
asset *string
startTime *int64
endTime *int64
size *int
current *int
}
// Asset sets the asset parameter.
func (s *ListLendingInterestService) Asset(asset string) *ListLendingInterestService {
s.asset = &asset
return s
}
// Size sets the size parameter.
func (s *ListLendingInterestService) Size(size int) *ListLendingInterestService {
s.size = &size
return s
}
// Current set the currently querying page. Start from 1. Default:1
func (s *ListLendingInterestService) Current(current int) *ListLendingInterestService {
s.current = ¤t
return s
}
// LendingType sets the lendingType parameter.
func (s *ListLendingInterestService) LendingType(lendingType string) *ListLendingInterestService {
s.lendingType = &lendingType
return s
}
// StartTime sets the startTime parameter.
// If present, EndTime MUST be specified. The difference between EndTime - StartTime MUST be between 0-90 days.
func (s *ListLendingInterestService) StartTime(startTime int64) *ListLendingInterestService {
s.startTime = &startTime
return s
}
// EndTime sets the endTime parameter.
// If present, StartTime MUST be specified. The difference between EndTime - StartTime MUST be between 0-90 days.
func (s *ListLendingInterestService) EndTime(endTime int64) *ListLendingInterestService {
s.endTime = &endTime
return s
}
// Do sends the request.
func (s *ListLendingInterestService) Do(ctx context.Context) (*[]LendingInterestResponse, error) {
r := &request{
method: "GET",
endpoint: "/sapi/v1/lending/union/interestHistory",
secType: secTypeSigned,
}
if s.asset != nil {
r.setParam("asset", *s.asset)
}
if s.current != nil {
r.setParam("current", *s.current)
}
if s.size != nil {
r.setParam("size", *s.size)
} else {
r.setParam("size", 100)
}
if s.lendingType != nil {
r.setParam("lendingType", *s.lendingType)
} else {
r.setParam("lendingType", `DAILY`)
}
if s.startTime != nil {
r.setParam("startTime", *s.startTime)
}
if s.endTime != nil {
r.setParam("endTime", *s.endTime)
}
r.setParam("recvWindow", 60000)
data, err := s.c.callAPI(ctx, r)
if err != nil {
return nil, err
}
res := new([]LendingInterestResponse)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}
// LendingInterestResponse represents a response from ListLendingInterestService.
type LendingInterestResponse struct {
Time int64 `json:"time"`
Asset string `json:"asset"`
ProductName string `json:"productName"`
Interest string `json:"interest"`
LendingType string `json:"lendingType"`
}