make currency parameter optional

This commit is contained in:
c9s 2020-10-12 17:15:13 +08:00
parent 931ce434ef
commit 92a5eac412
2 changed files with 14 additions and 6 deletions

View File

@ -99,8 +99,12 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
}
log.Infof("querying withdraw %s: %s <=> %s", asset, startTime, endTime)
withdraws, err := e.client.AccountService.NewGetWithdrawalHistoryRequest().
Currency(toLocalCurrency(asset)).
req := e.client.AccountService.NewGetWithdrawalHistoryRequest()
if len(asset) > 0 {
req.Currency(toLocalCurrency(asset))
}
withdraws, err := req.
From(startTime.Unix()).
To(endTime.Unix()).
Do(ctx)
@ -165,8 +169,12 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
}
log.Infof("querying deposit history %s: %s <=> %s", asset, startTime, endTime)
deposits, err := e.client.AccountService.NewGetDepositHistoryRequest().
Currency(toLocalCurrency(asset)).
req := e.client.AccountService.NewGetDepositHistoryRequest()
if len(asset) > 0 {
req.Currency(toLocalCurrency(asset))
}
deposits, err := req.
From(startTime.Unix()).
To(endTime.Unix()).Do(ctx)

View File

@ -126,7 +126,7 @@ type Deposit struct {
type GetDepositHistoryRequestParams struct {
*PrivateRequestParams
Currency string `json:"currency"`
Currency string `json:"currency,omitempty"`
From int64 `json:"from,omitempty"` // seconds
To int64 `json:"to,omitempty"` // seconds
State string `json:"state,omitempty"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
@ -212,7 +212,7 @@ type Withdraw struct {
type GetWithdrawHistoryRequestParams struct {
*PrivateRequestParams
Currency string `json:"currency"`
Currency string `json:"currency,omitempty"`
From int64 `json:"from,omitempty"` // seconds
To int64 `json:"to,omitempty"` // seconds
State string `json:"state,omitempty"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect