-
Notifications
You must be signed in to change notification settings - Fork 1
/
getCallbackURLs.ts
36 lines (30 loc) · 1.05 KB
/
getCallbackURLs.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 {
getApplicationKeyFromConfig,
getPrintFormat,
initVoiceService,
printFullResponse,
} from '../../config';
import { Voice } from '@sinch/sdk-core';
(async () => {
console.log('*******************');
console.log('* GetCallbackURLs *');
console.log('*******************');
const applicationKey = getApplicationKeyFromConfig();
const requestData: Voice.GetCallbackURLsRequestData = {
applicationkey: applicationKey,
};
const voiceService = initVoiceService();
let response;
try {
response = await voiceService.applications.getCallbackURLs(requestData);
} catch (error) {
console.log(`Impossible to retrieve the callback URLs for the application '${requestData.applicationkey}'`);
throw error;
}
const printFormat = getPrintFormat(process.argv);
if (printFormat === 'pretty') {
console.log(`The primary callback URL is [${response.url?.primary}]. ${response.url?.fallback ? 'The fallback URL is [' + response.url.fallback + ']' : 'There is no fallback URL'}`);
} else {
printFullResponse(response);
}
})();