@@ -527,19 +527,20 @@ HttpResponse<String> response=Unirest.post("https://api.amberscript.com/api/jobs
527
527
```
528
528
529
529
```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 ' ;
537
534
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}`;
540
536
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
+ }
543
544
```
544
545
545
546
```python
@@ -604,17 +605,14 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
604
605
```
605
606
606
607
```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' ;
612
610
const apiKey = ' YOUR_API_KEY' ;
613
611
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}`;
615
613
616
614
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' } });
618
616
console. log(response. data);
619
617
} catch (error) {
620
618
console. error(' Error:' , error. response. data)
@@ -751,11 +749,11 @@ HttpResponse<String> response=Unirest.get("https://api.amberscript.com/api/jobs/
751
749
```
752
750
753
751
```javascript
754
- async function exportSTL () {
752
+ async function exportSRT () {
755
753
const jobId = ' JOB_ID' ;
756
754
const apiKey = ' YOUR_API_KEY' ;
757
755
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}`;
759
757
760
758
try {
761
759
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
1084
1082
1085
1083
```javascript
1086
1084
async function deleteJob() {
1087
- const jobId = ' 6638de0ba17717297470040c ' ;
1085
+ const jobId = ' JOB_ID ' ;
1088
1086
const apiKey = ' YOUR_API_KEY' ;
1089
1087
1090
1088
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
1276
1274
```
1277
1275
1278
1276
```javascript
1279
- var request = require( " request " ) ;
1277
+ import fetch from ' node-fetch ' ;
1280
1278
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
+ }) ;
1286
1284
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
+ }
1289
1298
1290
- console. log(body);
1291
- });
1292
1299
```
1293
1300
1294
1301
```python
@@ -1395,41 +1402,44 @@ String body="{\n"+
1395
1402
```
1396
1403
1397
1404
```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
+ };
1417
1424
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
+ };
1427
1430
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
+ });
1430
1434
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
+ }
1433
1443
```
1434
1444
1435
1445
```python
@@ -1561,41 +1571,44 @@ String body="{\n"+
1561
1571
```
1562
1572
1563
1573
```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
+ };
1583
1593
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
+ });
1593
1597
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
+ };
1596
1603
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
+ }
1599
1612
```
1600
1613
1601
1614
```python
@@ -1708,19 +1721,25 @@ HttpResponse<String> response=Unirest.delete("https://api.amberscript.com/api/gl
1708
1721
```
1709
1722
1710
1723
```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
+ });
1718
1729
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
+ };
1721
1734
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
+ }
1724
1743
```
1725
1744
1726
1745
```python
0 commit comments