maxapi: move some methods to the rest client level

This commit is contained in:
c9s 2023-04-11 18:33:51 +08:00
parent 4766f6c203
commit 51c1d47fbc
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 8 additions and 8 deletions

View File

@ -551,7 +551,7 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
return nil, err
}
vipLevel, err := e.client.AccountService.NewGetVipLevelRequest().Do(ctx)
vipLevel, err := e.client.NewGetVipLevelRequest().Do(ctx)
if err != nil {
return nil, err
}

View File

@ -79,8 +79,8 @@ type GetVipLevelRequest struct {
client requestgen.AuthenticatedAPIClient
}
func (s *AccountService) NewGetVipLevelRequest() *GetVipLevelRequest {
return &GetVipLevelRequest{client: s.client}
func (c *RestClient) NewGetVipLevelRequest() *GetVipLevelRequest {
return &GetVipLevelRequest{client: c}
}
//go:generate GetRequest -url "v2/members/accounts/:currency" -type GetAccountRequest -responseType .Account
@ -90,8 +90,8 @@ type GetAccountRequest struct {
currency string `param:"currency,slug"`
}
func (s *AccountService) NewGetAccountRequest() *GetAccountRequest {
return &GetAccountRequest{client: s.client}
func (c *RestClient) NewGetAccountRequest() *GetAccountRequest {
return &GetAccountRequest{client: c}
}
//go:generate GetRequest -url "v2/members/accounts" -type GetAccountsRequest -responseType []Account

View File

@ -38,14 +38,14 @@ func TestAccountService_GetAccountRequest(t *testing.T) {
client := NewRestClient(ProductionAPIURL)
client.Auth(key, secret)
req := client.AccountService.NewGetAccountRequest()
req := client.NewGetAccountRequest()
req.Currency("twd")
account, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, account)
t.Logf("account: %+v", account)
req2 := client.AccountService.NewGetAccountRequest()
req2 := client.NewGetAccountRequest()
req2.Currency("usdt")
account, err = req.Do(ctx)
assert.NoError(t, err)
@ -64,7 +64,7 @@ func TestAccountService_GetVipLevelRequest(t *testing.T) {
client := NewRestClient(ProductionAPIURL)
client.Auth(key, secret)
req := client.AccountService.NewGetVipLevelRequest()
req := client.NewGetVipLevelRequest()
vipLevel, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, vipLevel)