diff --git a/services/mkt2/client.go b/services/mkt2/client.go new file mode 100644 index 0000000..9415ea5 --- /dev/null +++ b/services/mkt2/client.go @@ -0,0 +1,30 @@ +package mkt2 + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" +) + +const ( + VERSION = "2026-02-03" +) + +var HOST = requests.Host{ + Default: "mkt2-api", +} + +type Client struct { + sdk.Client +} + +func NewClient() (client *Client, err error) { + client = new(Client) + err = client.Init() + return +} + +func (c *Client) MaterialTaskNotify(request *MaterialTaskNotifyRequest) (response *MaterialTaskNotifyResponse, err error) { + response = CreateMaterialTaskNotifyResponse() + err = c.DoAction(request, response) + return +} diff --git a/services/mkt2/client_test.go b/services/mkt2/client_test.go new file mode 100644 index 0000000..db01be6 --- /dev/null +++ b/services/mkt2/client_test.go @@ -0,0 +1,35 @@ +package mkt2 + +import ( + "fmt" + "testing" +) + +// TestClient_MaterialTaskNotify 测试素材处理任务通知 +func TestClient_MaterialTaskNotify(t *testing.T) { + client, err := NewClient() + if err != nil { + t.Error("NewClient error:", err) + return + } + request := CreateMaterialTaskNotifyRequest(MaterialTaskNotifyParam{ + TaskType: "resource_to_vdb", + TaskId: 223, + FileInfo: FileInfo{ + Md5: "2fcf1306458f2321bccbb0e2ee8a712b", + Duration: 0, + Size: 14745, + Width: 480, + Height: 392, + Bitrate: 0, + Format: "jpg", + }, + }) + response, err := client.MaterialTaskNotify(request) + if err != nil { + t.Error("MaterialTaskNotify error:", err) + return + } + t.Log("response:", response) + fmt.Println("") +} diff --git a/services/mkt2/materialtask.go b/services/mkt2/materialtask.go new file mode 100644 index 0000000..638f2a7 --- /dev/null +++ b/services/mkt2/materialtask.go @@ -0,0 +1,57 @@ +package mkt2 + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +type MaterialTaskNotifyParam struct { + TaskType string `json:"task_type"` + TaskId int64 `json:"task_id"` + FileInfo FileInfo `json:"file_info"` +} + +// MaterialTaskNotifyRequest 媒资任务通知请求 +type MaterialTaskNotifyRequest struct { + *requests.JsonRequest + TaskType string `position:"Json" field:"task_type"` + TaskId int64 `position:"Json" field:"task_id"` + FileInfo FileInfo `position:"Json" field:"file_info"` +} + +// FileInfo 文件信息 +type FileInfo struct { + Md5 string `json:"md5"` + Duration float64 `json:"duration"` + Size int64 `json:"size"` + Width int64 `json:"width"` + Height int64 `json:"height"` + Bitrate int64 `json:"bitrate"` + Format string `json:"format"` +} + +type MaterialTaskNotifyResponse struct { + *responses.BaseResponse + StatusCode int `json:"status_code"` + StatusMsg string `json:"status_msg"` + TraceId string `json:"trace_id"` +} + +func CreateMaterialTaskNotifyRequest(param MaterialTaskNotifyParam) (req *MaterialTaskNotifyRequest) { + req = &MaterialTaskNotifyRequest{ + JsonRequest: &requests.JsonRequest{}, + TaskType: param.TaskType, + TaskId: param.TaskId, + FileInfo: param.FileInfo, + } + req.InitWithApiInfo(HOST, VERSION, "/api/cooperation/creativesMaterial/materialTaskNotify") + req.Method = requests.POST + return +} + +func CreateMaterialTaskNotifyResponse() (response *MaterialTaskNotifyResponse) { + response = &MaterialTaskNotifyResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +}