Skip to content

Commit

Permalink
Merge pull request #178 from renderforest/return-project-data
Browse files Browse the repository at this point in the history
return-project-data
  • Loading branch information
narekhovhannisyan committed Jun 13, 2019
2 parents f219645 + c416941 commit 13e40d3
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 181 deletions.
136 changes: 84 additions & 52 deletions docs/project-data-api/AREAS_API.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
## Areas API
# Areas API

* [Getters](#getters)
## Table of Contents

- [Areas API](#areas-api)
- [Table of Contents](#table-of-contents)
- [Getters](#getters)
- [Get area type](#get-area-type)
- [Get recommended character count](#get-recommended-character-count)
* [Setters](#setters)
- [Setters](#setters)
- [Set text](#set-text)
- [Set text scale](#set-text-scale)
- [Set image](#set-image)
- [Set video](#set-video)
- [Return project data](#return-project-data)
- [Save](#save)

## Getters

### Get area type

Gets area type. Possible values are: `text`, `image`, `video`.
Gets area type. Possible values for area types are: `text`, `image`, `video`.

```js
const secondScreen = projectDataInstance.getScreen(1)
const firstAreaSecondScreen = secondScreen.getArea(0)

firstAreaSecondScreen.getAreaType()
console.log(projectDataInstance.getScreen(1)
.getArea(0)
.getAreaType()
)
```

### Get recommended character count

Gets recommended character count for `text` areas. On other types throws error.

```js
const firstScreen = projectDataInstance.getScreen(0)
const firstAreaFirstScreen = firstScreen.getArea(0)

firstAreaFirstScreen.getRecommendedCharacterCount()
console.log(projectDataInstance.getScreen(1)
.getArea(0)
.getRecommendedCharacterCount()
)
```

## Setters
Expand All @@ -42,10 +48,9 @@ If area is `text`, then sets given value, otherwise throws error.
```js
Renderforest.getProjectData(15220886)
.then((projectDataInstance) => {
const firstScreen = projectDataInstance.getScreen(0)
const firstAreaFirstScreen = firstScreen.getArea(0)

firstAreaFirstScreen.setText('sample-text')
projectDataInstance.getScreen(0)
.getArea(0)
.setText('sample-text')
})
```

Expand All @@ -66,23 +71,22 @@ If area is `image`, then sets given image params, otherwise throws error.
```js
Renderforest.getProjectData(15220886)
.then((projectDataInstance) => {
const secondScreen = projectDataInstance.getScreen(1)
const firstAreaSecondScreen = secondScreen.getArea(0)

firstAreaSecondScreen.setImage({
fileName: 'sample file name', // optional
mime: 'image/png', // optional
filePath: 'https://example.com/sample.png',
webpPath: 'https://example.com/sample.webp', // optional
fileType: 'image', // optional
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
imageCropParams: {
transform: 0,
top: 11,
left: 0,
width: 798,
height: 456
}
projectDataInstance.getScreen(1)
.getArea(0)
.setImage({
fileName: 'sample file name', // optional
mime: 'image/png', // optional
filePath: 'https://example.com/sample.png',
webpPath: 'https://example.com/sample.webp', // optional
fileType: 'image', // optional
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
imageCropParams: {
transform: 0,
top: 11,
left: 0,
width: 798,
height: 456
}
})
})
```
Expand All @@ -94,30 +98,58 @@ If area is `video`, then sets given video params, otherwise throws error.
```js
Renderforest.getProjectData(15220886)
.then((projectDataInstance) => {
const thirdScreen = projectDataInstance.getScreen(2)
const firstAreaThirdScreen = thirdScreen.getArea(0)

firstAreaThirdScreen.setVideo({
fileName: 'sample file name', // optional
mime: 'video/mp4', // optional
filePath: 'https://example.com/sample.png',
webpPath: 'https://example.com/sample.webp', // optional
fileType: 'video', // optional
videoCropParams: {
duration: 6,
mime: 'video/mp4',
thumbnail: 'https://example.com/sample-thumbnail.png',
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
trims: [0, 2, 3, 5],
volume: {
music: 10,
video: 100
projectDataInstance.getScreen(2)
.getArea(0)
.setVideo({
fileName: 'sample file name', // optional
mime: 'video/mp4', // optional
filePath: 'https://example.com/sample.png',
webpPath: 'https://example.com/sample.webp', // optional
fileType: 'video', // optional
videoCropParams: {
duration: 6,
mime: 'video/mp4',
thumbnail: 'https://example.com/sample-thumbnail.png',
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
trims: [0, 2, 3, 5],
volume: {
music: 10,
video: 100
}
}
}
})
})
```

## Return project data

For project data manipulation sometimes there is need to step back from
area object to project data for further development.

```js
projectDataInstance.getScreen(0)
.getArea(1)
.setText('sample-text')
.setTextScale(100)
.returnProjectData()
.getScreen(1)
.getArea(0)
.setText('mock-text')
```

## Save

Save method works with the same logic as the project data one.
From the hood it steps back to project data then calls save method.

```js
projectDataInstance.getScreen(0)
.getArea(1)
.setText('sample-text')
.setTextScale(100)
.save()
```

[See advanced example for areas](/samples/project-data/set-text-image-video.js)

**[⬆ back to the top](#areas-api)**
104 changes: 46 additions & 58 deletions docs/project-data-api/PROJECT_DATA_API.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
## Projects-data API

- [Get Project-data](#get-project-data)
- [Update Project-data](#update-project-data)
* [Getters](#getters)
- [Get project id](#get-project-id)
- [Get template id](#get-template-id)
- [Check if project is Equalizer](#check-if-project-is-equalizer)
- [Check if project is Lego](#check-if-project-is-lego)
- [Get project title](#get-project-title)
- [Get mute music](#get-mute-music)
- [Get project sounds](#get-project-sounds)
- [Get project styles](#get-project-styles)
- [Get project voice over](#get-project-voice-over)
- [Get project fonts](#get-project-fonts)
- [Get project colors](#get-project-colors)
- [Get project duration](#get-project-duration)
- [Get screen](#get-screen)
- [Get screens](#get-screens)
* [Setters](#setters)
- [Set mute music](#set-mute-music)
- [Set project styles](#set-project-styles)
- [Set project voice over](#set-project-voice-over)
- [Set project sounds](#set-project-sounds)
- [Set project colors](#set-project-colors)
- [Set project fonts](#set-project-fonts)
- [Reset project fonts](#reset-project-fonts)
* [Save changes](#save-changes)
# Projects-data API

## Table of Contents

- [Projects-data API](#projects-data-api)
- [Table of Contents](#table-of-contents)
- [Get Project-data](#get-project-data)
- [Getters and Setters of Project-data Instance](#getters-and-setters-of-project-data-instance)
- [Getters](#getters)
- [Get project id](#get-project-id)
- [Get template id](#get-template-id)
- [Check if project is Equalizer](#check-if-project-is-equalizer)
- [Check if project is Lego](#check-if-project-is-lego)
- [Get project title](#get-project-title)
- [Get mute music](#get-mute-music)
- [Get project sounds](#get-project-sounds)
- [Get project styles](#get-project-styles)
- [Get project voice over](#get-project-voice-over)
- [Get project fonts](#get-project-fonts)
- [Get project colors](#get-project-colors)
- [Get project duration](#get-project-duration)
- [Get screen](#get-screen)
- [Get screens](#get-screens)
- [Setters](#setters)
- [Set mute music](#set-mute-music)
- [Set project styles](#set-project-styles)
- [Set project voice over](#set-project-voice-over)
- [Set project sounds](#set-project-sounds)
- [Set project colors](#set-project-colors)
- [Set project fonts](#set-project-fonts)
- [Reset project fonts](#reset-project-fonts)
- [Push screen](#push-screen)
- [Save changes](#save-changes)

### Get Project-data

Expand Down Expand Up @@ -57,36 +62,7 @@ Renderforest.getProjectData(7096113)
})
.catch(console.error) // handle the error
```
[See example](/samples/project-data/get-project-data.js)

### Update project data

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

const Renderforest = new RenderforestClient({ signKey: '<signKey>', clientId: -1 })

Renderforest.getProjectData(7125672)
.then((projectDataInstance) =>
projectDataInstance.setMuteMusic(true)
.setStyles({ theme: '1', transition: '2' })
.setVoiceOver({ path: 'https://example.com/voice-ower.mp3' })
.save()
)
.catch(console.error)
```

- You can update the following list of properties: `currentScreenId, duration, generator, muteMusic, themeVariableName,
themeVariableValue, projectColors, simple, sounds, screens, voiceSoundId`.
- Any top-level properties (writable) can be updated separately (except `themeVariableName` & `themeVariableValue`), as
well as all of them at the same time.
- The `themeVariableName` & `themeVariableValue` are related to the template theme and both should be updated at the same
time. Possible values you can get in the template theme section
(https://developers.renderforest.com/#get-theme-of-the-template).
- The `iconAdjustable` field of the screen takes one of the 0, 1 or 2 values. If iconAdjustable is 0, then the icon is
not adjustable. The value 1 indicates that the icon is on the left side, and the value 2 indicates that the icon is on
the right side. You can update 1 <-> 2 to change the icon from left <-> right.
- No blob data accepted for the value field of a screen area.
[See get project data example](/samples/project-data/get-project-data.js)

### Getters and Setters of Project-data Instance

Expand Down Expand Up @@ -321,6 +297,18 @@ Renderforest.getProjectData(15220886)
.catch(console.error)
```

- You can update the following list of properties: `currentScreenId, duration, generator, muteMusic, themeVariableName,
themeVariableValue, projectColors, simple, sounds, screens, voiceSoundId`.
- Any top-level properties (writable) can be updated separately (except `themeVariableName` & `themeVariableValue`), as
well as all of them at the same time.
- The `themeVariableName` & `themeVariableValue` are related to the template theme and both should be updated at the same
time. Possible values you can get in the template theme section
(https://developers.renderforest.com/#get-theme-of-the-template).
- The `iconAdjustable` field of the screen takes one of the 0, 1 or 2 values. If iconAdjustable is 0, then the icon is
not adjustable. The value 1 indicates that the icon is on the left side, and the value 2 indicates that the icon is on
the right side. You can update 1 <-> 2 to change the icon from left <-> right.
- No blob data accepted for the value field of a screen area.

- [See update project data example](/samples/project-data/update-project-data-partial.js)

**[⬆ back to the top](#projects-data-api)**
Loading

0 comments on commit 13e40d3

Please sign in to comment.