package promise_deliveryList_request

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

type PromiseDeliveryListRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *PromiseDeliveryListParam
}

func (c *PromiseDeliveryListRequest) GetUrlPath() string {
	return "/promise/deliveryList"
}

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

}

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

}

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

func (c *PromiseDeliveryListRequest) GetParams() *PromiseDeliveryListParam {
	return c.Param
}

type PromiseDeliveryListParam struct {
	// 商品ID
	ProductId int64 `json:"product_id"`
	// 页码，从1开始
	Page int64 `json:"page"`
	// 每页数量
	Size int64 `json:"size"`
}
