package logistics_indTrackRegister_reqeust

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

type LogisticsIndTrackRegisterRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *LogisticsIndTrackRegisterRequestParam
}

// GetUrlPath 根据即时配单号和公司编码订阅轨迹，用于即时配服务商推送轨迹
func (c *LogisticsIndTrackRegisterRequest) GetUrlPath() string {
	return "/logistics/ind/track/register"
}

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

}

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

}

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

func (c *LogisticsIndTrackRegisterRequest) GetParams() *LogisticsIndTrackRegisterRequestParam {
	return c.Param
}

type LogisticsIndTrackRegisterRequestParam struct {
	// 	运单号
	TrackNo string `json:"track_no"`
	// 回调地址
	CallbackUrl string `json:"callback_url"`
	// 物流商编码
	Company string `json:"company"`
}
