@webex/calling 3.0.0-next.2 → 3.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1403 -0
- package/README.md +74 -74
- package/dist/module/CallHistory/CallHistory.js +81 -81
- package/dist/module/CallHistory/callHistoryFixtures.js +307 -307
- package/dist/module/CallHistory/constants.js +9 -9
- package/dist/module/CallHistory/types.js +1 -1
- package/dist/module/CallSettings/CallSettings.js +65 -65
- package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
- package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
- package/dist/module/CallSettings/constants.js +11 -11
- package/dist/module/CallSettings/testFixtures.js +62 -62
- package/dist/module/CallSettings/types.js +1 -1
- package/dist/module/CallingClient/CallingClient.js +248 -248
- package/dist/module/CallingClient/callRecordFixtures.js +93 -93
- package/dist/module/CallingClient/calling/CallerId/index.js +169 -169
- package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
- package/dist/module/CallingClient/calling/call.js +1658 -1658
- package/dist/module/CallingClient/calling/callManager.js +284 -284
- package/dist/module/CallingClient/calling/index.js +2 -2
- package/dist/module/CallingClient/calling/types.js +53 -53
- package/dist/module/CallingClient/callingClientFixtures.js +38 -38
- package/dist/module/CallingClient/constants.js +122 -122
- package/dist/module/CallingClient/line/index.js +158 -158
- package/dist/module/CallingClient/line/types.js +15 -15
- package/dist/module/CallingClient/registration/index.js +1 -1
- package/dist/module/CallingClient/registration/register.js +507 -507
- package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
- package/dist/module/CallingClient/registration/types.js +1 -1
- package/dist/module/CallingClient/types.js +1 -1
- package/dist/module/Contacts/ContactsClient.js +484 -484
- package/dist/module/Contacts/constants.js +20 -20
- package/dist/module/Contacts/contactFixtures.js +284 -284
- package/dist/module/Contacts/types.js +10 -10
- package/dist/module/Errors/catalog/CallError.js +26 -26
- package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
- package/dist/module/Errors/catalog/ExtendedError.js +10 -10
- package/dist/module/Errors/catalog/LineError.js +24 -24
- package/dist/module/Errors/index.js +2 -2
- package/dist/module/Errors/types.js +48 -48
- package/dist/module/Events/impl/index.js +19 -19
- package/dist/module/Events/types.js +83 -83
- package/dist/module/Logger/index.js +114 -114
- package/dist/module/Logger/types.js +25 -25
- package/dist/module/Metrics/index.js +232 -232
- package/dist/module/Metrics/types.js +37 -37
- package/dist/module/SDKConnector/index.js +39 -39
- package/dist/module/SDKConnector/types.js +1 -1
- package/dist/module/SDKConnector/utils.js +12 -12
- package/dist/module/Voicemail/BroadworksBackendConnector.js +291 -291
- package/dist/module/Voicemail/UcmBackendConnector.js +279 -279
- package/dist/module/Voicemail/Voicemail.js +110 -110
- package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
- package/dist/module/Voicemail/constants.js +29 -29
- package/dist/module/Voicemail/types.js +1 -1
- package/dist/module/Voicemail/voicemailFixture.js +510 -510
- package/dist/module/api.js +6 -6
- package/dist/module/common/Utils.js +802 -802
- package/dist/module/common/constants.js +41 -41
- package/dist/module/common/index.js +1 -1
- package/dist/module/common/testUtil.js +938 -938
- package/dist/module/common/types.js +57 -57
- package/dist/module/index.js +8 -8
- package/dist/types/CallHistory/CallHistory.d.ts +17 -17
- package/dist/types/CallHistory/callHistoryFixtures.d.ts +94 -94
- package/dist/types/CallHistory/constants.d.ts +9 -9
- package/dist/types/CallHistory/types.d.ts +18 -18
- package/dist/types/CallSettings/CallSettings.d.ts +19 -19
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
- package/dist/types/CallSettings/constants.d.ts +11 -11
- package/dist/types/CallSettings/testFixtures.d.ts +15 -15
- package/dist/types/CallSettings/types.d.ts +107 -107
- package/dist/types/CallingClient/CallingClient.d.ts +35 -35
- package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
- package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
- package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
- package/dist/types/CallingClient/calling/call.d.ts +96 -96
- package/dist/types/CallingClient/calling/callManager.d.ts +25 -25
- package/dist/types/CallingClient/calling/index.d.ts +2 -2
- package/dist/types/CallingClient/calling/types.d.ts +206 -206
- package/dist/types/CallingClient/callingClientFixtures.d.ts +18 -18
- package/dist/types/CallingClient/constants.d.ts +122 -122
- package/dist/types/CallingClient/line/index.d.ts +43 -43
- package/dist/types/CallingClient/line/types.d.ts +55 -55
- package/dist/types/CallingClient/registration/index.d.ts +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +64 -64
- package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
- package/dist/types/CallingClient/registration/types.d.ts +20 -20
- package/dist/types/CallingClient/types.d.ts +29 -29
- package/dist/types/Contacts/ContactsClient.d.ts +26 -26
- package/dist/types/Contacts/constants.d.ts +19 -19
- package/dist/types/Contacts/contactFixtures.d.ts +280 -280
- package/dist/types/Contacts/types.d.ts +72 -72
- package/dist/types/Errors/catalog/CallError.d.ts +11 -11
- package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
- package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
- package/dist/types/Errors/catalog/LineError.d.ts +10 -10
- package/dist/types/Errors/index.d.ts +2 -2
- package/dist/types/Errors/types.d.ts +60 -60
- package/dist/types/Events/impl/index.d.ts +8 -8
- package/dist/types/Events/types.d.ts +288 -288
- package/dist/types/Logger/index.d.ts +12 -12
- package/dist/types/Logger/types.d.ts +25 -25
- package/dist/types/Metrics/index.d.ts +5 -5
- package/dist/types/Metrics/types.d.ts +42 -42
- package/dist/types/SDKConnector/index.d.ts +12 -12
- package/dist/types/SDKConnector/types.d.ts +128 -128
- package/dist/types/SDKConnector/utils.d.ts +5 -5
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
- package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
- package/dist/types/Voicemail/Voicemail.d.ts +27 -27
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
- package/dist/types/Voicemail/constants.d.ts +29 -29
- package/dist/types/Voicemail/types.d.ts +133 -133
- package/dist/types/Voicemail/voicemailFixture.d.ts +417 -417
- package/dist/types/api.d.ts +16 -16
- package/dist/types/common/Utils.d.ts +34 -34
- package/dist/types/common/constants.d.ts +41 -41
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/common/testUtil.d.ts +3611 -3611
- package/dist/types/common/types.d.ts +191 -191
- package/dist/types/index.d.ts +8 -8
- package/package.json +4 -4
- package/dist/CallHistory/CallHistory.js +0 -203
- package/dist/CallHistory/CallHistory.js.map +0 -1
- package/dist/CallHistory/CallHistory.test.js +0 -133
- package/dist/CallHistory/CallHistory.test.js.map +0 -1
- package/dist/CallHistory/callHistoryFixtures.js +0 -310
- package/dist/CallHistory/callHistoryFixtures.js.map +0 -1
- package/dist/CallHistory/constants.js +0 -26
- package/dist/CallHistory/constants.js.map +0 -1
- package/dist/CallHistory/types.js +0 -7
- package/dist/CallHistory/types.js.map +0 -1
- package/dist/CallSettings/CallSettings.js +0 -276
- package/dist/CallSettings/CallSettings.js.map +0 -1
- package/dist/CallSettings/CallSettings.test.js +0 -122
- package/dist/CallSettings/CallSettings.test.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.js +0 -217
- package/dist/CallSettings/UcmBackendConnector.js.map +0 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +0 -227
- package/dist/CallSettings/UcmBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.js +0 -541
- package/dist/CallSettings/WxCallBackendConnector.js.map +0 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +0 -802
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +0 -1
- package/dist/CallSettings/constants.js +0 -30
- package/dist/CallSettings/constants.js.map +0 -1
- package/dist/CallSettings/testFixtures.js +0 -72
- package/dist/CallSettings/testFixtures.js.map +0 -1
- package/dist/CallSettings/types.js +0 -7
- package/dist/CallSettings/types.js.map +0 -1
- package/dist/CallingClient/CallingClient.js +0 -572
- package/dist/CallingClient/CallingClient.js.map +0 -1
- package/dist/CallingClient/CallingClient.test.js +0 -931
- package/dist/CallingClient/CallingClient.test.js.map +0 -1
- package/dist/CallingClient/callRecordFixtures.js +0 -103
- package/dist/CallingClient/callRecordFixtures.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.js +0 -287
- package/dist/CallingClient/calling/CallerId/index.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +0 -274
- package/dist/CallingClient/calling/CallerId/index.test.js.map +0 -1
- package/dist/CallingClient/calling/CallerId/types.js +0 -7
- package/dist/CallingClient/calling/CallerId/types.js.map +0 -1
- package/dist/CallingClient/calling/call.js +0 -2995
- package/dist/CallingClient/calling/call.js.map +0 -1
- package/dist/CallingClient/calling/call.test.js +0 -2614
- package/dist/CallingClient/calling/call.test.js.map +0 -1
- package/dist/CallingClient/calling/callManager.js +0 -443
- package/dist/CallingClient/calling/callManager.js.map +0 -1
- package/dist/CallingClient/calling/callManager.test.js +0 -683
- package/dist/CallingClient/calling/callManager.test.js.map +0 -1
- package/dist/CallingClient/calling/index.js +0 -30
- package/dist/CallingClient/calling/index.js.map +0 -1
- package/dist/CallingClient/calling/types.js +0 -71
- package/dist/CallingClient/calling/types.js.map +0 -1
- package/dist/CallingClient/callingClientFixtures.js +0 -53
- package/dist/CallingClient/callingClientFixtures.js.map +0 -1
- package/dist/CallingClient/constants.js +0 -226
- package/dist/CallingClient/constants.js.map +0 -1
- package/dist/CallingClient/line/index.js +0 -312
- package/dist/CallingClient/line/index.js.map +0 -1
- package/dist/CallingClient/line/line.test.js +0 -270
- package/dist/CallingClient/line/line.test.js.map +0 -1
- package/dist/CallingClient/line/types.js +0 -25
- package/dist/CallingClient/line/types.js.map +0 -1
- package/dist/CallingClient/registration/index.js +0 -19
- package/dist/CallingClient/registration/index.js.map +0 -1
- package/dist/CallingClient/registration/register.js +0 -1295
- package/dist/CallingClient/registration/register.js.map +0 -1
- package/dist/CallingClient/registration/register.test.js +0 -838
- package/dist/CallingClient/registration/register.test.js.map +0 -1
- package/dist/CallingClient/registration/registerFixtures.js +0 -41
- package/dist/CallingClient/registration/registerFixtures.js.map +0 -1
- package/dist/CallingClient/registration/types.js +0 -7
- package/dist/CallingClient/registration/types.js.map +0 -1
- package/dist/CallingClient/types.js +0 -7
- package/dist/CallingClient/types.js.map +0 -1
- package/dist/Contacts/ContactsClient.js +0 -1139
- package/dist/Contacts/ContactsClient.js.map +0 -1
- package/dist/Contacts/ContactsClient.test.js +0 -725
- package/dist/Contacts/ContactsClient.test.js.map +0 -1
- package/dist/Contacts/constants.js +0 -36
- package/dist/Contacts/constants.js.map +0 -1
- package/dist/Contacts/contactFixtures.js +0 -340
- package/dist/Contacts/contactFixtures.js.map +0 -1
- package/dist/Contacts/types.js +0 -20
- package/dist/Contacts/types.js.map +0 -1
- package/dist/Errors/catalog/CallError.js +0 -94
- package/dist/Errors/catalog/CallError.js.map +0 -1
- package/dist/Errors/catalog/CallingDeviceError.js +0 -88
- package/dist/Errors/catalog/CallingDeviceError.js.map +0 -1
- package/dist/Errors/catalog/ExtendedError.js +0 -45
- package/dist/Errors/catalog/ExtendedError.js.map +0 -1
- package/dist/Errors/catalog/LineError.js +0 -90
- package/dist/Errors/catalog/LineError.js.map +0 -1
- package/dist/Errors/index.js +0 -21
- package/dist/Errors/index.js.map +0 -1
- package/dist/Errors/types.js +0 -62
- package/dist/Errors/types.js.map +0 -1
- package/dist/Events/impl/index.js +0 -82
- package/dist/Events/impl/index.js.map +0 -1
- package/dist/Events/types.js +0 -111
- package/dist/Events/types.js.map +0 -1
- package/dist/Logger/index.js +0 -221
- package/dist/Logger/index.js.map +0 -1
- package/dist/Logger/index.test.js +0 -62
- package/dist/Logger/index.test.js.map +0 -1
- package/dist/Logger/types.js +0 -37
- package/dist/Logger/types.js.map +0 -1
- package/dist/Metrics/index.js +0 -329
- package/dist/Metrics/index.js.map +0 -1
- package/dist/Metrics/index.test.js +0 -291
- package/dist/Metrics/index.test.js.map +0 -1
- package/dist/Metrics/types.js +0 -50
- package/dist/Metrics/types.js.map +0 -1
- package/dist/SDKConnector/index.js +0 -105
- package/dist/SDKConnector/index.js.map +0 -1
- package/dist/SDKConnector/index.test.js +0 -9
- package/dist/SDKConnector/index.test.js.map +0 -1
- package/dist/SDKConnector/types.js +0 -7
- package/dist/SDKConnector/types.js.map +0 -1
- package/dist/SDKConnector/utils.js +0 -40
- package/dist/SDKConnector/utils.js.map +0 -1
- package/dist/SDKConnector/utils.test.js +0 -9
- package/dist/SDKConnector/utils.test.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +0 -632
- package/dist/Voicemail/BroadworksBackendConnector.js.map +0 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +0 -733
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.js +0 -566
- package/dist/Voicemail/UcmBackendConnector.js.map +0 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +0 -628
- package/dist/Voicemail/UcmBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/Voicemail.js +0 -378
- package/dist/Voicemail/Voicemail.js.map +0 -1
- package/dist/Voicemail/Voicemail.test.js +0 -226
- package/dist/Voicemail/Voicemail.test.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.js +0 -540
- package/dist/Voicemail/WxCallBackendConnector.js.map +0 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +0 -942
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +0 -1
- package/dist/Voicemail/constants.js +0 -66
- package/dist/Voicemail/constants.js.map +0 -1
- package/dist/Voicemail/types.js +0 -7
- package/dist/Voicemail/types.js.map +0 -1
- package/dist/Voicemail/voicemailFixture.js +0 -559
- package/dist/Voicemail/voicemailFixture.js.map +0 -1
- package/dist/api.js +0 -134
- package/dist/api.js.map +0 -1
- package/dist/common/Utils.js +0 -1264
- package/dist/common/Utils.js.map +0 -1
- package/dist/common/Utils.test.js +0 -1227
- package/dist/common/Utils.test.js.map +0 -1
- package/dist/common/constants.js +0 -90
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.js +0 -19
- package/dist/common/index.js.map +0 -1
- package/dist/common/testUtil.js +0 -968
- package/dist/common/testUtil.js.map +0 -1
- package/dist/common/types.js +0 -75
- package/dist/common/types.js.map +0 -1
- package/dist/index.js +0 -63
- package/dist/index.js.map +0 -1
|
@@ -1,291 +1,291 @@
|
|
|
1
|
-
import { ERROR_CODE } from '../Errors/types';
|
|
2
|
-
import SDKConnector from '../SDKConnector';
|
|
3
|
-
import { BASE64, BEARER, BINARY, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, OBJECT, TOKEN, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, } from '../common/constants';
|
|
4
|
-
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
|
|
5
|
-
import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
|
|
6
|
-
import log from '../Logger';
|
|
7
|
-
import { BROADWORKS_VOICEMAIL_FILE, BW_TOKEN_FETCH_ENDPOINT, JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, } from './constants';
|
|
8
|
-
export class BroadworksBackendConnector {
|
|
9
|
-
bwtoken;
|
|
10
|
-
userId;
|
|
11
|
-
xsiAccessToken;
|
|
12
|
-
xsiEndpoint;
|
|
13
|
-
context;
|
|
14
|
-
sdkConnector;
|
|
15
|
-
webex;
|
|
16
|
-
xsiVoiceMessageURI;
|
|
17
|
-
constructor(webex, logger) {
|
|
18
|
-
this.sdkConnector = SDKConnector;
|
|
19
|
-
if (!this.sdkConnector.getWebex()) {
|
|
20
|
-
SDKConnector.setWebex(webex);
|
|
21
|
-
}
|
|
22
|
-
this.webex = this.sdkConnector.getWebex();
|
|
23
|
-
this.context = Math.random().toString(RADIX_RAND).substring(PREFIX);
|
|
24
|
-
log.setLogger(logger.level, BROADWORKS_VOICEMAIL_FILE);
|
|
25
|
-
}
|
|
26
|
-
init() {
|
|
27
|
-
const loggerContext = {
|
|
28
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
29
|
-
method: 'init',
|
|
30
|
-
};
|
|
31
|
-
log.info('Initializing Broadworks voicemail connector', loggerContext);
|
|
32
|
-
const response = this.setXsiVoiceMessageURI();
|
|
33
|
-
return response;
|
|
34
|
-
}
|
|
35
|
-
getSDKConnector() {
|
|
36
|
-
return this.sdkConnector;
|
|
37
|
-
}
|
|
38
|
-
async getUserId() {
|
|
39
|
-
const loggerContext = {
|
|
40
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
41
|
-
method: 'getUserId',
|
|
42
|
-
};
|
|
43
|
-
try {
|
|
44
|
-
await this.getBwToken();
|
|
45
|
-
if (this.bwtoken && this.bwtoken.split('.').length > 1) {
|
|
46
|
-
const decodedString = Buffer.from(this.bwtoken.split('.')[1], BASE64).toString(BINARY);
|
|
47
|
-
this.userId = JSON.parse(decodedString).sub;
|
|
48
|
-
return this.userId;
|
|
49
|
-
}
|
|
50
|
-
const error = ERROR_CODE.UNAUTHORIZED;
|
|
51
|
-
throw new Error(`${error}`);
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
const errorInfo = {
|
|
55
|
-
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
56
|
-
};
|
|
57
|
-
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async getBwToken() {
|
|
61
|
-
try {
|
|
62
|
-
const bwTokenResponse = await this.webex.request({
|
|
63
|
-
uri: `${this.webex.internal.services._serviceUrls.broadworksIdpProxy}${BW_TOKEN_FETCH_ENDPOINT}`,
|
|
64
|
-
method: HTTP_METHODS.GET,
|
|
65
|
-
});
|
|
66
|
-
const response = bwTokenResponse.body;
|
|
67
|
-
this.bwtoken = response[TOKEN][BEARER];
|
|
68
|
-
}
|
|
69
|
-
catch (err) {
|
|
70
|
-
log.info(`Broadworks token exception ${err}`, {});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
async setXsiVoiceMessageURI() {
|
|
74
|
-
const loggerContext = {
|
|
75
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
76
|
-
method: 'setXsiVoiceMessageURI',
|
|
77
|
-
};
|
|
78
|
-
let userIdResponse = await this.getUserId();
|
|
79
|
-
this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.BWRKS);
|
|
80
|
-
this.xsiAccessToken = `${BEARER} ${this.bwtoken}`;
|
|
81
|
-
log.info(`XsiEndpoint is ${this.xsiEndpoint}`, loggerContext);
|
|
82
|
-
if (userIdResponse && typeof userIdResponse !== OBJECT) {
|
|
83
|
-
this.xsiVoiceMessageURI = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${userIdResponse}/${VOICE_MESSAGING_MESSAGES}`;
|
|
84
|
-
userIdResponse = {
|
|
85
|
-
statusCode: SUCCESS_STATUS_CODE,
|
|
86
|
-
data: {},
|
|
87
|
-
message: SUCCESS_MESSAGE,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return userIdResponse;
|
|
91
|
-
}
|
|
92
|
-
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
93
|
-
const loggerContext = {
|
|
94
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
95
|
-
method: 'getVoicemailList',
|
|
96
|
-
};
|
|
97
|
-
log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
|
|
98
|
-
const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
|
|
99
|
-
let messageinfo;
|
|
100
|
-
const sortParam = Object.values(SORT).includes(sort) ? sort : SORT.DEFAULT;
|
|
101
|
-
if (refresh) {
|
|
102
|
-
try {
|
|
103
|
-
const response = await fetch(`${urlXsi}`, {
|
|
104
|
-
method: HTTP_METHODS.GET,
|
|
105
|
-
headers: {
|
|
106
|
-
Authorization: this.xsiAccessToken,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
if (!response.ok) {
|
|
110
|
-
throw new Error(`${response.status}`);
|
|
111
|
-
}
|
|
112
|
-
const voicemailListResponse = (await response.json());
|
|
113
|
-
if (Object.keys(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList).length === 0) {
|
|
114
|
-
messageinfo = [];
|
|
115
|
-
}
|
|
116
|
-
else if (!Array.isArray(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList?.messageInfo)) {
|
|
117
|
-
messageinfo = Array(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList?.messageInfo);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
messageinfo = voicemailListResponse?.VoiceMessagingMessages?.messageInfoList
|
|
121
|
-
?.messageInfo;
|
|
122
|
-
messageinfo = getSortedVoicemailList(messageinfo, sortParam);
|
|
123
|
-
}
|
|
124
|
-
storeVoicemailList(this.context, messageinfo);
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
const errorInfo = {
|
|
128
|
-
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
129
|
-
};
|
|
130
|
-
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
131
|
-
return errorStatus;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const { messages, moreVMAvailable } = fetchVoicemailList(this.context, offset, offsetLimit, loggerContext);
|
|
135
|
-
const responseDetails = {
|
|
136
|
-
statusCode: moreVMAvailable ? SUCCESS_STATUS_CODE : NO_VOICEMAIL_STATUS_CODE,
|
|
137
|
-
data: {
|
|
138
|
-
voicemailList: messages,
|
|
139
|
-
},
|
|
140
|
-
message: moreVMAvailable ? SUCCESS_MESSAGE : NO_VOICEMAIL_MSG,
|
|
141
|
-
};
|
|
142
|
-
return responseDetails;
|
|
143
|
-
}
|
|
144
|
-
async getVoicemailContent(messageId) {
|
|
145
|
-
const loggerContext = {
|
|
146
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
147
|
-
method: 'getVoicemailContent',
|
|
148
|
-
};
|
|
149
|
-
try {
|
|
150
|
-
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
151
|
-
const response = await fetch(`${voicemailContentUrl}`, {
|
|
152
|
-
method: 'GET',
|
|
153
|
-
headers: {
|
|
154
|
-
Authorization: this.xsiAccessToken,
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
if (!response.ok) {
|
|
158
|
-
throw new Error(`${response.status}`);
|
|
159
|
-
}
|
|
160
|
-
const xmlData = await response.text();
|
|
161
|
-
const parser = new DOMParser();
|
|
162
|
-
const xmlDOM = parser.parseFromString(xmlData, XML_TYPE);
|
|
163
|
-
const mediaDetails = xmlDOM.getElementsByTagName(MESSAGE_MEDIA_CONTENT)[0];
|
|
164
|
-
const mediaType = mediaDetails.childNodes[1]?.textContent;
|
|
165
|
-
const mediaContent = mediaDetails.childNodes[2]?.textContent;
|
|
166
|
-
log.info(`Media type is ${mediaType}`, loggerContext);
|
|
167
|
-
const responseDetails = {
|
|
168
|
-
statusCode: response?.status,
|
|
169
|
-
data: {
|
|
170
|
-
voicemailContent: {
|
|
171
|
-
type: mediaType,
|
|
172
|
-
content: mediaContent,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
message: SUCCESS_MESSAGE,
|
|
176
|
-
};
|
|
177
|
-
return responseDetails;
|
|
178
|
-
}
|
|
179
|
-
catch (err) {
|
|
180
|
-
const errorInfo = {
|
|
181
|
-
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
182
|
-
};
|
|
183
|
-
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
184
|
-
return errorStatus;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
async getVoicemailSummary() {
|
|
188
|
-
return Promise.resolve(null);
|
|
189
|
-
}
|
|
190
|
-
async voicemailMarkAsRead(messageId) {
|
|
191
|
-
const loggerContext = {
|
|
192
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
193
|
-
method: 'voicemailMarkAsRead',
|
|
194
|
-
};
|
|
195
|
-
try {
|
|
196
|
-
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
|
|
197
|
-
const response = await fetch(voicemailContentUrl, {
|
|
198
|
-
method: HTTP_METHODS.PUT,
|
|
199
|
-
headers: {
|
|
200
|
-
Authorization: this.xsiAccessToken,
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
if (!response.ok) {
|
|
204
|
-
throw new Error(`${response.status}`);
|
|
205
|
-
}
|
|
206
|
-
const responseDetails = {
|
|
207
|
-
statusCode: response.status,
|
|
208
|
-
data: {},
|
|
209
|
-
message: SUCCESS_MESSAGE,
|
|
210
|
-
};
|
|
211
|
-
return responseDetails;
|
|
212
|
-
}
|
|
213
|
-
catch (err) {
|
|
214
|
-
const errorInfo = {
|
|
215
|
-
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
216
|
-
};
|
|
217
|
-
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
218
|
-
return errorStatus;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
async voicemailMarkAsUnread(messageId) {
|
|
222
|
-
const loggerContext = {
|
|
223
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
224
|
-
method: 'voicemailMarkAsUnread',
|
|
225
|
-
};
|
|
226
|
-
try {
|
|
227
|
-
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
|
|
228
|
-
const response = await fetch(voicemailContentUrl, {
|
|
229
|
-
method: HTTP_METHODS.PUT,
|
|
230
|
-
headers: {
|
|
231
|
-
Authorization: this.xsiAccessToken,
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
if (!response.ok) {
|
|
235
|
-
throw new Error(`${response.status}`);
|
|
236
|
-
}
|
|
237
|
-
const responseDetails = {
|
|
238
|
-
statusCode: response.status,
|
|
239
|
-
data: {},
|
|
240
|
-
message: SUCCESS_MESSAGE,
|
|
241
|
-
};
|
|
242
|
-
return responseDetails;
|
|
243
|
-
}
|
|
244
|
-
catch (err) {
|
|
245
|
-
const errorInfo = {
|
|
246
|
-
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
247
|
-
};
|
|
248
|
-
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
249
|
-
return errorStatus;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
async deleteVoicemail(messageId) {
|
|
253
|
-
const loggerContext = {
|
|
254
|
-
file: BROADWORKS_VOICEMAIL_FILE,
|
|
255
|
-
method: 'deleteVoicemail',
|
|
256
|
-
};
|
|
257
|
-
try {
|
|
258
|
-
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
259
|
-
const response = await fetch(voicemailContentUrl, {
|
|
260
|
-
method: HTTP_METHODS.DELETE,
|
|
261
|
-
headers: {
|
|
262
|
-
Authorization: this.xsiAccessToken,
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
if (!response.ok) {
|
|
266
|
-
throw new Error(`${response.status}`);
|
|
267
|
-
}
|
|
268
|
-
const responseDetails = {
|
|
269
|
-
statusCode: response.status,
|
|
270
|
-
data: {},
|
|
271
|
-
message: SUCCESS_MESSAGE,
|
|
272
|
-
};
|
|
273
|
-
return responseDetails;
|
|
274
|
-
}
|
|
275
|
-
catch (err) {
|
|
276
|
-
const errorInfo = {
|
|
277
|
-
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
278
|
-
};
|
|
279
|
-
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
280
|
-
return errorStatus;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
async getVMTranscript(messageId) {
|
|
284
|
-
log.info(`Message Id: ${messageId}`, {});
|
|
285
|
-
return Promise.resolve(null);
|
|
286
|
-
}
|
|
287
|
-
resolveContact(callingPartyInfo) {
|
|
288
|
-
log.info(`Calling Party Info: ${callingPartyInfo}`, {});
|
|
289
|
-
return Promise.resolve(null);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
1
|
+
import { ERROR_CODE } from '../Errors/types';
|
|
2
|
+
import SDKConnector from '../SDKConnector';
|
|
3
|
+
import { BASE64, BEARER, BINARY, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, OBJECT, TOKEN, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, } from '../common/constants';
|
|
4
|
+
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
|
|
5
|
+
import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
|
|
6
|
+
import log from '../Logger';
|
|
7
|
+
import { BROADWORKS_VOICEMAIL_FILE, BW_TOKEN_FETCH_ENDPOINT, JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, } from './constants';
|
|
8
|
+
export class BroadworksBackendConnector {
|
|
9
|
+
bwtoken;
|
|
10
|
+
userId;
|
|
11
|
+
xsiAccessToken;
|
|
12
|
+
xsiEndpoint;
|
|
13
|
+
context;
|
|
14
|
+
sdkConnector;
|
|
15
|
+
webex;
|
|
16
|
+
xsiVoiceMessageURI;
|
|
17
|
+
constructor(webex, logger) {
|
|
18
|
+
this.sdkConnector = SDKConnector;
|
|
19
|
+
if (!this.sdkConnector.getWebex()) {
|
|
20
|
+
SDKConnector.setWebex(webex);
|
|
21
|
+
}
|
|
22
|
+
this.webex = this.sdkConnector.getWebex();
|
|
23
|
+
this.context = Math.random().toString(RADIX_RAND).substring(PREFIX);
|
|
24
|
+
log.setLogger(logger.level, BROADWORKS_VOICEMAIL_FILE);
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
const loggerContext = {
|
|
28
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
29
|
+
method: 'init',
|
|
30
|
+
};
|
|
31
|
+
log.info('Initializing Broadworks voicemail connector', loggerContext);
|
|
32
|
+
const response = this.setXsiVoiceMessageURI();
|
|
33
|
+
return response;
|
|
34
|
+
}
|
|
35
|
+
getSDKConnector() {
|
|
36
|
+
return this.sdkConnector;
|
|
37
|
+
}
|
|
38
|
+
async getUserId() {
|
|
39
|
+
const loggerContext = {
|
|
40
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
41
|
+
method: 'getUserId',
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
await this.getBwToken();
|
|
45
|
+
if (this.bwtoken && this.bwtoken.split('.').length > 1) {
|
|
46
|
+
const decodedString = Buffer.from(this.bwtoken.split('.')[1], BASE64).toString(BINARY);
|
|
47
|
+
this.userId = JSON.parse(decodedString).sub;
|
|
48
|
+
return this.userId;
|
|
49
|
+
}
|
|
50
|
+
const error = ERROR_CODE.UNAUTHORIZED;
|
|
51
|
+
throw new Error(`${error}`);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
const errorInfo = {
|
|
55
|
+
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
56
|
+
};
|
|
57
|
+
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async getBwToken() {
|
|
61
|
+
try {
|
|
62
|
+
const bwTokenResponse = await this.webex.request({
|
|
63
|
+
uri: `${this.webex.internal.services._serviceUrls.broadworksIdpProxy}${BW_TOKEN_FETCH_ENDPOINT}`,
|
|
64
|
+
method: HTTP_METHODS.GET,
|
|
65
|
+
});
|
|
66
|
+
const response = bwTokenResponse.body;
|
|
67
|
+
this.bwtoken = response[TOKEN][BEARER];
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
log.info(`Broadworks token exception ${err}`, {});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async setXsiVoiceMessageURI() {
|
|
74
|
+
const loggerContext = {
|
|
75
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
76
|
+
method: 'setXsiVoiceMessageURI',
|
|
77
|
+
};
|
|
78
|
+
let userIdResponse = await this.getUserId();
|
|
79
|
+
this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.BWRKS);
|
|
80
|
+
this.xsiAccessToken = `${BEARER} ${this.bwtoken}`;
|
|
81
|
+
log.info(`XsiEndpoint is ${this.xsiEndpoint}`, loggerContext);
|
|
82
|
+
if (userIdResponse && typeof userIdResponse !== OBJECT) {
|
|
83
|
+
this.xsiVoiceMessageURI = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${userIdResponse}/${VOICE_MESSAGING_MESSAGES}`;
|
|
84
|
+
userIdResponse = {
|
|
85
|
+
statusCode: SUCCESS_STATUS_CODE,
|
|
86
|
+
data: {},
|
|
87
|
+
message: SUCCESS_MESSAGE,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return userIdResponse;
|
|
91
|
+
}
|
|
92
|
+
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
93
|
+
const loggerContext = {
|
|
94
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
95
|
+
method: 'getVoicemailList',
|
|
96
|
+
};
|
|
97
|
+
log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
|
|
98
|
+
const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
|
|
99
|
+
let messageinfo;
|
|
100
|
+
const sortParam = Object.values(SORT).includes(sort) ? sort : SORT.DEFAULT;
|
|
101
|
+
if (refresh) {
|
|
102
|
+
try {
|
|
103
|
+
const response = await fetch(`${urlXsi}`, {
|
|
104
|
+
method: HTTP_METHODS.GET,
|
|
105
|
+
headers: {
|
|
106
|
+
Authorization: this.xsiAccessToken,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`${response.status}`);
|
|
111
|
+
}
|
|
112
|
+
const voicemailListResponse = (await response.json());
|
|
113
|
+
if (Object.keys(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList).length === 0) {
|
|
114
|
+
messageinfo = [];
|
|
115
|
+
}
|
|
116
|
+
else if (!Array.isArray(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList?.messageInfo)) {
|
|
117
|
+
messageinfo = Array(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList?.messageInfo);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
messageinfo = voicemailListResponse?.VoiceMessagingMessages?.messageInfoList
|
|
121
|
+
?.messageInfo;
|
|
122
|
+
messageinfo = getSortedVoicemailList(messageinfo, sortParam);
|
|
123
|
+
}
|
|
124
|
+
storeVoicemailList(this.context, messageinfo);
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
const errorInfo = {
|
|
128
|
+
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
129
|
+
};
|
|
130
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
131
|
+
return errorStatus;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const { messages, moreVMAvailable } = fetchVoicemailList(this.context, offset, offsetLimit, loggerContext);
|
|
135
|
+
const responseDetails = {
|
|
136
|
+
statusCode: moreVMAvailable ? SUCCESS_STATUS_CODE : NO_VOICEMAIL_STATUS_CODE,
|
|
137
|
+
data: {
|
|
138
|
+
voicemailList: messages,
|
|
139
|
+
},
|
|
140
|
+
message: moreVMAvailable ? SUCCESS_MESSAGE : NO_VOICEMAIL_MSG,
|
|
141
|
+
};
|
|
142
|
+
return responseDetails;
|
|
143
|
+
}
|
|
144
|
+
async getVoicemailContent(messageId) {
|
|
145
|
+
const loggerContext = {
|
|
146
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
147
|
+
method: 'getVoicemailContent',
|
|
148
|
+
};
|
|
149
|
+
try {
|
|
150
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
151
|
+
const response = await fetch(`${voicemailContentUrl}`, {
|
|
152
|
+
method: 'GET',
|
|
153
|
+
headers: {
|
|
154
|
+
Authorization: this.xsiAccessToken,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
throw new Error(`${response.status}`);
|
|
159
|
+
}
|
|
160
|
+
const xmlData = await response.text();
|
|
161
|
+
const parser = new DOMParser();
|
|
162
|
+
const xmlDOM = parser.parseFromString(xmlData, XML_TYPE);
|
|
163
|
+
const mediaDetails = xmlDOM.getElementsByTagName(MESSAGE_MEDIA_CONTENT)[0];
|
|
164
|
+
const mediaType = mediaDetails.childNodes[1]?.textContent;
|
|
165
|
+
const mediaContent = mediaDetails.childNodes[2]?.textContent;
|
|
166
|
+
log.info(`Media type is ${mediaType}`, loggerContext);
|
|
167
|
+
const responseDetails = {
|
|
168
|
+
statusCode: response?.status,
|
|
169
|
+
data: {
|
|
170
|
+
voicemailContent: {
|
|
171
|
+
type: mediaType,
|
|
172
|
+
content: mediaContent,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
message: SUCCESS_MESSAGE,
|
|
176
|
+
};
|
|
177
|
+
return responseDetails;
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
const errorInfo = {
|
|
181
|
+
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
182
|
+
};
|
|
183
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
184
|
+
return errorStatus;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async getVoicemailSummary() {
|
|
188
|
+
return Promise.resolve(null);
|
|
189
|
+
}
|
|
190
|
+
async voicemailMarkAsRead(messageId) {
|
|
191
|
+
const loggerContext = {
|
|
192
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
193
|
+
method: 'voicemailMarkAsRead',
|
|
194
|
+
};
|
|
195
|
+
try {
|
|
196
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
|
|
197
|
+
const response = await fetch(voicemailContentUrl, {
|
|
198
|
+
method: HTTP_METHODS.PUT,
|
|
199
|
+
headers: {
|
|
200
|
+
Authorization: this.xsiAccessToken,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
throw new Error(`${response.status}`);
|
|
205
|
+
}
|
|
206
|
+
const responseDetails = {
|
|
207
|
+
statusCode: response.status,
|
|
208
|
+
data: {},
|
|
209
|
+
message: SUCCESS_MESSAGE,
|
|
210
|
+
};
|
|
211
|
+
return responseDetails;
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
const errorInfo = {
|
|
215
|
+
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
216
|
+
};
|
|
217
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
218
|
+
return errorStatus;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async voicemailMarkAsUnread(messageId) {
|
|
222
|
+
const loggerContext = {
|
|
223
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
224
|
+
method: 'voicemailMarkAsUnread',
|
|
225
|
+
};
|
|
226
|
+
try {
|
|
227
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
|
|
228
|
+
const response = await fetch(voicemailContentUrl, {
|
|
229
|
+
method: HTTP_METHODS.PUT,
|
|
230
|
+
headers: {
|
|
231
|
+
Authorization: this.xsiAccessToken,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
if (!response.ok) {
|
|
235
|
+
throw new Error(`${response.status}`);
|
|
236
|
+
}
|
|
237
|
+
const responseDetails = {
|
|
238
|
+
statusCode: response.status,
|
|
239
|
+
data: {},
|
|
240
|
+
message: SUCCESS_MESSAGE,
|
|
241
|
+
};
|
|
242
|
+
return responseDetails;
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
const errorInfo = {
|
|
246
|
+
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
247
|
+
};
|
|
248
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
249
|
+
return errorStatus;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async deleteVoicemail(messageId) {
|
|
253
|
+
const loggerContext = {
|
|
254
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
255
|
+
method: 'deleteVoicemail',
|
|
256
|
+
};
|
|
257
|
+
try {
|
|
258
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
259
|
+
const response = await fetch(voicemailContentUrl, {
|
|
260
|
+
method: HTTP_METHODS.DELETE,
|
|
261
|
+
headers: {
|
|
262
|
+
Authorization: this.xsiAccessToken,
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
if (!response.ok) {
|
|
266
|
+
throw new Error(`${response.status}`);
|
|
267
|
+
}
|
|
268
|
+
const responseDetails = {
|
|
269
|
+
statusCode: response.status,
|
|
270
|
+
data: {},
|
|
271
|
+
message: SUCCESS_MESSAGE,
|
|
272
|
+
};
|
|
273
|
+
return responseDetails;
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
const errorInfo = {
|
|
277
|
+
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
278
|
+
};
|
|
279
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
280
|
+
return errorStatus;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async getVMTranscript(messageId) {
|
|
284
|
+
log.info(`Message Id: ${messageId}`, {});
|
|
285
|
+
return Promise.resolve(null);
|
|
286
|
+
}
|
|
287
|
+
resolveContact(callingPartyInfo) {
|
|
288
|
+
log.info(`Calling Party Info: ${callingPartyInfo}`, {});
|
|
289
|
+
return Promise.resolve(null);
|
|
290
|
+
}
|
|
291
|
+
}
|