Skip to content

Commit

Permalink
Merge pull request #152 from renderforest/fix-optional-parameter-issue
Browse files Browse the repository at this point in the history
fix-optional-parameter-issue
  • Loading branch information
narekhovhannisyan authored Feb 8, 2019
2 parents 29d39d5 + eacb3e4 commit 3dae667
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ renderforest.duplicateProject(payload)

### Render the Project

Renders the project.
Renders the project with given quality. The possible values for the quality are: 0, 360, 720, and 1080.
The watermark parameter is optional, must be in '.png' file format and have canvas size of 1920 x 1080 pixels,
url length must not exceed 250 characters and is not applicable to HD quality videos.

```js
const Renderforest = require('@renderforest/sdk-node')

Expand Down
2 changes: 1 addition & 1 deletion examples/projects/delete-project-videos.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Renderforest = require('../../src/lib/renderforest')
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })

const payload = {
projectId: 5000658,
projectId: 4120385,
quality: 360 // optional argument
}
renderforest.deleteProjectVideos(payload)
Expand Down
2 changes: 1 addition & 1 deletion examples/projects/render-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Renderforest = require('../../src/lib/renderforest')
const renderforest = new Renderforest({ signKey: '<signKey>', clientId: -1 })

const payload = {
projectId: 5000658,
projectId: 4120385,
quality: 360,
watermark: 'https://example.com/watermark.png' // optional argument
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "@renderforest/sdk-node",
"description": "Renderforest SDK for Node.js",
"version": "0.3.8",
"version": "0.3.9",
"author": "RenderForest LLC",
"bugs": {
"url": "https://github.com/renderforest/renderforest-sdk-node/issues"
},
"contributors": [
{
"name": "Narek Hovhannisyan",
"email": "[email protected]"
},
{
"name": "Albert Hambardzumyan",
"email": "[email protected]"
Expand Down
21 changes: 9 additions & 12 deletions src/util/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const { RenderforestError } = require('./error')

class Params {
/**
* @param {Object} payload
* @param {Array} props
* Destruct given properties from the payload.
* @param {Object} payload - The payload to destruct.
* @param {Array} props - The props to destruct from payload.
* @returns {Object}
* @description Destruct given properties from the payload.
*/
static destructParams (payload, props) {
if (!payload || !Object.keys(payload).length) {
Expand All @@ -30,11 +30,11 @@ class Params {
}

/**
* @param {Object} payload
* @param {string} param
* @returns {number|undefined}
* Destruct URL param from the payload.
* @param {Object} payload - The payload to destruct.
* @param {string} param - The param to destruct from payload.
* @returns {number|string}
* @throws RenderforestError
* @description Destruct URL param from the payload.
*/
static destructURLParam (payload, param) {
if (!payload || !Object.keys(payload).length || payload[param] === undefined) {
Expand All @@ -45,17 +45,14 @@ class Params {
}

/**
* Destruct optional URL param from the payload.
* @param {Object} payload
* @param {string} param
* @returns {number|string}
* @throws RenderforestError
* @description Destruct optional URL param from the payload.
*/
static destructOptionalURLParam (payload, param) {
if (!payload || !Object.keys(payload).length) {
throw new RenderforestError(`No parameter specified`)
}
if (payload[param] === undefined) {
if (!payload || !Object.keys(payload).length || payload[param] === undefined) {
return ''
}

Expand Down

0 comments on commit 3dae667

Please sign in to comment.