Skip to content

Commit

Permalink
Merge pull request #183 from renderforest/project-data-upgrade
Browse files Browse the repository at this point in the history
project-data-upgrade
  • Loading branch information
narekhovhannisyan authored Jun 19, 2019
2 parents 5b3d9c5 + 2d74f22 commit 6a3713e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
30 changes: 21 additions & 9 deletions lib/project-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ class ProjectData {
* @return {result}
*/
setText: function (text) {
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
const areaChecker = checkAreaType(area, 'text')
areaChecker(NotTextAreaError.of(`Area with id: ${id} is not text.`))

area.value = text
self.patchProperties.push('screens')
return this
Expand All @@ -484,7 +486,9 @@ class ProjectData {
* @return {result}
*/
setTextScale: function (scale) {
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
const areaChecker = checkAreaType(area, 'text')
areaChecker(NotTextAreaError.of(`Area with id: ${id} is not text.`))

if (scale < 80 || scale > 120) {
throw new InvalidTextScaleValue('The text scale value must be between 80 and 120.')
}
Expand All @@ -498,34 +502,42 @@ class ProjectData {
* @throws {NotTextAreaError}
*/
getRecommendedCharacterCount: () => {
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
const areaChecker = checkAreaType(area, 'text')
areaChecker(NotTextAreaError.of(`Area with id: ${id} is not text.`))

return Math.floor(parseInt(wordCount) * AVERAGE_CHARS_IN_WORD)
},
/**
* Checks if area is `image`, then sets the new image.
* @param {Object} image - The image properties.
* @throws {NotImageAreaError}
*/
setImage: (image) => {
checkAreaType(area, 'image')(NotImageAreaError.of(`Area with id: ${id} is not image.`))
setImage: function (image) {
const areaChecker = checkAreaType(area, 'image')
areaChecker(NotImageAreaError.of(`Area with id: ${id} is not image.`))

Object.assign(result, {
fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, imageCropParams
})
ProjectData.setAreaImage(area, image)
this.patchProperties.push('screens')
self.patchProperties.push('screens')
return this
},
/**
* Checks if area is `video`, then sets the new video.
* @param {Object} video - The image properties.
* @throws {NotImageAreaError}
*/
setVideo: (video) => {
checkAreaType(area, 'video')(NotVideoAreaError.of(`Area with id: ${id} is not video.`))
setVideo: function (video) {
const areaChecker = checkAreaType(area, 'video')
areaChecker(NotVideoAreaError.of(`Area with id: ${id} is not video.`))

Object.assign(result, {
fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, videoCropParams
})
ProjectData.setAreaVideo(area, video)
this.patchProperties.push('screens')
self.patchProperties.push('screens')
return this
},
/**
* Returns project data instance for further development.
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@renderforest/sdk-node",
"description": "Renderforest SDK for Node.js",
"version": "0.5.1",
"version": "0.5.2",
"author": "RenderForest LLC",
"bugs": {
"url": "https://github.com/renderforest/renderforest-sdk-node/issues"
Expand Down

0 comments on commit 6a3713e

Please sign in to comment.