mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
maxapi: add currency field to the accounts api
This commit is contained in:
parent
40f6295d91
commit
1ca81e11e6
|
@ -6,13 +6,14 @@ import "github.com/c9s/requestgen"
|
|||
//go:generate -command PostRequest requestgen -method POST
|
||||
//go:generate -command DeleteRequest requestgen -method DELETE
|
||||
|
||||
func (s *Client) NewGetWalletAccountsRequest(walletType WalletType) *GetWalletAccountsRequest {
|
||||
return &GetWalletAccountsRequest{client: s.Client, walletType: walletType}
|
||||
}
|
||||
|
||||
//go:generate GetRequest -url "/api/v3/wallet/:walletType/accounts" -type GetWalletAccountsRequest -responseType []Account
|
||||
type GetWalletAccountsRequest struct {
|
||||
client requestgen.AuthenticatedAPIClient
|
||||
|
||||
walletType WalletType `param:"walletType,slug,required"`
|
||||
currency string `param:"currency"`
|
||||
}
|
||||
|
||||
func (s *Client) NewGetWalletAccountsRequest(walletType WalletType) *GetWalletAccountsRequest {
|
||||
return &GetWalletAccountsRequest{client: s.Client, walletType: walletType}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,11 @@ import (
|
|||
"regexp"
|
||||
)
|
||||
|
||||
func (g *GetWalletAccountsRequest) Currency(currency string) *GetWalletAccountsRequest {
|
||||
g.currency = currency
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetWalletAccountsRequest) WalletType(walletType max.WalletType) *GetWalletAccountsRequest {
|
||||
g.walletType = walletType
|
||||
return g
|
||||
|
@ -32,6 +37,11 @@ func (g *GetWalletAccountsRequest) GetQueryParameters() (url.Values, error) {
|
|||
// GetParameters builds and checks the parameters and return the result in a map object
|
||||
func (g *GetWalletAccountsRequest) GetParameters() (map[string]interface{}, error) {
|
||||
var params = map[string]interface{}{}
|
||||
// check currency field -> json key currency
|
||||
currency := g.currency
|
||||
|
||||
// assign parameter of currency
|
||||
params["currency"] = currency
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
@ -128,9 +138,12 @@ func (g *GetWalletAccountsRequest) GetSlugsMap() (map[string]string, error) {
|
|||
|
||||
func (g *GetWalletAccountsRequest) Do(ctx context.Context) ([]max.Account, error) {
|
||||
|
||||
// no body params
|
||||
// empty params for GET operation
|
||||
var params interface{}
|
||||
query := url.Values{}
|
||||
query, err := g.GetParametersQuery()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
apiURL := "/api/v3/wallet/:walletType/accounts"
|
||||
slugs, err := g.GetSlugsMap()
|
||||
|
|
Loading…
Reference in New Issue
Block a user