Skip to content

Commit 07b36a2

Browse files
committed
Simplify and fix doc examples
1 parent 0cd94a6 commit 07b36a2

1 file changed

Lines changed: 8 additions & 66 deletions

File tree

‎README.md‎

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ For examples of how to use the SDK to create videos using code checkout the Node
4949
- [QueuedResponseData](#queuedresponsedata)
5050
- [RenderResponse](#renderresponse)
5151
- [RenderResponseData](#renderresponsedata)
52-
- [Status Check Example](#status-check-example-1)
5352
- [Inspecting Media](#inspecting-media)
5453
- [Probe Example](#probe-example)
5554
- [Probe Schemas](#probe-schemas)
@@ -119,11 +118,7 @@ edit
119118
.setOutput(output);
120119

121120
api.postRender(edit).then((data) => {
122-
let message = data.response.message;
123-
let id = data.response.id
124-
125-
console.log(message + '\n');
126-
console.log('>> Render ID ' + id);
121+
console.log(data.response.id);
127122
});
128123
```
129124

@@ -143,20 +138,11 @@ DeveloperKey.apiKey = 'H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD'; // use the cor
143138

144139
const api = new Shotstack.EditApi();
145140

146-
const id = "75143ec6-4b72-46f8-a67a-fd7284546935"; //use a valid render id
141+
const id = "75143ec6-4b72-46f8-a67a-fd7284546935"; // use the render id from previous example
147142

148143
api.getRender(id, { data: false, merged: true }).then((data) => {
149-
let status = data.response.status;
150-
let url = data.response.url;
151-
152-
console.log('Status: ' + status.toUpperCase() + '\n');
153-
154-
if (status == 'done') {
155-
console.log('>> Asset URL: ' + url);
156-
} else if (status == 'failed') {
157-
console.log('>> Something went wrong, rendering has terminated and will not continue.');
158-
} else {
159-
console.log('>> Rendering in progress, please try again shortly.\n>> Note: Rendering may take up to 1 minute to complete.');
144+
if (data.response.status === 'done') {
145+
console.log(data.response.url);
160146
}
161147
});
162148
```
@@ -940,40 +926,6 @@ getCreated(): string | The time the render task was initially queued. | Y
940926
getUpdated(): string | The time the render status was last updated. | Y
941927
942928
---
943-
944-
### Status Check Example
945-
946-
The example request below can be called a few seconds after the render above is posted. It will return the status of
947-
the render, which can take several seconds to process.
948-
949-
```javascript
950-
const Shotstack = require('shotstack-sdk');
951-
952-
const defaultClient = Shotstack.ApiClient.instance;
953-
defaultClient.basePath = 'https://api.shotstack.io/stage';
954-
955-
const DeveloperKey = defaultClient.authentications['DeveloperKey'];
956-
DeveloperKey.apiKey = 'H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD'; // use the correct API key
957-
958-
const api = new Shotstack.EditApi();
959-
960-
const id = "75143ec6-4b72-46f8-a67a-fd7284546935"; //use a valid render id
961-
962-
api.getRender(id, { data: false, merged: true }).then((data) => {
963-
let status = data.response.status;
964-
let url = data.response.url;
965-
966-
console.log('Status: ' + status.toUpperCase() + '\n');
967-
968-
if (status == 'done') {
969-
console.log('>> Asset URL: ' + url);
970-
} else if (status == 'failed') {
971-
console.log('>> Something went wrong, rendering has terminated and will not continue.');
972-
} else {
973-
console.log('>> Rendering in progress, please try again shortly.\n>> Note: Rendering may take up to 1 minute to complete.');
974-
}
975-
});
976-
```
977929
## Inspecting Media
978930
979931
The SDK `probe` endpoint can be used to inspect media hosted online. Simply pass the URL of an asset to inspect.
@@ -1042,18 +994,13 @@ defaultClient.basePath = 'https://api.shotstack.io/stage';
1042994
const DeveloperKey = defaultClient.authentications['DeveloperKey'];
1043995
DeveloperKey.apiKey = 'H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD'; // use the correct API key
1044996

1045-
const api = new Shotstack.EditApi();
997+
const api = new Shotstack.ServeApi();
1046998

1047999
const id = '140924c6-077d-4334-a89f-94befcfc0155'; // Use a valid render ID
10481000

10491001
api.getAssetByRenderId(id).then((assets) => {
10501002
assets.data.forEach((asset) => {
1051-
const status = asset.attributes.status;
1052-
console.log('Status: ' + status.toUpperCase() + '\n');
1053-
1054-
if (status == 'failed') {
1055-
console.log('>> Something went wrong, asset could not be copied.');
1056-
} else {
1003+
if (asset.attributes.status === 'ready') {
10571004
console.log('>> Asset CDN URL: ' + asset.attributes.url);
10581005
console.log('>> Asset ID: ' + asset.attributes.id);
10591006
console.log('>> Render ID: ' + asset.attributes.renderId);
@@ -1075,17 +1022,12 @@ defaultClient.basePath = 'https://api.shotstack.io/stage';
10751022
const DeveloperKey = defaultClient.authentications['DeveloperKey'];
10761023
DeveloperKey.apiKey = 'H7jKyj90kd09lbLOF7J900jNbSWS67X87xs9j0cD'; // use the correct API key
10771024

1078-
const api = new Shotstack.EditApi();
1025+
const api = new Shotstack.ServeApi();
10791026

10801027
const id = 'ed43eae3-4825-4c03-979d-f7dc47b9997c'; // use a valid asset ID
10811028

10821029
api.getAsset(id).then((asset) => {
1083-
const status = asset.data.attributes.status;
1084-
console.log('Status: ' + status.toUpperCase() + '\n');
1085-
1086-
if (status == 'failed') {
1087-
console.log('>> Something went wrong, asset could not be copied.');
1088-
} else {
1030+
if (asset.data.attributes.status === 'ready') {
10891031
console.log('>> Asset CDN URL: ' + asset.data.attributes.url);
10901032
console.log('>> Asset ID: ' + asset.data.attributes.id);
10911033
console.log('>> Render ID: ' + asset.data.attributes.renderId);

0 commit comments

Comments
 (0)