@@ -527,19 +527,20 @@ HttpResponse<String> response=Unirest.post("https://api.amberscript.com/api/jobs
527527```
528528
529529```javascript
530- var request = require("request");
531-
532- var options = {
533- method: ' POST ' ,
534- url: ' https: // api.amberscript.com/api/jobs/translatedSubtitles',
535- qs: {sourceJobId: ' SOURCE_JOB_ID' , targetLanguage: ' nl' , apiKey: ' YOUR_API_KEY' }
536- };
530+ async function createTranslatedSubtitles() {
531+ const sourceJobId = ' SOURCE_JOB_ID ' ;
532+ const targetLanguage = ' nl' ;
533+ const apiKey = ' YOUR_API_KEY ' ;
537534
538- request(options, function (error, response, body) {
539- if (error) throw new Error (error);
535+ const url = `https://api.amberscript.com/api/jobs/translatedSubtitles?sourceJobId=${sourceJobId}&targetLanguage=${targetLanguage}&apiKey=${apiKey}`;
540536
541- console. log(body);
542- });
537+ try {
538+ const response = await axios.post(url, {}, { headers: { ' content- type' : ' application/ json' } });
539+ console.log(response.data);
540+ } catch (error) {
541+ console.error(' Error : ' , error.response.data)
542+ }
543+ }
543544```
544545
545546```python
@@ -604,17 +605,14 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
604605```
605606
606607```javascript
607- import axios from ' axios' ;
608-
609- async function createTranslatedSubtitles() {
610- const sourceJobId = ' SOURCE_JOB_ID' ;
611- const targetLanguage = ' nl' ;
608+ async function fetchJobStatus() {
609+ const jobId = ' 6638de0ba17717297470040c' ;
612610 const apiKey = ' YOUR_API_KEY' ;
613611
614- const url = `https: // api.amberscript.com/api/jobs/translatedSubtitles?sourceJobId =${sourceJobId}&targetLanguage=${targetLanguage }&apiKey=${apiKey}`;
612+ const url = `https: // api.amberscript.com/api/jobs/status?jobId =${jobId }&apiKey=${apiKey}`;
615613
616614 try {
617- const response = await axios. post (url, {}, { headers: { ' content-type ' : ' application/json' } });
615+ const response = await axios. get (url, { headers: { ' Content-Type ' : ' application/json' } });
618616 console. log(response. data);
619617 } catch (error) {
620618 console. error(' Error:' , error. response. data)
@@ -751,11 +749,11 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
751749```
752750
753751```javascript
754- async function exportSTL () {
752+ async function exportSRT () {
755753 const jobId = ' JOB_ID' ;
756754 const apiKey = ' YOUR_API_KEY' ;
757755
758- const url = `https: // api.amberscript.com/api/jobs/export-stl ?jobId=${jobId}&apiKey=${apiKey}`;
756+ const url = `https: // api.amberscript.com/api/jobs/export-srt ?jobId=${jobId}&apiKey=${apiKey}`;
759757
760758 try {
761759 const response = await axios. get(url, { headers: { ' Content-Type' : ' application/json' } });
@@ -1084,7 +1082,7 @@ HttpResponse<String> response=Unirest.delete("https://api.amberscript.com/api/jo
10841082
10851083```javascript
10861084async function deleteJob() {
1087- const jobId = ' 6638de0ba17717297470040c ' ;
1085+ const jobId = ' JOB_ID ' ;
10881086 const apiKey = ' YOUR_API_KEY' ;
10891087
10901088 const url = `https: // api.amberscript.com/api/jobs?jobId=${jobId}&apiKey=${apiKey}`;
@@ -1276,19 +1274,28 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/gloss
12761274```
12771275
12781276```javascript
1279- var request = require( " request " ) ;
1277+ import fetch from ' node-fetch ' ;
12801278
1281- var options = {
1282- method : ' GET ' ,
1283- url : ' https://api.amberscript.com/api/glossary ' ,
1284- qs : { apiKey: ' YOUR_API_KEY' }
1285- } ;
1279+ async function getGlossary() {
1280+ const url = ' https://api.amberscript.com/api/glossary ' ;
1281+ const queryParams = new URLSearchParams ({
1282+ apiKey: ' YOUR_API_KEY'
1283+ }) ;
12861284
1287- request(options, function (error, response, body) {
1288- if (error) throw new Error (error);
1285+ const options = {
1286+ method: ' GET' ,
1287+ headers: {' Content-Type' : ' application/json' },
1288+ };
1289+
1290+ try {
1291+ const response = await fetch(`${url}? ${queryParams}`, options);
1292+ const data = await response. json();
1293+ console. log(data);
1294+ } catch (error) {
1295+ console. error(' Error:' , error. response. data);
1296+ }
1297+ }
12891298
1290- console. log(body);
1291- });
12921299```
12931300
12941301```python
@@ -1395,41 +1402,44 @@ String body="{\n"+
13951402```
13961403
13971404```javascript
1398- var request = require( " request " );
1399-
1400- var body = {
1401- " name" : " Name of first glossary" ,
1402- " names" : [
1403- " Test name one" ,
1404- " Test name two"
1405- ],
1406- " items" : [
1407- {
1408- " name" : " Item one name" ,
1409- " description" : " description of item one"
1410- },
1411- {
1412- " name" : " Item two name" ,
1413- " description" : " description of item two"
1414- }
1415- ]
1416- }
1405+ async function createGlossary() {
1406+ const url = ' https://api.amberscript.com/api/glossary ' ;
1407+ const body = {
1408+ " name" : " Name of first glossary" ,
1409+ " names" : [
1410+ " Test name one" ,
1411+ " Test name two"
1412+ ],
1413+ " items" : [
1414+ {
1415+ " name" : " Item one name" ,
1416+ " description" : " description of item one"
1417+ },
1418+ {
1419+ " name" : " Item two name" ,
1420+ " description" : " description of item two"
1421+ }
1422+ ]
1423+ };
14171424
1418- var options = {
1419- method: ' POST' ,
1420- url: ' https://api.amberscript.com/api/glossary' ,
1421- headers: {
1422- ' Content-Type' : ' application/json'
1423- },
1424- qs: {apiKey: ' YOUR_API_KEY' },
1425- body: body
1426- };
1425+ const options = {
1426+ method: ' POST' ,
1427+ headers: {' Content-Type' : ' application/json' },
1428+ body: JSON . stringify(body)
1429+ };
14271430
1428- request(options, function (error, response, body) {
1429- if (error) throw new Error (error);
1431+ const queryParams = new URLSearchParams ({
1432+ apiKey: ' YOUR_API_KEY'
1433+ });
14301434
1431- console. log(body);
1432- });
1435+ try {
1436+ const response = await fetch(`${url}? ${queryParams}`, options);
1437+ const data = await response. json();
1438+ console. log(data);
1439+ } catch (error) {
1440+ console. error(' Error:' , error. response. data);
1441+ }
1442+ }
14331443```
14341444
14351445```python
@@ -1561,41 +1571,44 @@ String body="{\n"+
15611571```
15621572
15631573```javascript
1564- var request = require( " request " );
1565-
1566- var body = {
1567- " name" : " Name of first glossary" ,
1568- " names" : [
1569- " Test name one" ,
1570- " Test name two"
1571- ],
1572- " items" : [
1573- {
1574- " name" : " Item one name" ,
1575- " description" : " description of item one"
1576- },
1577- {
1578- " name" : " Item two name" ,
1579- " description" : " description of item two"
1580- }
1581- ]
1582- }
1574+ async function updateGlossary() {
1575+ const url = ' https://api.amberscript.com/api/glossary/GLOSSARY_ID ' ;
1576+ const body = {
1577+ " name" : " Name of first glossary" ,
1578+ " names" : [
1579+ " Test name one" ,
1580+ " Test name two"
1581+ ],
1582+ " items" : [
1583+ {
1584+ " name" : " Item one name" ,
1585+ " description" : " description of item one"
1586+ },
1587+ {
1588+ " name" : " Item two name" ,
1589+ " description" : " description of item two"
1590+ }
1591+ ]
1592+ };
15831593
1584- var options = {
1585- method: ' PUT' ,
1586- url: ' https://api.amberscript.com/api/glossary/GLOSSARY_ID' ,
1587- headers: {
1588- ' Content-Type' : ' application/json'
1589- },
1590- qs: {apiKey: ' YOUR_API_KEY' },
1591- body: body
1592- };
1594+ const queryParams = new URLSearchParams ({
1595+ apiKey: ' YOUR_API_KEY'
1596+ });
15931597
1594- request(options, function (error, response, body) {
1595- if (error) throw new Error (error);
1598+ const options = {
1599+ method: ' PUT' ,
1600+ headers: {' Content-Type' : ' application/json' },
1601+ body: JSON . stringify(body)
1602+ };
15961603
1597- console. log(body);
1598- });
1604+ try {
1605+ const response = await fetch(`${url}? ${queryParams}`, options);
1606+ const data = await response. json();
1607+ console. log(data);
1608+ } catch (error) {
1609+ console. error(' Error:' , error. response. data);
1610+ }
1611+ }
15991612```
16001613
16011614```python
@@ -1708,19 +1721,25 @@ HttpResponse<String> response=Unirest.delete("https://api.amberscript.com/api/gl
17081721```
17091722
17101723```javascript
1711- var request = require(" request" );
1712-
1713- var options = {
1714- method: ' DELETE' ,
1715- url: ' https://api.amberscript.com/api/glossary/GLOSSARY_ID' ,
1716- qs: {apiKey: ' YOUR_API_KEY' }
1717- };
1724+ async function deleteGlossary() {
1725+ const url = ' https://api.amberscript.com/api/glossary/6638e42835d0580edd5e35c2' ;
1726+ const queryParams = new URLSearchParams ({
1727+ apiKey: ' YOUR_API_KEY'
1728+ });
17181729
1719- request(options, function (error, response, body) {
1720- if (error) throw new Error (error);
1730+ const options = {
1731+ method: ' DELETE' ,
1732+ headers: {' Content-Type' : ' application/json' },
1733+ };
17211734
1722- console. log(body);
1723- });
1735+ try {
1736+ const response = await fetch(`${url}? ${queryParams}`, options);
1737+ const data = await response. text();
1738+ console. log(data);
1739+ } catch (error) {
1740+ console. error(' Error:' , error. response. data);
1741+ }
1742+ }
17241743```
17251744
17261745```python
0 commit comments