package material_batchUploadVideoAsync_request

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

type MaterialBatchUploadVideoAsyncRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *MaterialBatchUploadVideoAsyncParam
}

func (c *MaterialBatchUploadVideoAsyncRequest) GetUrlPath() string {
	return "/material/batchUploadVideoAsync"
}

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

}

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

}

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

func (c *MaterialBatchUploadVideoAsyncRequest) GetParams() *MaterialBatchUploadVideoAsyncParam {
	return c.Param
}

type MaterialsItem struct {
	// 素材的唯一id，用于接口幂等（限时1个小时）
	RequestId string `json:"request_id"`
	// 文件夹id，“0”表示将素材上传到素材中心根目录
	FolderId string `json:"folder_id"`
	// 固定值video
	MaterialType string `json:"material_type"`
	// 素材名称，长度限制为50个字符
	Name string `json:"name"`
	// 素材url，素材中心会将改url转换成素材中心的url
	Url string `json:"url"`
}
type MaterialBatchUploadVideoAsyncParam struct {
	// 素材信息
	Materials []MaterialsItem `json:"materials"`
}
