-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget.ts
36 lines (30 loc) · 929 Bytes
/
get.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 {
getPrintFormat,
getBatchIdFromConfig,
printFullResponse,
initSmsServiceWithServicePlanId,
} from '../../config';
import { Sms } from '@sinch/sdk-core';
(async () => {
console.log('*******************');
console.log('* GetBatchMessage *');
console.log('*******************');
const batchId = getBatchIdFromConfig();
const requestData: Sms.GetBatchMessageRequestData= {
batch_id: batchId,
};
const smsService = initSmsServiceWithServicePlanId();
let response;
try {
response = await smsService.batches.get(requestData);
} catch (error) {
console.error(`ERROR: Impossible to retrieve the batch ${requestData.batch_id}`);
throw error;
}
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`Batch ID: ${response.id} - Type: ${response.type} - From: ${response.from}`);
} else {
printFullResponse(response);
}
})();