max: add currency parameter to /api/v3/wallet/:walletType/accounts api

This commit is contained in:
c9s 2023-05-15 20:10:52 +08:00
parent 24ca1b103b
commit 7aa673c673
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 12 additions and 9 deletions

View File

@ -11,7 +11,7 @@ type GetWalletAccountsRequest struct {
client requestgen.AuthenticatedAPIClient
walletType WalletType `param:"walletType,slug,required"`
currency string `param:"currency"`
currency *string `param:"currency,query"`
}
func (s *Client) NewGetWalletAccountsRequest(walletType WalletType) *GetWalletAccountsRequest {

View File

@ -13,7 +13,7 @@ import (
)
func (g *GetWalletAccountsRequest) Currency(currency string) *GetWalletAccountsRequest {
g.currency = currency
g.currency = &currency
return g
}
@ -25,6 +25,14 @@ func (g *GetWalletAccountsRequest) WalletType(walletType max.WalletType) *GetWal
// GetQueryParameters builds and checks the query parameters and returns url.Values
func (g *GetWalletAccountsRequest) GetQueryParameters() (url.Values, error) {
var params = map[string]interface{}{}
// check currency field -> json key currency
if g.currency != nil {
currency := *g.currency
// assign parameter of currency
params["currency"] = currency
} else {
}
query := url.Values{}
for _k, _v := range params {
@ -37,11 +45,6 @@ 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
}
@ -138,9 +141,9 @@ func (g *GetWalletAccountsRequest) GetSlugsMap() (map[string]string, error) {
func (g *GetWalletAccountsRequest) Do(ctx context.Context) ([]max.Account, error) {
// empty params for GET operation
// no body params
var params interface{}
query, err := g.GetParametersQuery()
query, err := g.GetQueryParameters()
if err != nil {
return nil, err
}