package logistics_indTrackPush_reqeust

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

type LogisticsIndTrackPushRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *LogisticsIndTrackPushParam
}

// GetUrlPath 同步配送坐标,配送轨迹推送
func (c *LogisticsIndTrackPushRequest) GetUrlPath() string {
	return "/logistics/indTrackPush"
}

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

}

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

}

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

func (c *LogisticsIndTrackPushRequest) GetParams() *LogisticsIndTrackPushParam {
	return c.Param
}

type LogisticsIndTrackPushParam struct {
	// 	请求时间
	CurTime string `json:"cur_time"`
	// 公司编码
	Company string `json:"company"`
	// 轨迹信息
	TraceMsgs []TraceMsgList `json:"trace_msgs"`
	// 未知
	//AuthorityId string `json:"authority_id"`
}

type TraceMsgList struct {
	// 运单号
	TrackNo string `json:"track_no"`
	// 轨迹列表
	Traces []TracesList `json:"traces"`
}

type TracesList struct {
	// 事件编码
	Opcode string `json:"opcode"`
	// 时间操作时间
	OpTime string `json:"op_time"`
	// 文案
	Content string `json:"content"`
	// 骑手信息
	Rider ReiderInfo `json:"rider"`
	// 三方运力公司，顺丰同城 sftc 闪送 shansong 达达 dada UU uupt 美团 meituan 蜂鸟 fengniao
	ThirdPartyCompany string `json:"third_party_company"`
	// 异常编码
	ExceptionCode string `json:"exception_code"`
	// 异常原因
	ExceptionDesc string `json:"exception_desc"`
	// 取消编码
	CancelCode string `json:"cancel_code"`
	// 取消原因
	CancelDesc string `json:"cancel_desc"`
}

type ReiderInfo struct {
	Name   string `json:"name"`   // 	骑手姓名
	Mobile string `json:"mobile"` // 	骑手电话号码
}
