package superm_product_launchProduct_request

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

type SupermProductLaunchProductRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *SupermProductLaunchProductParam
}

func (c *SupermProductLaunchProductRequest) GetUrlPath() string {
	return "/superm/product/launchProduct"
}

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

}

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

}

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

func (c *SupermProductLaunchProductRequest) GetParams() *SupermProductLaunchProductParam {
	return c.Param
}

type SupermProductLaunchProductParam struct {
	// 商品ID，支持主品上架，支持子品上架； (主品需要审核通过后上架)
	ProductId int64 `json:"product_id"`
}
