Skip to content

Commit

Permalink
Upgrade ListDepositService to sapi
Browse files Browse the repository at this point in the history
  • Loading branch information
kislikjeka committed Jun 10, 2021
1 parent 314ce9f commit 8be4536
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions v2/deposit_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ package binance
import (
"context"
"encoding/json"
"net/http"
)

// ListDepositsService fetches deposit history.
//
// See https://binance-docs.github.io/apidocs/spot/en/#deposit-history-user_data
type ListDepositsService struct {
c *Client
asset *string
coin *string
status *int
startTime *int64
endTime *int64
offset *int
limit *int
}

// Asset sets the asset parameter.
func (s *ListDepositsService) Asset(asset string) *ListDepositsService {
s.asset = &asset
// Coin sets the coin parameter.
func (s *ListDepositsService) Coin(coin string) *ListDepositsService {
s.coin = &coin
return s
}

Expand All @@ -42,15 +45,27 @@ func (s *ListDepositsService) EndTime(endTime int64) *ListDepositsService {
return s
}

// Offset sets the offset parameter
func (s *ListDepositsService) Offset(offset int) *ListDepositsService {
s.offset = &offset
return s
}

// Limit sets the limit parameter
func (s *ListDepositsService) Limit(limit int) *ListDepositsService {
s.limit = &limit
return s
}

// Do sends the request.
func (s *ListDepositsService) Do(ctx context.Context) (deposits []*Deposit, err error) {
r := &request{
method: "GET",
endpoint: "/wapi/v3/depositHistory.html",
method: http.MethodGet,
endpoint: "/sapi/v1/capital/deposit/hisrec",
secType: secTypeSigned,
}
if s.asset != nil {
r.setParam("asset", *s.asset)
if s.coin != nil {
r.setParam("coin", *s.coin)
}
if s.status != nil {
r.setParam("status", *s.status)
Expand All @@ -61,6 +76,12 @@ func (s *ListDepositsService) Do(ctx context.Context) (deposits []*Deposit, err
if s.endTime != nil {
r.setParam("endTime", *s.endTime)
}
if s.limit != nil {
r.setParam("limit", *s.limit)
}
if s.offset != nil {
r.setParam("offset", *s.offset)
}

data, err := s.c.callAPI(ctx, r)
if err != nil {
Expand Down

0 comments on commit 8be4536

Please sign in to comment.