package product_getComponentTemplate_request

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

type ProductGetComponentTemplateRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *ProductGetComponentTemplateParam
}

func (c *ProductGetComponentTemplateRequest) GetUrlPath() string {
	return "/product/getComponentTemplate"
}

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

}

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

}

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

func (c *ProductGetComponentTemplateRequest) GetParams() *ProductGetComponentTemplateParam {
	return c.Param
}

type ProductGetComponentTemplateParam struct {
	// 模板类型: size_info(尺码表)
	TemplateType string `json:"template_type"`
	// 组件模板子类型；clothing -饰；undies-内衣；shoes 鞋靴；children_clothing-童装
	TemplateSubType string `json:"template_sub_type"`
	// 模板ID
	TemplateId int64 `json:"template_id"`
	// 是否为公有模板(多个商品可共用)
	Shareable bool `json:"shareable"`
	// 页码，从0开始，最大支持100
	PageNum int64 `json:"page_num"`
	// 每页条数，最大支持20；page_size和template_id二选一入参
	PageSize int64 `json:"page_size"`
}
