Skip to content

Commit 108d43d

Browse files
Merge pull request #147 from renderforest/update-routes
Update endpoints
2 parents 8f4392c + 77d7edd commit 108d43d

File tree

8 files changed

+87
-4
lines changed

8 files changed

+87
-4
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Welcome to the Renderforest API! You can use our API to:
1818
- [Get a Specific Project](#get-a-specific-project)
1919
- [Update the Project - partial update](#update-the-project---partial-update)
2020
- [Delete a Specific Project](#delete-a-specific-project)
21+
- [Delete Specific Project Videos](#delete-specific-project-videos)
2122
- [Apply Template Preset on the Project](#apply-template-preset-on-the-project)
2223
- [Duplicate the Project](#duplicate-the-project)
2324
- [Render the Project](#render-the-project)
@@ -204,6 +205,25 @@ renderforest.deleteProject(payload)
204205
[See example](https://github.com/renderforest/renderforest-sdk-node/blob/master/examples/projects/delete-project.js)
205206

206207

208+
### Delete Specific Project Videos
209+
210+
Deletes specific project videos.
211+
The quality parameter is optional. If you want to delete only a single quality video, you have to specify quality parameter, otherwise all quality videos of the project will be deleted.
212+
```js
213+
const Renderforest = require('@renderforest/sdk-node')
214+
215+
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
216+
217+
const payload = {
218+
projectId: 5000658,
219+
quality: 360
220+
}
221+
renderforest.deleteProjectVideos(payload)
222+
.then(console.log) // handle the success
223+
.catch(console.error) // handle the error
224+
```
225+
[See example](https://github.com/renderforest/renderforest-sdk-node/blob/master/examples/projects/delete-project-videos.js)
226+
207227
### Apply Template Preset on the Project
208228

209229
Applies template preset on the project.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright (c) 2018-present, Renderforest, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the license found in the
6+
* LICENSE file in the root directory.
7+
*/
8+
9+
const Renderforest = require('../../src/lib/renderforest')
10+
11+
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
12+
13+
const payload = {
14+
projectId: 5000658,
15+
quality: 360
16+
}
17+
renderforest.deleteProjectVideos(payload)
18+
.then(console.log) // handle the success
19+
.catch(console.error) // handle the error

examples/projects/render-project.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })
1212

1313
const payload = {
1414
projectId: 5000658,
15-
quality: 1080
15+
quality: 360,
16+
watermark: 'watermarkURL'
1617
}
1718
renderforest.renderProject(payload)
1819
.then(console.log) // handle the success

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@renderforest/sdk-node",
33
"description": "Renderforest SDK for Node.js",
4-
"version": "0.3.6",
4+
"version": "0.3.7",
55
"author": "RenderForest LLC",
66
"bugs": {
77
"url": "https://github.com/renderforest/renderforest-sdk-node/issues"

src/lib/renderforest.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ class Renderforest {
9898
return Projects.deleteProject(payload)
9999
}
100100

101+
/**
102+
* @param {Object} payload
103+
* @returns {Promise.<Object>}
104+
* @description Delete Specific Project Videos.
105+
*/
106+
deleteProjectVideos (payload) {
107+
return Projects.deleteProjectVideos(payload)
108+
}
109+
101110
/**
102111
* @param {Object} payload
103112
* @returns {Promise.<Object>}

src/lib/resources/projects.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ class Projects {
105105
return ApiRequest.authorizedRequest(options)
106106
}
107107

108+
/**
109+
* @param {Object} payload
110+
* @returns {Promise.<Object>}
111+
* @description Delete Specific Project Videos.
112+
*/
113+
static deleteProjectVideos (payload) {
114+
const projectId = Params.destructURLParam(payload, 'projectId')
115+
const quality = Params.destructOptionalURLParam(payload, 'quality')
116+
117+
const options = {
118+
method: 'DELETE',
119+
endpoint: `${API_PREFIX}/projects/${projectId}/videos/${quality}`
120+
}
121+
return ApiRequest.authorizedRequest(options)
122+
}
123+
108124
/**
109125
* @param {Object} payload
110126
* @returns {Promise.<Object>}
@@ -143,7 +159,7 @@ class Projects {
143159
* @description Render the Project.
144160
*/
145161
static renderProject (payload) {
146-
const body = Params.destructParams(payload, ['quality'])
162+
const body = Params.destructParams(payload, ['quality', 'watermark'])
147163
const projectId = Params.destructURLParam(payload, 'projectId')
148164

149165
const options = {

src/util/params.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ class Params {
4343

4444
return payload[param]
4545
}
46+
47+
/**
48+
* @param {Object} payload
49+
* @param {string} param
50+
* @returns {number|string}
51+
* @throws RenderforestError
52+
* @description Destruct optional URL param from the payload.
53+
*/
54+
static destructOptionalURLParam (payload, param) {
55+
if (!payload || !Object.keys(payload).length) {
56+
throw new RenderforestError(`No parameter specified`)
57+
}
58+
if (payload[param] === undefined) {
59+
return ''
60+
}
61+
62+
return payload[param]
63+
}
4664
}
4765

4866
module.exports = Params

0 commit comments

Comments
 (0)