From 869f214ccdb114af6a438b21b352de4542bf23ff Mon Sep 17 00:00:00 2001 From: Allan Nava Date: Tue, 14 Nov 2023 16:30:07 +0100 Subject: [PATCH] feat: added SetPublishedUpload --- compress/api_upload.go | 26 ++++++++++++++++++++++++++ compress/compress.go | 1 + compress/constants.go | 5 ++++- compress/model_upload.go | 6 ++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/compress/api_upload.go b/compress/api_upload.go index 3a6c863..9aaa3dd 100644 --- a/compress/api_upload.go +++ b/compress/api_upload.go @@ -93,4 +93,30 @@ func (o *compress) GetJobidProgress(requestBody jobidProgressRequest) (*VideoUpl return nil, err } return &obj, nil +} +/** +* jobid is compulsory +* example: set_published_upload(1000) +* @param {string} api_key +* @param {number} jobid +*/ +func (o *compress) SetPublishedUpload(requestBody publishedUploadRequest) (*VideoUploadInfo , error) { + // + if errs := validator.Validate(requestBody); errs != nil { + // values not valid, deal with errors here + return nil, errs + } + resp, err := o.restyPost(SET_PUBLISHED_UPLOAD(requestBody.JobId), requestBody) + if err != nil { + return nil, err + } + o.debugPrint(resp) + if resp.IsError() { + return nil, fmt.Errorf("") + } + var obj VideoUploadInfo + if err := json.Unmarshal(resp.Body(), &obj); err != nil { + return nil, err + } + return &obj, nil } \ No newline at end of file diff --git a/compress/compress.go b/compress/compress.go index d62cf9c..5055cf0 100644 --- a/compress/compress.go +++ b/compress/compress.go @@ -11,6 +11,7 @@ type ICompress interface { GetUploads(uploadsPaginated UploadsPaginated) ([]VideoUploadInfo, error) GetSingleUpload(requestBody jobidProgressRequest) (*VideoUploadInfo , error) GetJobidProgress(requestBody jobidProgressRequest) (*VideoUploadInfo , error) + SetPublishedUpload(requestBody publishedUploadRequest) (*VideoUploadInfo , error) GetCategories(requestBody categoriesRequest) ([]Category, error) CreateCategory( requestBody createCategoryRequest ) (*Category, error) // diff --git a/compress/constants.go b/compress/constants.go index 56d5db8..d88c58c 100644 --- a/compress/constants.go +++ b/compress/constants.go @@ -31,7 +31,10 @@ var ( return TNGRM_BASE_URL+UPLOADS+"/jobid" } GET_JOBID_PROGRESS = func(jobId int) string { - return TNGRM_BASE_URL+UPLOADS+"job_progress/jobid" + return TNGRM_BASE_URL+UPLOADS+"/job_progress/jobid" + } + SET_PUBLISHED_UPLOAD = func(jobId int) string { + return TNGRM_BASE_URL+UPLOADS+"/set_published" } // ) \ No newline at end of file diff --git a/compress/model_upload.go b/compress/model_upload.go index 6bf6cb5..84b82cf 100644 --- a/compress/model_upload.go +++ b/compress/model_upload.go @@ -50,4 +50,10 @@ type VideoUploadInfo struct { type jobidProgressRequest struct { BaseModel JobId int `json:"job_id" validate:"nonzero,min=1" required:"true"` +} + +type publishedUploadRequest struct { + BaseModel + JobId int `json:"job_id" validate:"nonzero,min=1" required:"true"` + Published int `json:"published" required:"true"` } \ No newline at end of file