kucoin: remove New prefix from the requests

This commit is contained in:
c9s 2021-12-31 01:36:21 +08:00
parent 8aef3c002a
commit b91bf10a7c
4 changed files with 61 additions and 61 deletions

View File

@ -16,17 +16,17 @@ type AccountService struct {
}
func (s *AccountService) ListSubAccounts(ctx context.Context) ([]SubAccount, error) {
req := &NewListSubAccountsRequest{client: s.client}
req := &ListSubAccountsRequest{client: s.client}
return req.Do(ctx)
}
func (s *AccountService) ListAccounts(ctx context.Context) ([]Account, error) {
req := &NewListAccountsRequest{client: s.client}
req := &ListAccountsRequest{client: s.client}
return req.Do(ctx)
}
func (s *AccountService) GetAccount(ctx context.Context, accountID string) (*Account, error) {
req := &NewGetAccountRequest{client: s.client, accountID: accountID}
req := &GetAccountRequest{client: s.client, accountID: accountID}
return req.Do(ctx)
}
@ -37,8 +37,8 @@ type SubAccount struct {
Remark string `json:"remarks"`
}
//go:generate GetRequest -url "/api/v1/sub/user" -type NewListSubAccountsRequest -responseDataType []SubAccount
type NewListSubAccountsRequest struct {
//go:generate GetRequest -url "/api/v1/sub/user" -type ListSubAccountsRequest -responseDataType []SubAccount
type ListSubAccountsRequest struct {
client requestgen.AuthenticatedAPIClient
}
@ -51,13 +51,13 @@ type Account struct {
Holds fixedpoint.Value `json:"holds"`
}
//go:generate GetRequest -url "/api/v1/accounts" -type NewListAccountsRequest -responseDataType []Account
type NewListAccountsRequest struct {
//go:generate GetRequest -url "/api/v1/accounts" -type ListAccountsRequest -responseDataType []Account
type ListAccountsRequest struct {
client requestgen.AuthenticatedAPIClient
}
//go:generate GetRequest -url "/api/v1/accounts/:accountID" -type NewGetAccountRequest -responseDataType .Account
type NewGetAccountRequest struct {
//go:generate GetRequest -url "/api/v1/accounts/:accountID" -type GetAccountRequest -responseDataType .Account
type GetAccountRequest struct {
client requestgen.AuthenticatedAPIClient
accountID string `param:"accountID,slug"`
}

View File

@ -1,4 +1,4 @@
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Data -url /api/v1/accounts/:accountID -type NewGetAccountRequest -responseDataType .Account"; DO NOT EDIT.
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Data -url /api/v1/accounts/:accountID -type GetAccountRequest -responseDataType .Account"; DO NOT EDIT.
package kucoinapi
@ -10,13 +10,13 @@ import (
"regexp"
)
func (n *NewGetAccountRequest) AccountID(accountID string) *NewGetAccountRequest {
n.accountID = accountID
return n
func (g *GetAccountRequest) AccountID(accountID string) *GetAccountRequest {
g.accountID = accountID
return g
}
// GetQueryParameters builds and checks the query parameters and returns url.Values
func (n *NewGetAccountRequest) GetQueryParameters() (url.Values, error) {
func (g *GetAccountRequest) GetQueryParameters() (url.Values, error) {
var params = map[string]interface{}{}
query := url.Values{}
@ -28,17 +28,17 @@ func (n *NewGetAccountRequest) GetQueryParameters() (url.Values, error) {
}
// GetParameters builds and checks the parameters and return the result in a map object
func (n *NewGetAccountRequest) GetParameters() (map[string]interface{}, error) {
func (g *GetAccountRequest) GetParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
func (n *NewGetAccountRequest) GetParametersQuery() (url.Values, error) {
func (g *GetAccountRequest) GetParametersQuery() (url.Values, error) {
query := url.Values{}
params, err := n.GetParameters()
params, err := g.GetParameters()
if err != nil {
return query, err
}
@ -51,8 +51,8 @@ func (n *NewGetAccountRequest) GetParametersQuery() (url.Values, error) {
}
// GetParametersJSON converts the parameters from GetParameters into the JSON format
func (n *NewGetAccountRequest) GetParametersJSON() ([]byte, error) {
params, err := n.GetParameters()
func (g *GetAccountRequest) GetParametersJSON() ([]byte, error) {
params, err := g.GetParameters()
if err != nil {
return nil, err
}
@ -61,10 +61,10 @@ func (n *NewGetAccountRequest) GetParametersJSON() ([]byte, error) {
}
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
func (n *NewGetAccountRequest) GetSlugParameters() (map[string]interface{}, error) {
func (g *GetAccountRequest) GetSlugParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
// check accountID field -> json key accountID
accountID := n.accountID
accountID := g.accountID
// assign parameter of accountID
params["accountID"] = accountID
@ -72,7 +72,7 @@ func (n *NewGetAccountRequest) GetSlugParameters() (map[string]interface{}, erro
return params, nil
}
func (n *NewGetAccountRequest) applySlugsToUrl(url string, slugs map[string]string) string {
func (g *GetAccountRequest) applySlugsToUrl(url string, slugs map[string]string) string {
for k, v := range slugs {
needleRE := regexp.MustCompile(":" + k + "\\b")
url = needleRE.ReplaceAllString(url, v)
@ -81,9 +81,9 @@ func (n *NewGetAccountRequest) applySlugsToUrl(url string, slugs map[string]stri
return url
}
func (n *NewGetAccountRequest) GetSlugsMap() (map[string]string, error) {
func (g *GetAccountRequest) GetSlugsMap() (map[string]string, error) {
slugs := map[string]string{}
params, err := n.GetSlugParameters()
params, err := g.GetSlugParameters()
if err != nil {
return slugs, nil
}
@ -95,26 +95,26 @@ func (n *NewGetAccountRequest) GetSlugsMap() (map[string]string, error) {
return slugs, nil
}
func (n *NewGetAccountRequest) Do(ctx context.Context) (*Account, error) {
func (g *GetAccountRequest) Do(ctx context.Context) (*Account, error) {
// no body params
var params interface{}
query := url.Values{}
apiURL := "/api/v1/accounts/:accountID"
slugs, err := n.GetSlugsMap()
slugs, err := g.GetSlugsMap()
if err != nil {
return nil, err
}
apiURL = n.applySlugsToUrl(apiURL, slugs)
apiURL = g.applySlugsToUrl(apiURL, slugs)
req, err := n.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
req, err := g.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
if err != nil {
return nil, err
}
response, err := n.client.SendRequest(req)
response, err := g.client.SendRequest(req)
if err != nil {
return nil, err
}

View File

@ -1,4 +1,4 @@
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Data -url /api/v1/sub/user -type NewListSubAccountsRequest -responseDataType []SubAccount"; DO NOT EDIT.
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Data -url /api/v1/accounts -type ListAccountsRequest -responseDataType []Account"; DO NOT EDIT.
package kucoinapi
@ -11,7 +11,7 @@ import (
)
// GetQueryParameters builds and checks the query parameters and returns url.Values
func (n *NewListSubAccountsRequest) GetQueryParameters() (url.Values, error) {
func (l *ListAccountsRequest) GetQueryParameters() (url.Values, error) {
var params = map[string]interface{}{}
query := url.Values{}
@ -23,17 +23,17 @@ func (n *NewListSubAccountsRequest) GetQueryParameters() (url.Values, error) {
}
// GetParameters builds and checks the parameters and return the result in a map object
func (n *NewListSubAccountsRequest) GetParameters() (map[string]interface{}, error) {
func (l *ListAccountsRequest) GetParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
func (n *NewListSubAccountsRequest) GetParametersQuery() (url.Values, error) {
func (l *ListAccountsRequest) GetParametersQuery() (url.Values, error) {
query := url.Values{}
params, err := n.GetParameters()
params, err := l.GetParameters()
if err != nil {
return query, err
}
@ -46,8 +46,8 @@ func (n *NewListSubAccountsRequest) GetParametersQuery() (url.Values, error) {
}
// GetParametersJSON converts the parameters from GetParameters into the JSON format
func (n *NewListSubAccountsRequest) GetParametersJSON() ([]byte, error) {
params, err := n.GetParameters()
func (l *ListAccountsRequest) GetParametersJSON() ([]byte, error) {
params, err := l.GetParameters()
if err != nil {
return nil, err
}
@ -56,13 +56,13 @@ func (n *NewListSubAccountsRequest) GetParametersJSON() ([]byte, error) {
}
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
func (n *NewListSubAccountsRequest) GetSlugParameters() (map[string]interface{}, error) {
func (l *ListAccountsRequest) GetSlugParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
func (n *NewListSubAccountsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
func (l *ListAccountsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
for k, v := range slugs {
needleRE := regexp.MustCompile(":" + k + "\\b")
url = needleRE.ReplaceAllString(url, v)
@ -71,9 +71,9 @@ func (n *NewListSubAccountsRequest) applySlugsToUrl(url string, slugs map[string
return url
}
func (n *NewListSubAccountsRequest) GetSlugsMap() (map[string]string, error) {
func (l *ListAccountsRequest) GetSlugsMap() (map[string]string, error) {
slugs := map[string]string{}
params, err := n.GetSlugParameters()
params, err := l.GetSlugParameters()
if err != nil {
return slugs, nil
}
@ -85,20 +85,20 @@ func (n *NewListSubAccountsRequest) GetSlugsMap() (map[string]string, error) {
return slugs, nil
}
func (n *NewListSubAccountsRequest) Do(ctx context.Context) ([]SubAccount, error) {
func (l *ListAccountsRequest) Do(ctx context.Context) ([]Account, error) {
// no body params
var params interface{}
query := url.Values{}
apiURL := "/api/v1/sub/user"
apiURL := "/api/v1/accounts"
req, err := n.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
req, err := l.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
if err != nil {
return nil, err
}
response, err := n.client.SendRequest(req)
response, err := l.client.SendRequest(req)
if err != nil {
return nil, err
}
@ -107,7 +107,7 @@ func (n *NewListSubAccountsRequest) Do(ctx context.Context) ([]SubAccount, error
if err := response.DecodeJSON(&apiResponse); err != nil {
return nil, err
}
var data []SubAccount
var data []Account
if err := json.Unmarshal(apiResponse.Data, &data); err != nil {
return nil, err
}

View File

@ -1,4 +1,4 @@
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Data -url /api/v1/accounts -type NewListAccountsRequest -responseDataType []Account"; DO NOT EDIT.
// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Data -url /api/v1/sub/user -type ListSubAccountsRequest -responseDataType []SubAccount"; DO NOT EDIT.
package kucoinapi
@ -11,7 +11,7 @@ import (
)
// GetQueryParameters builds and checks the query parameters and returns url.Values
func (n *NewListAccountsRequest) GetQueryParameters() (url.Values, error) {
func (l *ListSubAccountsRequest) GetQueryParameters() (url.Values, error) {
var params = map[string]interface{}{}
query := url.Values{}
@ -23,17 +23,17 @@ func (n *NewListAccountsRequest) GetQueryParameters() (url.Values, error) {
}
// GetParameters builds and checks the parameters and return the result in a map object
func (n *NewListAccountsRequest) GetParameters() (map[string]interface{}, error) {
func (l *ListSubAccountsRequest) GetParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
func (n *NewListAccountsRequest) GetParametersQuery() (url.Values, error) {
func (l *ListSubAccountsRequest) GetParametersQuery() (url.Values, error) {
query := url.Values{}
params, err := n.GetParameters()
params, err := l.GetParameters()
if err != nil {
return query, err
}
@ -46,8 +46,8 @@ func (n *NewListAccountsRequest) GetParametersQuery() (url.Values, error) {
}
// GetParametersJSON converts the parameters from GetParameters into the JSON format
func (n *NewListAccountsRequest) GetParametersJSON() ([]byte, error) {
params, err := n.GetParameters()
func (l *ListSubAccountsRequest) GetParametersJSON() ([]byte, error) {
params, err := l.GetParameters()
if err != nil {
return nil, err
}
@ -56,13 +56,13 @@ func (n *NewListAccountsRequest) GetParametersJSON() ([]byte, error) {
}
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
func (n *NewListAccountsRequest) GetSlugParameters() (map[string]interface{}, error) {
func (l *ListSubAccountsRequest) GetSlugParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
func (n *NewListAccountsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
func (l *ListSubAccountsRequest) applySlugsToUrl(url string, slugs map[string]string) string {
for k, v := range slugs {
needleRE := regexp.MustCompile(":" + k + "\\b")
url = needleRE.ReplaceAllString(url, v)
@ -71,9 +71,9 @@ func (n *NewListAccountsRequest) applySlugsToUrl(url string, slugs map[string]st
return url
}
func (n *NewListAccountsRequest) GetSlugsMap() (map[string]string, error) {
func (l *ListSubAccountsRequest) GetSlugsMap() (map[string]string, error) {
slugs := map[string]string{}
params, err := n.GetSlugParameters()
params, err := l.GetSlugParameters()
if err != nil {
return slugs, nil
}
@ -85,20 +85,20 @@ func (n *NewListAccountsRequest) GetSlugsMap() (map[string]string, error) {
return slugs, nil
}
func (n *NewListAccountsRequest) Do(ctx context.Context) ([]Account, error) {
func (l *ListSubAccountsRequest) Do(ctx context.Context) ([]SubAccount, error) {
// no body params
var params interface{}
query := url.Values{}
apiURL := "/api/v1/accounts"
apiURL := "/api/v1/sub/user"
req, err := n.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
req, err := l.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
if err != nil {
return nil, err
}
response, err := n.client.SendRequest(req)
response, err := l.client.SendRequest(req)
if err != nil {
return nil, err
}
@ -107,7 +107,7 @@ func (n *NewListAccountsRequest) Do(ctx context.Context) ([]Account, error) {
if err := response.DecodeJSON(&apiResponse); err != nil {
return nil, err
}
var data []Account
var data []SubAccount
if err := json.Unmarshal(apiResponse.Data, &data); err != nil {
return nil, err
}