max: fix max withdrawal api parameters

This commit is contained in:
c9s 2024-08-16 13:27:14 +08:00
parent a91685920e
commit 4154cc9d53
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 25 additions and 23 deletions

View File

@ -845,8 +845,7 @@ func (e *Exchange) QueryWithdrawHistory(
}
withdraws, err := req.
From(startTime).
To(endTime).
Timestamp(startTime).
Limit(limit).
Do(ctx)

View File

@ -207,8 +207,12 @@ type GetWithdrawHistoryRequest struct {
currency *string `param:"currency"`
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
from *time.Time `param:"from,seconds"` // seconds
to *time.Time `param:"to,seconds"` // seconds
timestamp *time.Time `param:"timestamp,milliseconds"` // milli-seconds
// order could be desc or asc
order *string `param:"order"`
// limit's default = 50
limit *int `param:"limit"`
}

View File

@ -23,13 +23,13 @@ func (g *GetWithdrawHistoryRequest) State(state string) *GetWithdrawHistoryReque
return g
}
func (g *GetWithdrawHistoryRequest) From(from time.Time) *GetWithdrawHistoryRequest {
g.from = &from
func (g *GetWithdrawHistoryRequest) Timestamp(timestamp time.Time) *GetWithdrawHistoryRequest {
g.timestamp = &timestamp
return g
}
func (g *GetWithdrawHistoryRequest) To(to time.Time) *GetWithdrawHistoryRequest {
g.to = &to
func (g *GetWithdrawHistoryRequest) Order(order string) *GetWithdrawHistoryRequest {
g.order = &order
return g
}
@ -69,22 +69,21 @@ func (g *GetWithdrawHistoryRequest) GetParameters() (map[string]interface{}, err
params["state"] = state
} else {
}
// check from field -> json key from
if g.from != nil {
from := *g.from
// check timestamp field -> json key timestamp
if g.timestamp != nil {
timestamp := *g.timestamp
// assign parameter of from
// convert time.Time to seconds time stamp
params["from"] = strconv.FormatInt(from.Unix(), 10)
// assign parameter of timestamp
// convert time.Time to milliseconds time stamp
params["timestamp"] = strconv.FormatInt(timestamp.UnixNano()/int64(time.Millisecond), 10)
} else {
}
// check to field -> json key to
if g.to != nil {
to := *g.to
// check order field -> json key order
if g.order != nil {
order := *g.order
// assign parameter of to
// convert time.Time to seconds time stamp
params["to"] = strconv.FormatInt(to.Unix(), 10)
// assign parameter of order
params["order"] = order
} else {
}
// check limit field -> json key limit