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