-
Notifications
You must be signed in to change notification settings - Fork 1
/
unassignNumber.ts
33 lines (28 loc) · 1.09 KB
/
unassignNumber.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('* UnassignNumber *');
console.log('******************');
const phoneNumber = getPhoneNumberFromConfig();
const applicationKey = getApplicationKeyFromConfig();
const requestData: Voice.UnassignNumberRequestData = {
unassignNumbersRequestBody: {
number: phoneNumber,
applicationkey: applicationKey,
capability: 'voice',
},
};
const voiceService = initVoiceService();
try {
await voiceService.applications.unassignNumber(requestData);
} catch (error) {
console.log(`Impossible to unassign the number '${requestData.unassignNumbersRequestBody?.number}' from the application '${requestData.unassignNumbersRequestBody?.applicationkey}'`);
throw error;
}
console.log(`The number '${requestData.unassignNumbersRequestBody?.number}' has been unassigned from the application '${requestData.unassignNumbersRequestBody?.applicationkey}'`);
})();