package product_getProductUpdateRule_request

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

type ProductGetProductUpdateRuleRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *ProductGetProductUpdateRuleParam
}

func (c *ProductGetProductUpdateRuleRequest) GetUrlPath() string {
	return "/product/getProductUpdateRule"
}

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

}

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

}

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

func (c *ProductGetProductUpdateRuleRequest) GetParams() *ProductGetProductUpdateRuleParam {
	return c.Param
}

type ProductGetProductUpdateRuleParam struct {
	// 类目id
	CategoryId int64 `json:"category_id"`
	// 闪购定制参数，普通发品忽略
	Senses []int32 `json:"senses"`
	// 品牌id
	StandardBrandId int64 `json:"standard_brand_id"`
	// spu_id
	SpuId int64 `json:"spu_id"`
}
