Skip to content

Commit

Permalink
Add GetFlexibleLoanRepayHistoryService
Browse files Browse the repository at this point in the history
  • Loading branch information
Haiss2 committed Oct 24, 2023
1 parent c3d66ff commit 143c7c4
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
4 changes: 4 additions & 0 deletions v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,3 +1058,7 @@ func (c *Client) NewFlexibleLoanAdjustLTVService() *FlexibleLoanAdjustLTVService
func (c *Client) NewGetFlexibleLoanBorrowHistoryService() *GetFlexibleLoanBorrowHistoryService {
return &GetFlexibleLoanBorrowHistoryService{c: c}
}

func (c *Client) NewGetFlexibleLoanRepayHistoryService() *GetFlexibleLoanRepayHistoryService {
return &GetFlexibleLoanRepayHistoryService{c: c}
}
File renamed without changes.
111 changes: 111 additions & 0 deletions v2/get_flexible_loan_repay_history.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package binance

import (
"context"
"net/http"
)

type GetFlexibleLoanRepayHistoryService struct {
c *Client
loanCoin *string
collateralCoin *string
startTime *int64
endTime *int64
current *int64
limit *int64
}

type GetFlexibleLoanRepayHistoryResp struct {
Rows []FlexibleLoanRepayHistory `json:"rows"`
Total int64 `json:"total"`
}

type FlexibleLoanRepayHistory struct {
LoanCoin string `json:"loanCoin"`
RepayAmount string `json:"repayAmount"`
CollateralCoin string `json:"collateralCoin"`
CollateralReturn string `json:"collateralReturn"`
RepayTime interface{} `json:"repayTime"`
RepayStatus FlexibleLoanRepayStatus `json:"repayStatus"`
}

// LoanCoin set loanCoin
func (s *GetFlexibleLoanRepayHistoryService) LoanCoin(loanCoin string) *GetFlexibleLoanRepayHistoryService {
s.loanCoin = &loanCoin
return s
}

// CollateralCoin set collateralCoin
func (s *GetFlexibleLoanRepayHistoryService) CollateralCoin(coll string) *GetFlexibleLoanRepayHistoryService {
s.collateralCoin = &coll
return s
}

// Current set current
func (s *GetFlexibleLoanRepayHistoryService) Current(current int64) *GetFlexibleLoanRepayHistoryService {
s.current = &current
return s
}

// Limit set limit
func (s *GetFlexibleLoanRepayHistoryService) Limit(limit int64) *GetFlexibleLoanRepayHistoryService {
s.limit = &limit
return s
}

// StartTime set startTime
func (s *GetFlexibleLoanRepayHistoryService) StartTime(startTime int64) *GetFlexibleLoanRepayHistoryService {
s.startTime = &startTime
return s
}

// EndTime set endTime
func (s *GetFlexibleLoanRepayHistoryService) EndTime(endTime int64) *GetFlexibleLoanRepayHistoryService {
s.endTime = &endTime
return s
}

// Do send request
func (s *GetFlexibleLoanRepayHistoryService) Do(ctx context.Context, opts ...RequestOption) (res *GetFlexibleLoanRepayHistoryResp, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/sapi/v1/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(GetFlexibleLoanRepayHistoryResp)
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}

0 comments on commit 143c7c4

Please sign in to comment.