From b88aff6d73ff33b086f97cf6d74aa59cd23fde8d Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 16 Aug 2024 13:40:26 +0800 Subject: [PATCH] max: fix GetDepositHistoryRequest --- pkg/exchange/max/exchange.go | 5 +- pkg/exchange/max/maxapi/account.go | 14 +++--- .../get_deposit_history_request_requestgen.go | 47 +++++++++---------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/pkg/exchange/max/exchange.go b/pkg/exchange/max/exchange.go index 364329ba0..a7bd7e79a 100644 --- a/pkg/exchange/max/exchange.go +++ b/pkg/exchange/max/exchange.go @@ -846,6 +846,7 @@ func (e *Exchange) QueryWithdrawHistory( withdraws, err := req. Timestamp(startTime). + Order("asc"). Limit(limit). Do(ctx) @@ -927,8 +928,8 @@ func (e *Exchange) QueryDepositHistory( } deposits, err := req. - From(startTime). - To(endTime). + Timestamp(startTime). + Order("asc"). Limit(limit). Do(ctx) diff --git a/pkg/exchange/max/maxapi/account.go b/pkg/exchange/max/maxapi/account.go index 2e1e38f82..a363a0449 100644 --- a/pkg/exchange/max/maxapi/account.go +++ b/pkg/exchange/max/maxapi/account.go @@ -133,15 +133,17 @@ type Deposit struct { UpdatedAt types.MillisecondTimestamp `json:"updated_at"` } -//go:generate GetRequest -url "v2/deposits" -type GetDepositHistoryRequest -responseType []Deposit +//go:generate GetRequest -url "v3/deposits" -type GetDepositHistoryRequest -responseType []Deposit type GetDepositHistoryRequest struct { client requestgen.AuthenticatedAPIClient - currency *string `param:"currency"` - from *time.Time `param:"from,seconds"` // seconds - to *time.Time `param:"to,seconds"` // seconds - state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect - limit *int `param:"limit"` + currency *string `param:"currency"` + timestamp *time.Time `param:"timestamp,milliseconds"` // seconds + state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect + + order *string `param:"order"` + + limit *int `param:"limit"` } func (c *RestClient) NewGetDepositHistoryRequest() *GetDepositHistoryRequest { diff --git a/pkg/exchange/max/maxapi/get_deposit_history_request_requestgen.go b/pkg/exchange/max/maxapi/get_deposit_history_request_requestgen.go index 8d80303f5..379d377c5 100644 --- a/pkg/exchange/max/maxapi/get_deposit_history_request_requestgen.go +++ b/pkg/exchange/max/maxapi/get_deposit_history_request_requestgen.go @@ -1,4 +1,4 @@ -// Code generated by "requestgen -method GET -url v2/deposits -type GetDepositHistoryRequest -responseType []Deposit"; DO NOT EDIT. +// Code generated by "requestgen -method GET -url v3/deposits -type GetDepositHistoryRequest -responseType []Deposit"; DO NOT EDIT. package max @@ -18,13 +18,8 @@ func (g *GetDepositHistoryRequest) Currency(currency string) *GetDepositHistoryR return g } -func (g *GetDepositHistoryRequest) From(from time.Time) *GetDepositHistoryRequest { - g.from = &from - return g -} - -func (g *GetDepositHistoryRequest) To(to time.Time) *GetDepositHistoryRequest { - g.to = &to +func (g *GetDepositHistoryRequest) Timestamp(timestamp time.Time) *GetDepositHistoryRequest { + g.timestamp = ×tamp return g } @@ -33,6 +28,11 @@ func (g *GetDepositHistoryRequest) State(state string) *GetDepositHistoryRequest return g } +func (g *GetDepositHistoryRequest) Order(order string) *GetDepositHistoryRequest { + g.order = &order + return g +} + func (g *GetDepositHistoryRequest) Limit(limit int) *GetDepositHistoryRequest { g.limit = &limit return g @@ -61,22 +61,13 @@ func (g *GetDepositHistoryRequest) GetParameters() (map[string]interface{}, erro params["currency"] = currency } 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) - } else { - } - // check to field -> json key to - if g.to != nil { - to := *g.to - - // assign parameter of to - // convert time.Time to seconds time stamp - params["to"] = strconv.FormatInt(to.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 state field -> json key state @@ -87,6 +78,14 @@ func (g *GetDepositHistoryRequest) GetParameters() (map[string]interface{}, erro params["state"] = state } else { } + // check order field -> json key order + if g.order != nil { + order := *g.order + + // assign parameter of order + params["order"] = order + } else { + } // check limit field -> json key limit if g.limit != nil { limit := *g.limit @@ -180,7 +179,7 @@ func (g *GetDepositHistoryRequest) GetSlugsMap() (map[string]string, error) { // GetPath returns the request path of the API func (g *GetDepositHistoryRequest) GetPath() string { - return "v2/deposits" + return "v3/deposits" } // Do generates the request object and send the request object to the API endpoint