pkg/exchange: rm redundant prefix

This commit is contained in:
Edwin 2023-07-27 10:31:24 +08:00
parent 5105046053
commit 574d7c0c74
5 changed files with 65 additions and 65 deletions

View File

@ -12,8 +12,8 @@ type CancelOrderResponse struct {
OrderLinkId string `json:"orderLinkId"`
}
//go:generate PostRequest -url "/v5/order/cancel" -type PostCancelOrderRequest -responseDataType .CancelOrderResponse
type PostCancelOrderRequest struct {
//go:generate PostRequest -url "/v5/order/cancel" -type CancelOrderRequest -responseDataType .CancelOrderResponse
type CancelOrderRequest struct {
client requestgen.AuthenticatedAPIClient
category Category `param:"category" validValues:"spot"`
@ -27,8 +27,8 @@ type PostCancelOrderRequest struct {
orderFilter *string `param:"timeInForce" validValues:"Order"`
}
func (c *RestClient) NewCancelOrderRequest() *PostCancelOrderRequest {
return &PostCancelOrderRequest{
func (c *RestClient) NewCancelOrderRequest() *CancelOrderRequest {
return &CancelOrderRequest{
client: c,
category: CategorySpot,
}

View File

@ -1,4 +1,4 @@
// Code generated by "requestgen -method POST -responseType .APIResponse -responseDataField Result -url /v5/order/cancel -type PostCancelOrderRequest -responseDataType .CancelOrderResponse"; DO NOT EDIT.
// Code generated by "requestgen -method POST -responseType .APIResponse -responseDataField Result -url /v5/order/cancel -type CancelOrderRequest -responseDataType .CancelOrderResponse"; DO NOT EDIT.
package bybitapi
@ -11,33 +11,33 @@ import (
"regexp"
)
func (p *PostCancelOrderRequest) Category(category Category) *PostCancelOrderRequest {
func (p *CancelOrderRequest) Category(category Category) *CancelOrderRequest {
p.category = category
return p
}
func (p *PostCancelOrderRequest) Symbol(symbol string) *PostCancelOrderRequest {
func (p *CancelOrderRequest) Symbol(symbol string) *CancelOrderRequest {
p.symbol = symbol
return p
}
func (p *PostCancelOrderRequest) OrderLinkId(orderLinkId string) *PostCancelOrderRequest {
func (p *CancelOrderRequest) OrderLinkId(orderLinkId string) *CancelOrderRequest {
p.orderLinkId = orderLinkId
return p
}
func (p *PostCancelOrderRequest) OrderId(orderId string) *PostCancelOrderRequest {
func (p *CancelOrderRequest) OrderId(orderId string) *CancelOrderRequest {
p.orderId = &orderId
return p
}
func (p *PostCancelOrderRequest) OrderFilter(orderFilter string) *PostCancelOrderRequest {
func (p *CancelOrderRequest) OrderFilter(orderFilter string) *CancelOrderRequest {
p.orderFilter = &orderFilter
return p
}
// GetQueryParameters builds and checks the query parameters and returns url.Values
func (p *PostCancelOrderRequest) GetQueryParameters() (url.Values, error) {
func (p *CancelOrderRequest) GetQueryParameters() (url.Values, error) {
var params = map[string]interface{}{}
query := url.Values{}
@ -49,7 +49,7 @@ func (p *PostCancelOrderRequest) GetQueryParameters() (url.Values, error) {
}
// GetParameters builds and checks the parameters and return the result in a map object
func (p *PostCancelOrderRequest) GetParameters() (map[string]interface{}, error) {
func (p *CancelOrderRequest) GetParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
// check category field -> json key category
category := p.category
@ -109,7 +109,7 @@ func (p *PostCancelOrderRequest) GetParameters() (map[string]interface{}, error)
}
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
func (p *PostCancelOrderRequest) GetParametersQuery() (url.Values, error) {
func (p *CancelOrderRequest) GetParametersQuery() (url.Values, error) {
query := url.Values{}
params, err := p.GetParameters()
@ -131,7 +131,7 @@ func (p *PostCancelOrderRequest) GetParametersQuery() (url.Values, error) {
}
// GetParametersJSON converts the parameters from GetParameters into the JSON format
func (p *PostCancelOrderRequest) GetParametersJSON() ([]byte, error) {
func (p *CancelOrderRequest) GetParametersJSON() ([]byte, error) {
params, err := p.GetParameters()
if err != nil {
return nil, err
@ -141,13 +141,13 @@ func (p *PostCancelOrderRequest) GetParametersJSON() ([]byte, error) {
}
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
func (p *PostCancelOrderRequest) GetSlugParameters() (map[string]interface{}, error) {
func (p *CancelOrderRequest) GetSlugParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
func (p *PostCancelOrderRequest) applySlugsToUrl(url string, slugs map[string]string) string {
func (p *CancelOrderRequest) applySlugsToUrl(url string, slugs map[string]string) string {
for _k, _v := range slugs {
needleRE := regexp.MustCompile(":" + _k + "\\b")
url = needleRE.ReplaceAllString(url, _v)
@ -156,7 +156,7 @@ func (p *PostCancelOrderRequest) applySlugsToUrl(url string, slugs map[string]st
return url
}
func (p *PostCancelOrderRequest) iterateSlice(slice interface{}, _f func(it interface{})) {
func (p *CancelOrderRequest) iterateSlice(slice interface{}, _f func(it interface{})) {
sliceValue := reflect.ValueOf(slice)
for _i := 0; _i < sliceValue.Len(); _i++ {
it := sliceValue.Index(_i).Interface()
@ -164,7 +164,7 @@ func (p *PostCancelOrderRequest) iterateSlice(slice interface{}, _f func(it inte
}
}
func (p *PostCancelOrderRequest) isVarSlice(_v interface{}) bool {
func (p *CancelOrderRequest) isVarSlice(_v interface{}) bool {
rt := reflect.TypeOf(_v)
switch rt.Kind() {
case reflect.Slice:
@ -173,7 +173,7 @@ func (p *PostCancelOrderRequest) isVarSlice(_v interface{}) bool {
return false
}
func (p *PostCancelOrderRequest) GetSlugsMap() (map[string]string, error) {
func (p *CancelOrderRequest) GetSlugsMap() (map[string]string, error) {
slugs := map[string]string{}
params, err := p.GetSlugParameters()
if err != nil {
@ -187,7 +187,7 @@ func (p *PostCancelOrderRequest) GetSlugsMap() (map[string]string, error) {
return slugs, nil
}
func (p *PostCancelOrderRequest) Do(ctx context.Context) (*CancelOrderResponse, error) {
func (p *CancelOrderRequest) Do(ctx context.Context) (*CancelOrderResponse, error) {
params, err := p.GetParameters()
if err != nil {

View File

@ -79,7 +79,7 @@ func TestClient(t *testing.T) {
}
})
t.Run("PostPlaceOrderRequest", func(t *testing.T) {
t.Run("PlaceOrderRequest", func(t *testing.T) {
req := client.NewPlaceOrderRequest().
Symbol("DOTUSDT").
Side(SideBuy).
@ -98,7 +98,7 @@ func TestClient(t *testing.T) {
t.Logf("apiResp: %+v", ordersResp.List[0])
})
t.Run("PostCancelOrderRequest", func(t *testing.T) {
t.Run("CancelOrderRequest", func(t *testing.T) {
req := client.NewPlaceOrderRequest().
Symbol("DOTUSDT").
Side(SideBuy).

View File

@ -12,8 +12,8 @@ type PlaceOrderResponse struct {
OrderLinkId string `json:"orderLinkId"`
}
//go:generate PostRequest -url "/v5/order/create" -type PostPlaceOrderRequest -responseDataType .PlaceOrderResponse
type PostPlaceOrderRequest struct {
//go:generate PostRequest -url "/v5/order/create" -type PlaceOrderRequest -responseDataType .PlaceOrderResponse
type PlaceOrderRequest struct {
client requestgen.AuthenticatedAPIClient
category Category `param:"category" validValues:"spot"`
@ -49,8 +49,8 @@ type PostPlaceOrderRequest struct {
slOrderType *string `param:"slOrderType"`
}
func (c *RestClient) NewPlaceOrderRequest() *PostPlaceOrderRequest {
return &PostPlaceOrderRequest{
func (c *RestClient) NewPlaceOrderRequest() *PlaceOrderRequest {
return &PlaceOrderRequest{
client: c,
category: CategorySpot,
}

View File

@ -1,4 +1,4 @@
// Code generated by "requestgen -method POST -responseType .APIResponse -responseDataField Result -url /v5/order/create -type PostPlaceOrderRequest -responseDataType .PlaceOrderResponse"; DO NOT EDIT.
// Code generated by "requestgen -method POST -responseType .APIResponse -responseDataField Result -url /v5/order/create -type PlaceOrderRequest -responseDataType .PlaceOrderResponse"; DO NOT EDIT.
package bybitapi
@ -11,148 +11,148 @@ import (
"regexp"
)
func (p *PostPlaceOrderRequest) Category(category Category) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) Category(category Category) *PlaceOrderRequest {
p.category = category
return p
}
func (p *PostPlaceOrderRequest) Symbol(symbol string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) Symbol(symbol string) *PlaceOrderRequest {
p.symbol = symbol
return p
}
func (p *PostPlaceOrderRequest) Side(side Side) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) Side(side Side) *PlaceOrderRequest {
p.side = side
return p
}
func (p *PostPlaceOrderRequest) OrderType(orderType OrderType) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) OrderType(orderType OrderType) *PlaceOrderRequest {
p.orderType = orderType
return p
}
func (p *PostPlaceOrderRequest) Qty(qty string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) Qty(qty string) *PlaceOrderRequest {
p.qty = qty
return p
}
func (p *PostPlaceOrderRequest) OrderLinkId(orderLinkId string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) OrderLinkId(orderLinkId string) *PlaceOrderRequest {
p.orderLinkId = orderLinkId
return p
}
func (p *PostPlaceOrderRequest) TimeInForce(timeInForce TimeInForce) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TimeInForce(timeInForce TimeInForce) *PlaceOrderRequest {
p.timeInForce = timeInForce
return p
}
func (p *PostPlaceOrderRequest) IsLeverage(isLeverage bool) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) IsLeverage(isLeverage bool) *PlaceOrderRequest {
p.isLeverage = &isLeverage
return p
}
func (p *PostPlaceOrderRequest) Price(price string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) Price(price string) *PlaceOrderRequest {
p.price = &price
return p
}
func (p *PostPlaceOrderRequest) TriggerDirection(triggerDirection int) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TriggerDirection(triggerDirection int) *PlaceOrderRequest {
p.triggerDirection = &triggerDirection
return p
}
func (p *PostPlaceOrderRequest) OrderFilter(orderFilter string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) OrderFilter(orderFilter string) *PlaceOrderRequest {
p.orderFilter = &orderFilter
return p
}
func (p *PostPlaceOrderRequest) TriggerPrice(triggerPrice string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TriggerPrice(triggerPrice string) *PlaceOrderRequest {
p.triggerPrice = &triggerPrice
return p
}
func (p *PostPlaceOrderRequest) TriggerBy(triggerBy string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TriggerBy(triggerBy string) *PlaceOrderRequest {
p.triggerBy = &triggerBy
return p
}
func (p *PostPlaceOrderRequest) OrderIv(orderIv string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) OrderIv(orderIv string) *PlaceOrderRequest {
p.orderIv = &orderIv
return p
}
func (p *PostPlaceOrderRequest) PositionIdx(positionIdx string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) PositionIdx(positionIdx string) *PlaceOrderRequest {
p.positionIdx = &positionIdx
return p
}
func (p *PostPlaceOrderRequest) TakeProfit(takeProfit string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TakeProfit(takeProfit string) *PlaceOrderRequest {
p.takeProfit = &takeProfit
return p
}
func (p *PostPlaceOrderRequest) StopLoss(stopLoss string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) StopLoss(stopLoss string) *PlaceOrderRequest {
p.stopLoss = &stopLoss
return p
}
func (p *PostPlaceOrderRequest) TpTriggerBy(tpTriggerBy string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TpTriggerBy(tpTriggerBy string) *PlaceOrderRequest {
p.tpTriggerBy = &tpTriggerBy
return p
}
func (p *PostPlaceOrderRequest) SlTriggerBy(slTriggerBy string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) SlTriggerBy(slTriggerBy string) *PlaceOrderRequest {
p.slTriggerBy = &slTriggerBy
return p
}
func (p *PostPlaceOrderRequest) ReduceOnly(reduceOnly bool) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) ReduceOnly(reduceOnly bool) *PlaceOrderRequest {
p.reduceOnly = &reduceOnly
return p
}
func (p *PostPlaceOrderRequest) CloseOnTrigger(closeOnTrigger bool) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) CloseOnTrigger(closeOnTrigger bool) *PlaceOrderRequest {
p.closeOnTrigger = &closeOnTrigger
return p
}
func (p *PostPlaceOrderRequest) SmpType(smpType string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) SmpType(smpType string) *PlaceOrderRequest {
p.smpType = &smpType
return p
}
func (p *PostPlaceOrderRequest) Mmp(mmp bool) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) Mmp(mmp bool) *PlaceOrderRequest {
p.mmp = &mmp
return p
}
func (p *PostPlaceOrderRequest) TpslMode(tpslMode string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TpslMode(tpslMode string) *PlaceOrderRequest {
p.tpslMode = &tpslMode
return p
}
func (p *PostPlaceOrderRequest) TpLimitPrice(tpLimitPrice string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TpLimitPrice(tpLimitPrice string) *PlaceOrderRequest {
p.tpLimitPrice = &tpLimitPrice
return p
}
func (p *PostPlaceOrderRequest) SlLimitPrice(slLimitPrice string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) SlLimitPrice(slLimitPrice string) *PlaceOrderRequest {
p.slLimitPrice = &slLimitPrice
return p
}
func (p *PostPlaceOrderRequest) TpOrderType(tpOrderType string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) TpOrderType(tpOrderType string) *PlaceOrderRequest {
p.tpOrderType = &tpOrderType
return p
}
func (p *PostPlaceOrderRequest) SlOrderType(slOrderType string) *PostPlaceOrderRequest {
func (p *PlaceOrderRequest) SlOrderType(slOrderType string) *PlaceOrderRequest {
p.slOrderType = &slOrderType
return p
}
// GetQueryParameters builds and checks the query parameters and returns url.Values
func (p *PostPlaceOrderRequest) GetQueryParameters() (url.Values, error) {
func (p *PlaceOrderRequest) GetQueryParameters() (url.Values, error) {
var params = map[string]interface{}{}
query := url.Values{}
@ -164,7 +164,7 @@ func (p *PostPlaceOrderRequest) GetQueryParameters() (url.Values, error) {
}
// GetParameters builds and checks the parameters and return the result in a map object
func (p *PostPlaceOrderRequest) GetParameters() (map[string]interface{}, error) {
func (p *PlaceOrderRequest) GetParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
// check category field -> json key category
category := p.category
@ -418,7 +418,7 @@ func (p *PostPlaceOrderRequest) GetParameters() (map[string]interface{}, error)
}
// GetParametersQuery converts the parameters from GetParameters into the url.Values format
func (p *PostPlaceOrderRequest) GetParametersQuery() (url.Values, error) {
func (p *PlaceOrderRequest) GetParametersQuery() (url.Values, error) {
query := url.Values{}
params, err := p.GetParameters()
@ -440,7 +440,7 @@ func (p *PostPlaceOrderRequest) GetParametersQuery() (url.Values, error) {
}
// GetParametersJSON converts the parameters from GetParameters into the JSON format
func (p *PostPlaceOrderRequest) GetParametersJSON() ([]byte, error) {
func (p *PlaceOrderRequest) GetParametersJSON() ([]byte, error) {
params, err := p.GetParameters()
if err != nil {
return nil, err
@ -450,13 +450,13 @@ func (p *PostPlaceOrderRequest) GetParametersJSON() ([]byte, error) {
}
// GetSlugParameters builds and checks the slug parameters and return the result in a map object
func (p *PostPlaceOrderRequest) GetSlugParameters() (map[string]interface{}, error) {
func (p *PlaceOrderRequest) GetSlugParameters() (map[string]interface{}, error) {
var params = map[string]interface{}{}
return params, nil
}
func (p *PostPlaceOrderRequest) applySlugsToUrl(url string, slugs map[string]string) string {
func (p *PlaceOrderRequest) applySlugsToUrl(url string, slugs map[string]string) string {
for _k, _v := range slugs {
needleRE := regexp.MustCompile(":" + _k + "\\b")
url = needleRE.ReplaceAllString(url, _v)
@ -465,7 +465,7 @@ func (p *PostPlaceOrderRequest) applySlugsToUrl(url string, slugs map[string]str
return url
}
func (p *PostPlaceOrderRequest) iterateSlice(slice interface{}, _f func(it interface{})) {
func (p *PlaceOrderRequest) iterateSlice(slice interface{}, _f func(it interface{})) {
sliceValue := reflect.ValueOf(slice)
for _i := 0; _i < sliceValue.Len(); _i++ {
it := sliceValue.Index(_i).Interface()
@ -473,7 +473,7 @@ func (p *PostPlaceOrderRequest) iterateSlice(slice interface{}, _f func(it inter
}
}
func (p *PostPlaceOrderRequest) isVarSlice(_v interface{}) bool {
func (p *PlaceOrderRequest) isVarSlice(_v interface{}) bool {
rt := reflect.TypeOf(_v)
switch rt.Kind() {
case reflect.Slice:
@ -482,7 +482,7 @@ func (p *PostPlaceOrderRequest) isVarSlice(_v interface{}) bool {
return false
}
func (p *PostPlaceOrderRequest) GetSlugsMap() (map[string]string, error) {
func (p *PlaceOrderRequest) GetSlugsMap() (map[string]string, error) {
slugs := map[string]string{}
params, err := p.GetSlugParameters()
if err != nil {
@ -496,7 +496,7 @@ func (p *PostPlaceOrderRequest) GetSlugsMap() (map[string]string, error) {
return slugs, nil
}
func (p *PostPlaceOrderRequest) Do(ctx context.Context) (*PlaceOrderResponse, error) {
func (p *PlaceOrderRequest) Do(ctx context.Context) (*PlaceOrderResponse, error) {
params, err := p.GetParameters()
if err != nil {