mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
maxapi: add deposit request tests and withdrawal request tests
This commit is contained in:
parent
f3eafd5cd8
commit
72ea9f7e24
|
@ -794,7 +794,7 @@ func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since,
|
|||
allDeposits = append(allDeposits, types.Deposit{
|
||||
Exchange: types.ExchangeMax,
|
||||
Time: types.Time(time.Unix(d.CreatedAt, 0)),
|
||||
Amount: fixedpoint.MustNewFromString(d.Amount),
|
||||
Amount: d.Amount,
|
||||
Asset: toGlobalCurrency(d.Currency),
|
||||
Address: "", // not supported
|
||||
AddressTag: "", // not supported
|
||||
|
|
|
@ -113,26 +113,26 @@ func (s *AccountService) NewGetMeRequest() *GetMeRequest {
|
|||
}
|
||||
|
||||
type Deposit struct {
|
||||
Currency string `json:"currency"`
|
||||
CurrencyVersion string `json:"currency_version"` // "eth"
|
||||
Amount string `json:"amount"`
|
||||
Fee string `json:"fee"`
|
||||
TxID string `json:"txid"`
|
||||
State string `json:"state"`
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
Currency string `json:"currency"`
|
||||
CurrencyVersion string `json:"currency_version"` // "eth"
|
||||
Amount fixedpoint.Value `json:"amount"`
|
||||
Fee fixedpoint.Value `json:"fee"`
|
||||
TxID string `json:"txid"`
|
||||
State string `json:"state"`
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
}
|
||||
|
||||
//go:generate GetRequest -url "v2/deposits" -type GetDepositHistoryRequest -responseType []Deposit
|
||||
type GetDepositHistoryRequest struct {
|
||||
client requestgen.AuthenticatedAPIClient
|
||||
|
||||
currency string `param:"currency"`
|
||||
from int64 `param:"from"` // seconds
|
||||
to int64 `param:"to"` // seconds
|
||||
state string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
|
||||
limit int `param:"limit"`
|
||||
currency string `param:"currency"`
|
||||
from *int64 `param:"from"` // seconds
|
||||
to *int64 `param:"to"` // seconds
|
||||
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
|
||||
limit *int `param:"limit"`
|
||||
}
|
||||
|
||||
func (s *AccountService) NewGetDepositHistoryRequest() *GetDepositHistoryRequest {
|
||||
|
|
|
@ -90,3 +90,24 @@ func TestAccountService_GetWithdrawHistoryRequest(t *testing.T) {
|
|||
assert.NotEmpty(t, withdraws)
|
||||
t.Logf("withdraws: %+v", withdraws)
|
||||
}
|
||||
|
||||
func TestAccountService_NewGetDepositHistoryRequest(t *testing.T) {
|
||||
key, secret, ok := integrationTestConfigured(t, "MAX")
|
||||
if !ok {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
client := NewRestClient(ProductionAPIURL)
|
||||
client.Auth(key, secret)
|
||||
|
||||
req := client.AccountService.NewGetDepositHistoryRequest()
|
||||
req.Currency("usdt")
|
||||
deposits, err := req.Do(ctx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, deposits)
|
||||
assert.NotEmpty(t, deposits)
|
||||
t.Logf("deposits: %+v", deposits)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,22 +17,22 @@ func (g *GetDepositHistoryRequest) Currency(currency string) *GetDepositHistoryR
|
|||
}
|
||||
|
||||
func (g *GetDepositHistoryRequest) From(from int64) *GetDepositHistoryRequest {
|
||||
g.from = from
|
||||
g.from = &from
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetDepositHistoryRequest) To(to int64) *GetDepositHistoryRequest {
|
||||
g.to = to
|
||||
g.to = &to
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetDepositHistoryRequest) State(state string) *GetDepositHistoryRequest {
|
||||
g.state = state
|
||||
g.state = &state
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetDepositHistoryRequest) Limit(limit int) *GetDepositHistoryRequest {
|
||||
g.limit = limit
|
||||
g.limit = &limit
|
||||
return g
|
||||
}
|
||||
|
||||
|
@ -57,25 +57,37 @@ func (g *GetDepositHistoryRequest) GetParameters() (map[string]interface{}, erro
|
|||
// assign parameter of currency
|
||||
params["currency"] = currency
|
||||
// check from field -> json key from
|
||||
from := g.from
|
||||
if g.from != nil {
|
||||
from := *g.from
|
||||
|
||||
// assign parameter of from
|
||||
params["from"] = from
|
||||
// assign parameter of from
|
||||
params["from"] = from
|
||||
} else {
|
||||
}
|
||||
// check to field -> json key to
|
||||
to := g.to
|
||||
if g.to != nil {
|
||||
to := *g.to
|
||||
|
||||
// assign parameter of to
|
||||
params["to"] = to
|
||||
// assign parameter of to
|
||||
params["to"] = to
|
||||
} else {
|
||||
}
|
||||
// check state field -> json key state
|
||||
state := g.state
|
||||
if g.state != nil {
|
||||
state := *g.state
|
||||
|
||||
// assign parameter of state
|
||||
params["state"] = state
|
||||
// assign parameter of state
|
||||
params["state"] = state
|
||||
} else {
|
||||
}
|
||||
// check limit field -> json key limit
|
||||
limit := g.limit
|
||||
if g.limit != nil {
|
||||
limit := *g.limit
|
||||
|
||||
// assign parameter of limit
|
||||
params["limit"] = limit
|
||||
// assign parameter of limit
|
||||
params["limit"] = limit
|
||||
} else {
|
||||
}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
|
|
@ -42,8 +42,16 @@ func TestOrderService_GetOrdersRequest(t *testing.T) {
|
|||
// req3.State([]OrderState{OrderStateDone})
|
||||
req3.Market("btcusdt")
|
||||
orders, err := req3.Do(ctx)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, orders)
|
||||
if assert.NoError(t, err) {
|
||||
t.Logf("orders: %+v", orders)
|
||||
|
||||
assert.NotNil(t, orders)
|
||||
if assert.NotEmptyf(t, orders, "got %d orders", len(orders)) {
|
||||
for _, order := range orders {
|
||||
assert.Contains(t, []OrderState{OrderStateDone, OrderStateFinalizing}, order.State)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrderService_GetOrdersRequest_SingleState(t *testing.T) {
|
||||
|
@ -84,7 +92,6 @@ func TestOrderService_GetOrderHistoryRequest(t *testing.T) {
|
|||
assert.NotNil(t, orders)
|
||||
}
|
||||
|
||||
|
||||
func TestOrderService(t *testing.T) {
|
||||
key, secret, ok := integrationTestConfigured(t, "MAX")
|
||||
if !ok {
|
||||
|
|
Loading…
Reference in New Issue
Block a user