Merge pull request #1695 from c9s/c9s/max/fix-deposit-history-query-api

FIX: [max] fix GetDepositHistoryRequest
This commit is contained in:
c9s 2024-08-16 13:53:18 +08:00 committed by GitHub
commit 098de2245c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 32 deletions

View File

@ -846,6 +846,7 @@ func (e *Exchange) QueryWithdrawHistory(
withdraws, err := req. withdraws, err := req.
Timestamp(startTime). Timestamp(startTime).
Order("asc").
Limit(limit). Limit(limit).
Do(ctx) Do(ctx)
@ -927,8 +928,8 @@ func (e *Exchange) QueryDepositHistory(
} }
deposits, err := req. deposits, err := req.
From(startTime). Timestamp(startTime).
To(endTime). Order("asc").
Limit(limit). Limit(limit).
Do(ctx) Do(ctx)

View File

@ -133,15 +133,17 @@ type Deposit struct {
UpdatedAt types.MillisecondTimestamp `json:"updated_at"` 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 { type GetDepositHistoryRequest struct {
client requestgen.AuthenticatedAPIClient client requestgen.AuthenticatedAPIClient
currency *string `param:"currency"` currency *string `param:"currency"`
from *time.Time `param:"from,seconds"` // seconds timestamp *time.Time `param:"timestamp,milliseconds"` // seconds
to *time.Time `param:"to,seconds"` // seconds state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
limit *int `param:"limit"` order *string `param:"order"`
limit *int `param:"limit"`
} }
func (c *RestClient) NewGetDepositHistoryRequest() *GetDepositHistoryRequest { func (c *RestClient) NewGetDepositHistoryRequest() *GetDepositHistoryRequest {

View File

@ -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 package max
@ -18,13 +18,8 @@ func (g *GetDepositHistoryRequest) Currency(currency string) *GetDepositHistoryR
return g return g
} }
func (g *GetDepositHistoryRequest) From(from time.Time) *GetDepositHistoryRequest { func (g *GetDepositHistoryRequest) Timestamp(timestamp time.Time) *GetDepositHistoryRequest {
g.from = &from g.timestamp = &timestamp
return g
}
func (g *GetDepositHistoryRequest) To(to time.Time) *GetDepositHistoryRequest {
g.to = &to
return g return g
} }
@ -33,6 +28,11 @@ func (g *GetDepositHistoryRequest) State(state string) *GetDepositHistoryRequest
return g return g
} }
func (g *GetDepositHistoryRequest) Order(order string) *GetDepositHistoryRequest {
g.order = &order
return g
}
func (g *GetDepositHistoryRequest) Limit(limit int) *GetDepositHistoryRequest { func (g *GetDepositHistoryRequest) Limit(limit int) *GetDepositHistoryRequest {
g.limit = &limit g.limit = &limit
return g return g
@ -61,22 +61,13 @@ func (g *GetDepositHistoryRequest) GetParameters() (map[string]interface{}, erro
params["currency"] = currency params["currency"] = currency
} 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 {
}
// 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)
} else { } else {
} }
// check state field -> json key state // check state field -> json key state
@ -87,6 +78,14 @@ func (g *GetDepositHistoryRequest) GetParameters() (map[string]interface{}, erro
params["state"] = state params["state"] = state
} else { } 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 // check limit field -> json key limit
if g.limit != nil { if g.limit != nil {
limit := *g.limit limit := *g.limit
@ -180,7 +179,7 @@ func (g *GetDepositHistoryRequest) GetSlugsMap() (map[string]string, error) {
// GetPath returns the request path of the API // GetPath returns the request path of the API
func (g *GetDepositHistoryRequest) GetPath() string { 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 // Do generates the request object and send the request object to the API endpoint