package instantShopping_cancelDelivery_request

import (
	"encoding/json"
	instantShopping_cancelDelivery_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/instantShopping_cancelDelivery/response"
	doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
)

type InstantShoppingCancelDeliveryRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *InstantShoppingCancelDeliveryParam
}

func (c *InstantShoppingCancelDeliveryRequest) GetUrlPath() string {
	return "/instantShopping/cancelDelivery"
}

func New() *InstantShoppingCancelDeliveryRequest {
	request := &InstantShoppingCancelDeliveryRequest{
		Param: &InstantShoppingCancelDeliveryParam{},
	}
	request.SetConfig(doudian_sdk.GlobalConfig)
	request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
	return request

}

func (c *InstantShoppingCancelDeliveryRequest) Execute(accessToken *doudian_sdk.AccessToken) (*instantShopping_cancelDelivery_response.InstantShoppingCancelDeliveryResponse, error) {
	responseJson, err := c.GetClient().Request(c, accessToken)
	if err != nil {
		return nil, err
	}
	response := &instantShopping_cancelDelivery_response.InstantShoppingCancelDeliveryResponse{}
	_ = json.Unmarshal([]byte(responseJson), response)
	return response, nil

}

func (c *InstantShoppingCancelDeliveryRequest) GetParamObject() interface{} {
	return c.Param
}

func (c *InstantShoppingCancelDeliveryRequest) GetParams() *InstantShoppingCancelDeliveryParam {
	return c.Param
}

type InstantShoppingCancelDeliveryParam struct {
	// 抖音电商shop order单id
	ShopOrderId string `json:"shop_order_id"`
	// 门店id
	StoreId int64 `json:"store_id"`
	// 取消原因，详见附录F01
	CancelCode int64 `json:"cancel_code"`
}
