112 lines
2.6 KiB
Go
112 lines
2.6 KiB
Go
|
// Code generated by "requestgen -type CancelOrderRequest"; DO NOT EDIT.
|
||
|
|
||
|
package kucoinapi
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"net/url"
|
||
|
"regexp"
|
||
|
)
|
||
|
|
||
|
func (r *CancelOrderRequest) OrderID(orderID string) *CancelOrderRequest {
|
||
|
r.orderID = &orderID
|
||
|
return r
|
||
|
}
|
||
|
|
||
|
func (r *CancelOrderRequest) ClientOrderID(clientOrderID string) *CancelOrderRequest {
|
||
|
r.clientOrderID = &clientOrderID
|
||
|
return r
|
||
|
}
|
||
|
|
||
|
// GetQueryParameters builds and checks the query parameters and returns url.Values
|
||
|
func (r *CancelOrderRequest) GetQueryParameters() (url.Values, error) {
|
||
|
var params = map[string]interface{}{}
|
||
|
|
||
|
query := url.Values{}
|
||
|
for k, v := range params {
|
||
|
query.Add(k, fmt.Sprintf("%v", v))
|
||
|
}
|
||
|
|
||
|
return query, nil
|
||
|
}
|
||
|
|
||
|
// GetParameters builds and checks the parameters and return the result in a map object
|
||
|
func (r *CancelOrderRequest) GetParameters() (map[string]interface{}, error) {
|
||
|
var params = map[string]interface{}{}
|
||
|
// check orderID field -> json key orderID
|
||
|
if r.orderID != nil {
|
||
|
orderID := *r.orderID
|
||
|
|
||
|
// assign parameter of orderID
|
||
|
params["orderID"] = orderID
|
||
|
} else {
|
||
|
}
|
||
|
// check clientOrderID field -> json key clientOrderID
|
||
|
if r.clientOrderID != nil {
|
||
|
clientOrderID := *r.clientOrderID
|
||
|
|
||
|
// assign parameter of clientOrderID
|
||
|
params["clientOrderID"] = clientOrderID
|
||
|
} else {
|
||
|
}
|
||
|
|
||
|
return params, nil
|
||
|
}
|
||
|
|
||
|
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
|
||
|
func (r *CancelOrderRequest) GetParametersQuery() (url.Values, error) {
|
||
|
query := url.Values{}
|
||
|
|
||
|
params, err := r.GetParameters()
|
||
|
if err != nil {
|
||
|
return query, err
|
||
|
}
|
||
|
|
||
|
for k, v := range params {
|
||
|
query.Add(k, fmt.Sprintf("%v", v))
|
||
|
}
|
||
|
|
||
|
return query, nil
|
||
|
}
|
||
|
|
||
|
// GetParametersJSON converts the parameters from GetParameters into the JSON format
|
||
|
func (r *CancelOrderRequest) GetParametersJSON() ([]byte, error) {
|
||
|
params, err := r.GetParameters()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return json.Marshal(params)
|
||
|
}
|
||
|
|
||
|
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
|
||
|
func (r *CancelOrderRequest) GetSlugParameters() (map[string]interface{}, error) {
|
||
|
var params = map[string]interface{}{}
|
||
|
|
||
|
return params, nil
|
||
|
}
|
||
|
|
||
|
func (r *CancelOrderRequest) applySlugsToUrl(url string, slugs map[string]string) string {
|
||
|
for k, v := range slugs {
|
||
|
needleRE := regexp.MustCompile(":" + k + "\\b")
|
||
|
url = needleRE.ReplaceAllString(url, v)
|
||
|
}
|
||
|
|
||
|
return url
|
||
|
}
|
||
|
|
||
|
func (r *CancelOrderRequest) GetSlugsMap() (map[string]string, error) {
|
||
|
slugs := map[string]string{}
|
||
|
params, err := r.GetSlugParameters()
|
||
|
if err != nil {
|
||
|
return slugs, nil
|
||
|
}
|
||
|
|
||
|
for k, v := range params {
|
||
|
slugs[k] = fmt.Sprintf("%v", v)
|
||
|
}
|
||
|
|
||
|
return slugs, nil
|
||
|
}
|