-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathassignNumbers.ts
33 lines (28 loc) · 1.09 KB
/
assignNumbers.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
import {
getApplicationKeyFromConfig,
getPhoneNumberFromConfig,
initVoiceService,
} from '../../config';
import { Voice } from '@sinch/sdk-core';
(async () => {
console.log('*****************');
console.log('* UpdateNumbers *');
console.log('*****************');
const phoneNumber = getPhoneNumberFromConfig();
const applicationKey = getApplicationKeyFromConfig();
const requestData: Voice.AssignNumbersRequestData = {
assignNumbersRequestBody: {
numbers: [phoneNumber],
applicationkey: applicationKey,
capability: 'voice',
},
};
const voiceService = initVoiceService();
try {
await voiceService.applications.assignNumbers(requestData);
} catch (error) {
console.log(`Impossible to assign the numbers '${requestData.assignNumbersRequestBody?.numbers}' to the application '${requestData.assignNumbersRequestBody?.applicationkey}'`);
throw error;
}
console.log(`The numbers '${requestData.assignNumbersRequestBody?.numbers}' have been assigned to the application '${requestData.assignNumbersRequestBody?.applicationkey}' successfully`);
})();