package afterSale_buyerExchangeConfirm_request

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

type AfterSaleBuyerExchangeConfirmRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *AfterSaleBuyerExchangeConfirmParam
}

func (c *AfterSaleBuyerExchangeConfirmRequest) GetUrlPath() string {
	return "/afterSale/buyerExchangeConfirm"
}

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

}

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

}

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

func (c *AfterSaleBuyerExchangeConfirmRequest) GetParams() *AfterSaleBuyerExchangeConfirmParam {
	return c.Param
}

type AfterSaleBuyerExchangeConfirmParam struct {
	// 售后的单id
	AfterSaleId int64 `json:"aftersale_id"`
	// 处理方式： false：确认仓库收到退回货货物并二次发货（或直接退款） true：拒绝
	IsReject bool `json:"is_reject"`
	// s_reject为false时，必填，用于指定换货操作行为；换货动作： refund_agree ： 同意换货转退款 exchange_agree：同意换货并发货
	Action string `json:"action"`
	// is_reject = true 时需要选择拒绝原因；具体各个可选值对应的拒绝原因见下表
	Comment string `json:"comment"`
	// 凭证图片，只能传一张
	Evidence []string `json:"evidence"`
	// is_reject = false时需要上传物流单号
	LogisticsCode string `json:"logistics_code"`
	// is_reject = false时需要上传物流公司编号 ，如圆通为yuantong
	CompanyCode string `json:"company_code"`
}
