diff --git a/pkg/exchange/kucoin/kucoinapi/cancel_all_order_request_accessors.go b/pkg/exchange/kucoin/kucoinapi/cancel_all_order_request_accessors.go new file mode 100644 index 000000000..5be06ca82 --- /dev/null +++ b/pkg/exchange/kucoin/kucoinapi/cancel_all_order_request_accessors.go @@ -0,0 +1,54 @@ +// Code generated by "requestgen -type CancelAllOrderRequest"; DO NOT EDIT. + +package kucoinapi + +import ( + "fmt" + "net/url" +) + +func (r *CancelAllOrderRequest) Symbol(symbol string) *CancelAllOrderRequest { + r.symbol = &symbol + return r +} + +func (r *CancelAllOrderRequest) TradeType(tradeType string) *CancelAllOrderRequest { + r.tradeType = &tradeType + return r +} + +func (r *CancelAllOrderRequest) getParameters() (map[string]interface{}, error) { + var params = map[string]interface{}{} + + // check symbol field -> json key symbol + if r.symbol != nil { + symbol := *r.symbol + + params["symbol"] = symbol + } else { + } + + // check tradeType field -> json key tradeType + if r.tradeType != nil { + tradeType := *r.tradeType + + params["tradeType"] = tradeType + } else { + } + return params, nil +} + +func (r *CancelAllOrderRequest) getQuery() (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 +} diff --git a/pkg/exchange/kucoin/kucoinapi/cancel_order_request_accessors.go b/pkg/exchange/kucoin/kucoinapi/cancel_order_request_accessors.go new file mode 100644 index 000000000..5865dad21 --- /dev/null +++ b/pkg/exchange/kucoin/kucoinapi/cancel_order_request_accessors.go @@ -0,0 +1,54 @@ +// Code generated by "requestgen -type CancelOrderRequest"; DO NOT EDIT. + +package kucoinapi + +import ( + "fmt" + "net/url" +) + +func (c *CancelOrderRequest) OrderID(orderID string) *CancelOrderRequest { + c.orderID = &orderID + return c +} + +func (c *CancelOrderRequest) ClientOrderID(clientOrderID string) *CancelOrderRequest { + c.clientOrderID = &clientOrderID + return c +} + +func (c *CancelOrderRequest) getParameters() (map[string]interface{}, error) { + var params = map[string]interface{}{} + + // check orderID field -> json key orderID + if c.orderID != nil { + orderID := *c.orderID + + params["orderID"] = orderID + } else { + } + + // check clientOrderID field -> json key clientOrderID + if c.clientOrderID != nil { + clientOrderID := *c.clientOrderID + + params["clientOrderID"] = clientOrderID + } else { + } + return params, nil +} + +func (c *CancelOrderRequest) getQuery() (url.Values, error) { + query := url.Values{} + + params, err := c.getParameters() + if err != nil { + return query, err + } + + for k, v := range params { + query.Add(k, fmt.Sprintf("%v", v)) + } + + return query, nil +} diff --git a/pkg/exchange/kucoin/kucoinapi/place_order_request_accessors.go b/pkg/exchange/kucoin/kucoinapi/place_order_request_accessors.go index cdeb3cadb..04be6f89d 100644 --- a/pkg/exchange/kucoin/kucoinapi/place_order_request_accessors.go +++ b/pkg/exchange/kucoin/kucoinapi/place_order_request_accessors.go @@ -4,6 +4,7 @@ package kucoinapi import ( "fmt" + "github.com/google/uuid" "net/url" ) @@ -60,6 +61,9 @@ func (r *PlaceOrderRequest) getParameters() (map[string]interface{}, error) { params["clientOid"] = clientOrderID } else { + clientOrderID := uuid.New().String() + + params["clientOid"] = clientOrderID } // check symbol field -> json key symbol diff --git a/pkg/exchange/kucoin/kucoinapi/trade.go b/pkg/exchange/kucoin/kucoinapi/trade.go index cc55ffd93..5a50c11a6 100644 --- a/pkg/exchange/kucoin/kucoinapi/trade.go +++ b/pkg/exchange/kucoin/kucoinapi/trade.go @@ -143,7 +143,7 @@ type PlaceOrderRequest struct { client *RestClient // A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. - clientOrderID *string `param:"clientOid,required"` + clientOrderID *string `param:"clientOid,required" defaultValuer:"uuid()"` symbol string `param:"symbol,required"` @@ -169,10 +169,6 @@ func (r *PlaceOrderRequest) Do(ctx context.Context) (*OrderResponse, error) { return nil, err } - if _, ok := payload["clientOid"]; !ok { - payload["clientOid"] = uuid.New().String() - } - req, err := r.client.newAuthenticatedRequest("POST", "/api/v1/orders", nil, payload) if err != nil { return nil, err @@ -200,21 +196,12 @@ func (r *PlaceOrderRequest) Do(ctx context.Context) (*OrderResponse, error) { return orderResponse.Data, nil } +//go:generate requestgen -type CancelOrderRequest type CancelOrderRequest struct { client *RestClient - orderID *string - clientOrderID *string -} - -func (r *CancelOrderRequest) OrderID(orderID string) *CancelOrderRequest { - r.orderID = &orderID - return r -} - -func (r *CancelOrderRequest) ClientOrderID(clientOrderID string) *CancelOrderRequest { - r.clientOrderID = &clientOrderID - return r + orderID *string `param:"orderID"` + clientOrderID *string `param:"clientOrderID"` } type CancelOrderResponse struct { @@ -264,21 +251,21 @@ func (r *CancelOrderRequest) Do(ctx context.Context) (*CancelOrderResponse, erro return apiResponse.Data, nil } +//go:generate requestgen -type CancelAllOrderRequest type CancelAllOrderRequest struct { client *RestClient - symbol *string - - // tradeType string -} - -func (r *CancelAllOrderRequest) Symbol(symbol string) *CancelAllOrderRequest { - r.symbol = &symbol - return r + symbol *string `param:"symbol"` + tradeType *string `param:"tradeType"` } func (r *CancelAllOrderRequest) Do(ctx context.Context) (*CancelOrderResponse, error) { - req, err := r.client.newAuthenticatedRequest("DELETE", "/api/v1/orders", nil, nil) + params, err := r.getQuery() + if err != nil { + return nil, err + } + + req, err := r.client.newAuthenticatedRequest("DELETE", "/api/v1/orders", params, nil) if err != nil { return nil, err }