Merge pull request #1694 from c9s/c9s/max/fix-withdrawal-query-api

FIX: [max] fix max withdrawal api parameters
This commit is contained in:
c9s 2024-08-16 13:39:47 +08:00 committed by GitHub
commit 7488a1069f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 23 deletions

View File

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

View File

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

View File

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