-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.ts
45 lines (39 loc) · 1.23 KB
/
update.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Fax } from '@sinch/sdk-core';
import {
getFaxCallbackUrlFromConfig,
getFaxServiceIdFromConfig,
getPrintFormat,
initFaxService,
printFullResponse,
} from '../../config';
(async () => {
console.log('*****************');
console.log('* updateService *');
console.log('*****************');
const serviceId = getFaxServiceIdFromConfig();
const webhookUrl = getFaxCallbackUrlFromConfig();
const requestData: Fax.UpdateServiceRequestData = {
serviceId,
updateServiceRequestBody: {
name: 'Updated name with the Node.js SDK',
incomingWebhookUrl: webhookUrl,
webhookContentType: 'application/json',
defaultForProject: true,
imageConversionMethod: 'MONOCHROME',
saveOutboundFaxDocuments: true,
saveInboundFaxDocuments: true,
emailSettings: {
pdfPassword: 'pwd',
useBodyAsCoverPage: true,
},
},
};
const faxService = initFaxService();
const response = await faxService.services.update(requestData);
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`The service with the id '${response.id}' has been updated - New name: ${response.name}`);
} else {
printFullResponse(response);
}
})();