Skip to content

Commit 13e40d3

Browse files
Merge pull request #178 from renderforest/return-project-data
return-project-data
2 parents f219645 + c416941 commit 13e40d3

File tree

9 files changed

+245
-181
lines changed

9 files changed

+245
-181
lines changed

docs/project-data-api/AREAS_API.md

Lines changed: 84 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
1-
## Areas API
1+
# Areas API
22

3-
* [Getters](#getters)
3+
## Table of Contents
4+
5+
- [Areas API](#areas-api)
6+
- [Table of Contents](#table-of-contents)
7+
- [Getters](#getters)
48
- [Get area type](#get-area-type)
59
- [Get recommended character count](#get-recommended-character-count)
6-
* [Setters](#setters)
10+
- [Setters](#setters)
711
- [Set text](#set-text)
812
- [Set text scale](#set-text-scale)
913
- [Set image](#set-image)
1014
- [Set video](#set-video)
15+
- [Return project data](#return-project-data)
16+
- [Save](#save)
1117

1218
## Getters
1319

1420
### Get area type
1521

16-
Gets area type. Possible values are: `text`, `image`, `video`.
22+
Gets area type. Possible values for area types are: `text`, `image`, `video`.
1723

1824
```js
19-
const secondScreen = projectDataInstance.getScreen(1)
20-
const firstAreaSecondScreen = secondScreen.getArea(0)
21-
22-
firstAreaSecondScreen.getAreaType()
25+
console.log(projectDataInstance.getScreen(1)
26+
.getArea(0)
27+
.getAreaType()
28+
)
2329
```
2430

2531
### Get recommended character count
2632

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

2935
```js
30-
const firstScreen = projectDataInstance.getScreen(0)
31-
const firstAreaFirstScreen = firstScreen.getArea(0)
32-
33-
firstAreaFirstScreen.getRecommendedCharacterCount()
36+
console.log(projectDataInstance.getScreen(1)
37+
.getArea(0)
38+
.getRecommendedCharacterCount()
39+
)
3440
```
3541

3642
## Setters
@@ -42,10 +48,9 @@ If area is `text`, then sets given value, otherwise throws error.
4248
```js
4349
Renderforest.getProjectData(15220886)
4450
.then((projectDataInstance) => {
45-
const firstScreen = projectDataInstance.getScreen(0)
46-
const firstAreaFirstScreen = firstScreen.getArea(0)
47-
48-
firstAreaFirstScreen.setText('sample-text')
51+
projectDataInstance.getScreen(0)
52+
.getArea(0)
53+
.setText('sample-text')
4954
})
5055
```
5156

@@ -66,23 +71,22 @@ If area is `image`, then sets given image params, otherwise throws error.
6671
```js
6772
Renderforest.getProjectData(15220886)
6873
.then((projectDataInstance) => {
69-
const secondScreen = projectDataInstance.getScreen(1)
70-
const firstAreaSecondScreen = secondScreen.getArea(0)
71-
72-
firstAreaSecondScreen.setImage({
73-
fileName: 'sample file name', // optional
74-
mime: 'image/png', // optional
75-
filePath: 'https://example.com/sample.png',
76-
webpPath: 'https://example.com/sample.webp', // optional
77-
fileType: 'image', // optional
78-
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
79-
imageCropParams: {
80-
transform: 0,
81-
top: 11,
82-
left: 0,
83-
width: 798,
84-
height: 456
85-
}
74+
projectDataInstance.getScreen(1)
75+
.getArea(0)
76+
.setImage({
77+
fileName: 'sample file name', // optional
78+
mime: 'image/png', // optional
79+
filePath: 'https://example.com/sample.png',
80+
webpPath: 'https://example.com/sample.webp', // optional
81+
fileType: 'image', // optional
82+
thumbnailPath: 'https://example.com/sample-thumbnail.png', // optional
83+
imageCropParams: {
84+
transform: 0,
85+
top: 11,
86+
left: 0,
87+
width: 798,
88+
height: 456
89+
}
8690
})
8791
})
8892
```
@@ -94,30 +98,58 @@ If area is `video`, then sets given video params, otherwise throws error.
9498
```js
9599
Renderforest.getProjectData(15220886)
96100
.then((projectDataInstance) => {
97-
const thirdScreen = projectDataInstance.getScreen(2)
98-
const firstAreaThirdScreen = thirdScreen.getArea(0)
99-
100-
firstAreaThirdScreen.setVideo({
101-
fileName: 'sample file name', // optional
102-
mime: 'video/mp4', // optional
103-
filePath: 'https://example.com/sample.png',
104-
webpPath: 'https://example.com/sample.webp', // optional
105-
fileType: 'video', // optional
106-
videoCropParams: {
107-
duration: 6,
108-
mime: 'video/mp4',
109-
thumbnail: 'https://example.com/sample-thumbnail.png',
110-
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
111-
trims: [0, 2, 3, 5],
112-
volume: {
113-
music: 10,
114-
video: 100
101+
projectDataInstance.getScreen(2)
102+
.getArea(0)
103+
.setVideo({
104+
fileName: 'sample file name', // optional
105+
mime: 'video/mp4', // optional
106+
filePath: 'https://example.com/sample.png',
107+
webpPath: 'https://example.com/sample.webp', // optional
108+
fileType: 'video', // optional
109+
videoCropParams: {
110+
duration: 6,
111+
mime: 'video/mp4',
112+
thumbnail: 'https://example.com/sample-thumbnail.png',
113+
thumbnailVideo: 'https://example.com/sample-thumbnail-video.mp4',
114+
trims: [0, 2, 3, 5],
115+
volume: {
116+
music: 10,
117+
video: 100
118+
}
115119
}
116-
}
117120
})
118121
})
119122
```
120123

124+
## Return project data
125+
126+
For project data manipulation sometimes there is need to step back from
127+
area object to project data for further development.
128+
129+
```js
130+
projectDataInstance.getScreen(0)
131+
.getArea(1)
132+
.setText('sample-text')
133+
.setTextScale(100)
134+
.returnProjectData()
135+
.getScreen(1)
136+
.getArea(0)
137+
.setText('mock-text')
138+
```
139+
140+
## Save
141+
142+
Save method works with the same logic as the project data one.
143+
From the hood it steps back to project data then calls save method.
144+
145+
```js
146+
projectDataInstance.getScreen(0)
147+
.getArea(1)
148+
.setText('sample-text')
149+
.setTextScale(100)
150+
.save()
151+
```
152+
121153
[See advanced example for areas](/samples/project-data/set-text-image-video.js)
122154

123155
**[⬆ back to the top](#areas-api)**

docs/project-data-api/PROJECT_DATA_API.md

Lines changed: 46 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1-
## Projects-data API
2-
3-
- [Get Project-data](#get-project-data)
4-
- [Update Project-data](#update-project-data)
5-
* [Getters](#getters)
6-
- [Get project id](#get-project-id)
7-
- [Get template id](#get-template-id)
8-
- [Check if project is Equalizer](#check-if-project-is-equalizer)
9-
- [Check if project is Lego](#check-if-project-is-lego)
10-
- [Get project title](#get-project-title)
11-
- [Get mute music](#get-mute-music)
12-
- [Get project sounds](#get-project-sounds)
13-
- [Get project styles](#get-project-styles)
14-
- [Get project voice over](#get-project-voice-over)
15-
- [Get project fonts](#get-project-fonts)
16-
- [Get project colors](#get-project-colors)
17-
- [Get project duration](#get-project-duration)
18-
- [Get screen](#get-screen)
19-
- [Get screens](#get-screens)
20-
* [Setters](#setters)
21-
- [Set mute music](#set-mute-music)
22-
- [Set project styles](#set-project-styles)
23-
- [Set project voice over](#set-project-voice-over)
24-
- [Set project sounds](#set-project-sounds)
25-
- [Set project colors](#set-project-colors)
26-
- [Set project fonts](#set-project-fonts)
27-
- [Reset project fonts](#reset-project-fonts)
28-
* [Save changes](#save-changes)
1+
# Projects-data API
2+
3+
## Table of Contents
4+
5+
- [Projects-data API](#projects-data-api)
6+
- [Table of Contents](#table-of-contents)
7+
- [Get Project-data](#get-project-data)
8+
- [Getters and Setters of Project-data Instance](#getters-and-setters-of-project-data-instance)
9+
- [Getters](#getters)
10+
- [Get project id](#get-project-id)
11+
- [Get template id](#get-template-id)
12+
- [Check if project is Equalizer](#check-if-project-is-equalizer)
13+
- [Check if project is Lego](#check-if-project-is-lego)
14+
- [Get project title](#get-project-title)
15+
- [Get mute music](#get-mute-music)
16+
- [Get project sounds](#get-project-sounds)
17+
- [Get project styles](#get-project-styles)
18+
- [Get project voice over](#get-project-voice-over)
19+
- [Get project fonts](#get-project-fonts)
20+
- [Get project colors](#get-project-colors)
21+
- [Get project duration](#get-project-duration)
22+
- [Get screen](#get-screen)
23+
- [Get screens](#get-screens)
24+
- [Setters](#setters)
25+
- [Set mute music](#set-mute-music)
26+
- [Set project styles](#set-project-styles)
27+
- [Set project voice over](#set-project-voice-over)
28+
- [Set project sounds](#set-project-sounds)
29+
- [Set project colors](#set-project-colors)
30+
- [Set project fonts](#set-project-fonts)
31+
- [Reset project fonts](#reset-project-fonts)
32+
- [Push screen](#push-screen)
33+
- [Save changes](#save-changes)
2934

3035
### Get Project-data
3136

@@ -57,36 +62,7 @@ Renderforest.getProjectData(7096113)
5762
})
5863
.catch(console.error) // handle the error
5964
```
60-
[See example](/samples/project-data/get-project-data.js)
61-
62-
### Update project data
63-
64-
```js
65-
const RenderforestClient = require('@renderforest/sdk-node')
66-
67-
const Renderforest = new RenderforestClient({ signKey: '<signKey>', clientId: -1 })
68-
69-
Renderforest.getProjectData(7125672)
70-
.then((projectDataInstance) =>
71-
projectDataInstance.setMuteMusic(true)
72-
.setStyles({ theme: '1', transition: '2' })
73-
.setVoiceOver({ path: 'https://example.com/voice-ower.mp3' })
74-
.save()
75-
)
76-
.catch(console.error)
77-
```
78-
79-
- You can update the following list of properties: `currentScreenId, duration, generator, muteMusic, themeVariableName,
80-
themeVariableValue, projectColors, simple, sounds, screens, voiceSoundId`.
81-
- Any top-level properties (writable) can be updated separately (except `themeVariableName` & `themeVariableValue`), as
82-
well as all of them at the same time.
83-
- The `themeVariableName` & `themeVariableValue` are related to the template theme and both should be updated at the same
84-
time. Possible values you can get in the template theme section
85-
(https://developers.renderforest.com/#get-theme-of-the-template).
86-
- The `iconAdjustable` field of the screen takes one of the 0, 1 or 2 values. If iconAdjustable is 0, then the icon is
87-
not adjustable. The value 1 indicates that the icon is on the left side, and the value 2 indicates that the icon is on
88-
the right side. You can update 1 <-> 2 to change the icon from left <-> right.
89-
- No blob data accepted for the value field of a screen area.
65+
[See get project data example](/samples/project-data/get-project-data.js)
9066

9167
### Getters and Setters of Project-data Instance
9268

@@ -321,6 +297,18 @@ Renderforest.getProjectData(15220886)
321297
.catch(console.error)
322298
```
323299

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

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

0 commit comments

Comments
 (0)