package material_uploadVideoAsync_request

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

type MaterialUploadVideoAsyncRequest struct {
	doudian_sdk.BaseDoudianOpApiRequest
	Param *MaterialUploadVideoAsyncParam
}

func (c *MaterialUploadVideoAsyncRequest) GetUrlPath() string {
	return "/material/uploadVideoAsync"
}

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

}

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

}

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

func (c *MaterialUploadVideoAsyncRequest) GetParams() *MaterialUploadVideoAsyncParam {
	return c.Param
}

type MaterialUploadVideoAsyncParam struct {
	// 父文件夹id
	FolderId string `json:"folder_id"`
	// 视频url
	Url string `json:"url"`
	// 视频名称，不得超过50个字符
	Name string `json:"name"`
}
