package freightTemplate_detail_request

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

type FreightTemplateDetailRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *FreightTemplateDetailParam
}

func (c *FreightTemplateDetailRequest) GetUrlPath() string {
	return "/freightTemplate/detail"
}

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

}

type T struct {
	Code int `json:"code"`
	Data struct {
		Columns []struct {
			AddNum           int           `json:"add_num"`
			AddNumPrice      int           `json:"add_num_price"`
			AddWeight        int           `json:"add_weight"`
			AddWeightPrice   int           `json:"add_weight_price"`
			FirstNum         int           `json:"first_num"`
			FirstNumPrice    int           `json:"first_num_price"`
			FirstWeight      int           `json:"first_weight"`
			FirstWeightPrice int           `json:"first_weight_price"`
			IsDefault        int           `json:"is_default"`
			IsLimited        bool          `json:"is_limited"`
			IsOverFree       bool          `json:"is_over_free"`
			OverAmount       int           `json:"over_amount"`
			OverNum          int           `json:"over_num"`
			OverWeight       int           `json:"over_weight"`
			ProvinceInfos    []interface{} `json:"province_infos"`
		} `json:"columns"`
		Template struct {
			CalculateType   int    `json:"calculate_type"`
			FixedAmount     int    `json:"fixed_amount"`
			Id              int    `json:"id"`
			ProductCity     string `json:"product_city"`
			ProductProvince string `json:"product_province"`
			RuleType        int    `json:"rule_type"`
			TemplateName    string `json:"template_name"`
			TransferType    int    `json:"transfer_type"`
		} `json:"template"`
	} `json:"data"`
	LogId   string `json:"log_id"`
	Msg     string `json:"msg"`
	SubCode string `json:"sub_code"`
	SubMsg  string `json:"sub_msg"`
}

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

}

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

func (c *FreightTemplateDetailRequest) GetParams() *FreightTemplateDetailParam {
	return c.Param
}

type FreightTemplateDetailParam struct {
	// 模板id
	FreightId int64 `json:"freight_id"`
}
