-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcancel.ts
36 lines (30 loc) · 961 Bytes
/
cancel.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
import {
getBatchIdFromConfig,
getPrintFormat,
initSmsServiceWithServicePlanId,
printFullResponse,
} from '../../config';
import { Sms } from '@sinch/sdk-core';
(async () => {
console.log('**********************');
console.log('* CancelBatchMessage *');
console.log('**********************');
const batchIdInTheFuture = getBatchIdFromConfig();
const requestData: Sms.CancelBatchMessageRequestData= {
batch_id: batchIdInTheFuture,
};
const smsService = initSmsServiceWithServicePlanId();
let response;
try {
response = await smsService.batches.cancel(requestData);
} catch (error) {
console.error(`ERROR: The batch could not be canceled`);
throw error;
}
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`The batch has been canceled successfully. Here is the boolean 'canceled': ${response.canceled}`);
} else {
printFullResponse(response);
}
})();