@webex/calling 0.0.1-next.0
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/README.md +67 -0
- package/dist/module/CallHistory/CallHistory.js +84 -0
- package/dist/module/CallHistory/callHistoryFixtures.js +307 -0
- package/dist/module/CallHistory/constants.js +9 -0
- package/dist/module/CallHistory/types.js +1 -0
- package/dist/module/CallSettings/CallSettings.js +65 -0
- package/dist/module/CallSettings/UcmBackendConnector.js +100 -0
- package/dist/module/CallSettings/WxCallBackendConnector.js +287 -0
- package/dist/module/CallSettings/constants.js +11 -0
- package/dist/module/CallSettings/testFixtures.js +62 -0
- package/dist/module/CallSettings/types.js +1 -0
- package/dist/module/CallingClient/CallingClient.js +268 -0
- package/dist/module/CallingClient/callRecordFixtures.js +93 -0
- package/dist/module/CallingClient/calling/CallerId/index.js +169 -0
- package/dist/module/CallingClient/calling/CallerId/types.js +1 -0
- package/dist/module/CallingClient/calling/call.js +1649 -0
- package/dist/module/CallingClient/calling/callManager.js +274 -0
- package/dist/module/CallingClient/calling/index.js +2 -0
- package/dist/module/CallingClient/calling/types.js +53 -0
- package/dist/module/CallingClient/callingClientFixtures.js +38 -0
- package/dist/module/CallingClient/constants.js +122 -0
- package/dist/module/CallingClient/line/index.js +110 -0
- package/dist/module/CallingClient/line/types.js +14 -0
- package/dist/module/CallingClient/registration/index.js +1 -0
- package/dist/module/CallingClient/registration/register.js +507 -0
- package/dist/module/CallingClient/registration/registerFixtures.js +28 -0
- package/dist/module/CallingClient/registration/types.js +1 -0
- package/dist/module/CallingClient/types.js +1 -0
- package/dist/module/Contacts/ContactsClient.js +487 -0
- package/dist/module/Contacts/constants.js +20 -0
- package/dist/module/Contacts/contactFixtures.js +284 -0
- package/dist/module/Contacts/types.js +10 -0
- package/dist/module/Errors/catalog/CallError.js +26 -0
- package/dist/module/Errors/catalog/CallingDeviceError.js +18 -0
- package/dist/module/Errors/catalog/ExtendedError.js +10 -0
- package/dist/module/Errors/catalog/LineError.js +24 -0
- package/dist/module/Errors/index.js +2 -0
- package/dist/module/Errors/types.js +48 -0
- package/dist/module/Events/impl/index.js +19 -0
- package/dist/module/Events/types.js +74 -0
- package/dist/module/Logger/index.js +114 -0
- package/dist/module/Logger/types.js +25 -0
- package/dist/module/Metrics/index.js +232 -0
- package/dist/module/Metrics/types.js +37 -0
- package/dist/module/SDKConnector/index.js +39 -0
- package/dist/module/SDKConnector/types.js +1 -0
- package/dist/module/SDKConnector/utils.js +12 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +289 -0
- package/dist/module/Voicemail/UcmBackendConnector.js +275 -0
- package/dist/module/Voicemail/Voicemail.js +110 -0
- package/dist/module/Voicemail/WxCallBackendConnector.js +279 -0
- package/dist/module/Voicemail/constants.js +29 -0
- package/dist/module/Voicemail/types.js +1 -0
- package/dist/module/Voicemail/voicemailFixture.js +449 -0
- package/dist/module/common/Utils.js +802 -0
- package/dist/module/common/constants.js +40 -0
- package/dist/module/common/index.js +1 -0
- package/dist/module/common/testUtil.js +938 -0
- package/dist/module/common/types.js +57 -0
- package/dist/module/index.js +8 -0
- package/dist/types/CallHistory/CallHistory.d.ts +19 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -0
- package/dist/types/CallHistory/callHistoryFixtures.d.ts +95 -0
- package/dist/types/CallHistory/callHistoryFixtures.d.ts.map +1 -0
- package/dist/types/CallHistory/constants.d.ts +10 -0
- package/dist/types/CallHistory/constants.d.ts.map +1 -0
- package/dist/types/CallHistory/types.d.ts +21 -0
- package/dist/types/CallHistory/types.d.ts.map +1 -0
- package/dist/types/CallSettings/CallSettings.d.ts +20 -0
- package/dist/types/CallSettings/CallSettings.d.ts.map +1 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +20 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -0
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts +22 -0
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -0
- package/dist/types/CallSettings/constants.d.ts +12 -0
- package/dist/types/CallSettings/constants.d.ts.map +1 -0
- package/dist/types/CallSettings/testFixtures.d.ts +16 -0
- package/dist/types/CallSettings/testFixtures.d.ts.map +1 -0
- package/dist/types/CallSettings/types.d.ts +108 -0
- package/dist/types/CallSettings/types.d.ts.map +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +38 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -0
- package/dist/types/CallingClient/callRecordFixtures.d.ts +4 -0
- package/dist/types/CallingClient/callRecordFixtures.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/CallerId/index.d.ts +18 -0
- package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/CallerId/types.d.ts +42 -0
- package/dist/types/CallingClient/calling/CallerId/types.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/call.d.ts +95 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/callManager.d.ts +22 -0
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/index.d.ts +3 -0
- package/dist/types/CallingClient/calling/index.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/types.d.ts +204 -0
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -0
- package/dist/types/CallingClient/callingClientFixtures.d.ts +19 -0
- package/dist/types/CallingClient/callingClientFixtures.d.ts.map +1 -0
- package/dist/types/CallingClient/constants.d.ts +123 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/line/index.d.ts +39 -0
- package/dist/types/CallingClient/line/index.d.ts.map +1 -0
- package/dist/types/CallingClient/line/types.d.ts +51 -0
- package/dist/types/CallingClient/line/types.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/index.d.ts +2 -0
- package/dist/types/CallingClient/registration/index.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/register.d.ts +65 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/registerFixtures.d.ts +29 -0
- package/dist/types/CallingClient/registration/registerFixtures.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/types.d.ts +21 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -0
- package/dist/types/CallingClient/types.d.ts +30 -0
- package/dist/types/CallingClient/types.d.ts.map +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts +28 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -0
- package/dist/types/Contacts/constants.d.ts +20 -0
- package/dist/types/Contacts/constants.d.ts.map +1 -0
- package/dist/types/Contacts/contactFixtures.d.ts +281 -0
- package/dist/types/Contacts/contactFixtures.d.ts.map +1 -0
- package/dist/types/Contacts/types.d.ts +75 -0
- package/dist/types/Contacts/types.d.ts.map +1 -0
- package/dist/types/Errors/catalog/CallError.d.ts +12 -0
- package/dist/types/Errors/catalog/CallError.d.ts.map +1 -0
- package/dist/types/Errors/catalog/CallingDeviceError.d.ts +11 -0
- package/dist/types/Errors/catalog/CallingDeviceError.d.ts.map +1 -0
- package/dist/types/Errors/catalog/ExtendedError.d.ts +7 -0
- package/dist/types/Errors/catalog/ExtendedError.d.ts.map +1 -0
- package/dist/types/Errors/catalog/LineError.d.ts +11 -0
- package/dist/types/Errors/catalog/LineError.d.ts.map +1 -0
- package/dist/types/Errors/index.d.ts +3 -0
- package/dist/types/Errors/index.d.ts.map +1 -0
- package/dist/types/Errors/types.d.ts +61 -0
- package/dist/types/Errors/types.d.ts.map +1 -0
- package/dist/types/Events/impl/index.d.ts +9 -0
- package/dist/types/Events/impl/index.d.ts.map +1 -0
- package/dist/types/Events/types.d.ts +284 -0
- package/dist/types/Events/types.d.ts.map +1 -0
- package/dist/types/Logger/index.d.ts +13 -0
- package/dist/types/Logger/index.d.ts.map +1 -0
- package/dist/types/Logger/types.d.ts +26 -0
- package/dist/types/Logger/types.d.ts.map +1 -0
- package/dist/types/Metrics/index.d.ts +6 -0
- package/dist/types/Metrics/index.d.ts.map +1 -0
- package/dist/types/Metrics/types.d.ts +43 -0
- package/dist/types/Metrics/types.d.ts.map +1 -0
- package/dist/types/SDKConnector/index.d.ts +13 -0
- package/dist/types/SDKConnector/index.d.ts.map +1 -0
- package/dist/types/SDKConnector/types.d.ts +129 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -0
- package/dist/types/SDKConnector/utils.d.ts +6 -0
- package/dist/types/SDKConnector/utils.d.ts.map +1 -0
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +28 -0
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -0
- package/dist/types/Voicemail/UcmBackendConnector.d.ts +35 -0
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -0
- package/dist/types/Voicemail/Voicemail.d.ts +28 -0
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -0
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +24 -0
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -0
- package/dist/types/Voicemail/constants.d.ts +30 -0
- package/dist/types/Voicemail/constants.d.ts.map +1 -0
- package/dist/types/Voicemail/types.d.ts +134 -0
- package/dist/types/Voicemail/types.d.ts.map +1 -0
- package/dist/types/Voicemail/voicemailFixture.d.ts +350 -0
- package/dist/types/Voicemail/voicemailFixture.d.ts.map +1 -0
- package/dist/types/common/Utils.d.ts +35 -0
- package/dist/types/common/Utils.d.ts.map +1 -0
- package/dist/types/common/constants.d.ts +41 -0
- package/dist/types/common/constants.d.ts.map +1 -0
- package/dist/types/common/index.d.ts +2 -0
- package/dist/types/common/index.d.ts.map +1 -0
- package/dist/types/common/testUtil.d.ts +3612 -0
- package/dist/types/common/testUtil.d.ts.map +1 -0
- package/dist/types/common/types.d.ts +192 -0
- package/dist/types/common/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +161 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import SDKConnector from '../SDKConnector';
|
|
2
|
+
import { HTTP_METHODS, CALLING_BACKEND, } from '../common/types';
|
|
3
|
+
import { getVgActionEndpoint, serviceErrorCodeHandler } from '../common/Utils';
|
|
4
|
+
import { SUCCESS_MESSAGE, USERS, CONTENT, UCM_CONNECTOR_FILE } from '../common/constants';
|
|
5
|
+
import log from '../Logger';
|
|
6
|
+
import { API_V1, LIMIT, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
|
|
7
|
+
export class UcmBackendConnector {
|
|
8
|
+
vgEndpoint;
|
|
9
|
+
userId;
|
|
10
|
+
orgId;
|
|
11
|
+
sdkConnector;
|
|
12
|
+
webex;
|
|
13
|
+
vgVoiceMessageURI;
|
|
14
|
+
constructor(webex, logger) {
|
|
15
|
+
this.sdkConnector = SDKConnector;
|
|
16
|
+
if (!this.sdkConnector.getWebex()) {
|
|
17
|
+
SDKConnector.setWebex(webex);
|
|
18
|
+
}
|
|
19
|
+
this.webex = this.sdkConnector.getWebex();
|
|
20
|
+
this.userId = this.webex.internal.device.userId;
|
|
21
|
+
this.orgId = this.webex.internal.device.orgId;
|
|
22
|
+
log.setLogger(logger.level, UCM_CONNECTOR_FILE);
|
|
23
|
+
}
|
|
24
|
+
init() {
|
|
25
|
+
const loggerContext = {
|
|
26
|
+
file: UCM_CONNECTOR_FILE,
|
|
27
|
+
method: 'init',
|
|
28
|
+
};
|
|
29
|
+
log.info('Initializing UCM calling voicemail connector', loggerContext);
|
|
30
|
+
const response = this.setUcmVoiceMessageBaseURI();
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
getSDKConnector() {
|
|
34
|
+
return this.sdkConnector;
|
|
35
|
+
}
|
|
36
|
+
setUcmVoiceMessageBaseURI() {
|
|
37
|
+
this.vgEndpoint = getVgActionEndpoint(this.webex, CALLING_BACKEND.UCM);
|
|
38
|
+
this.vgVoiceMessageURI = `${this.vgEndpoint}/${VMGATEWAY}/${API_V1}/${USERS}/${this.userId}/`;
|
|
39
|
+
return this.vgVoiceMessageURI;
|
|
40
|
+
}
|
|
41
|
+
async getVoicemailList(offset, offsetLimit, sort) {
|
|
42
|
+
const loggerContext = {
|
|
43
|
+
file: UCM_CONNECTOR_FILE,
|
|
44
|
+
method: 'getVoicemailList',
|
|
45
|
+
};
|
|
46
|
+
log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
|
|
47
|
+
const urlVg = `${this.vgVoiceMessageURI}${VOICEMAILS}/${OFFSET}=${offset}${LIMIT}=${offsetLimit}${SORT_ORDER}=${sort}`;
|
|
48
|
+
try {
|
|
49
|
+
const response = await this.webex.request({
|
|
50
|
+
uri: `${urlVg}`,
|
|
51
|
+
method: HTTP_METHODS.GET,
|
|
52
|
+
headers: {
|
|
53
|
+
orgId: this.orgId,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const msgInfo = response.body;
|
|
57
|
+
const messageinfoArray = [];
|
|
58
|
+
const ucmVmMsgInfo = msgInfo.Message;
|
|
59
|
+
ucmVmMsgInfo.forEach((msgInfoObj) => {
|
|
60
|
+
const message = {};
|
|
61
|
+
let stringObj = {};
|
|
62
|
+
const numberObj = {};
|
|
63
|
+
stringObj.$ = msgInfoObj.Duration;
|
|
64
|
+
message.duration = stringObj;
|
|
65
|
+
numberObj.$ = Number(msgInfoObj.ArrivalTime);
|
|
66
|
+
message.time = numberObj;
|
|
67
|
+
stringObj = { $: '' };
|
|
68
|
+
stringObj.$ = msgInfoObj.MsgId;
|
|
69
|
+
message.messageId = stringObj;
|
|
70
|
+
if (msgInfoObj.Read === 'true') {
|
|
71
|
+
message.read = {};
|
|
72
|
+
}
|
|
73
|
+
const callerIdObj = msgInfoObj.CallerId;
|
|
74
|
+
const callingParty = {};
|
|
75
|
+
stringObj = { $: '' };
|
|
76
|
+
stringObj.$ = callerIdObj.CallerName;
|
|
77
|
+
callingParty.name = stringObj;
|
|
78
|
+
stringObj = { $: '' };
|
|
79
|
+
stringObj.$ = this.userId;
|
|
80
|
+
callingParty.userId = stringObj;
|
|
81
|
+
stringObj = { $: '' };
|
|
82
|
+
stringObj.$ = callerIdObj.CallerNumber;
|
|
83
|
+
callingParty.address = stringObj;
|
|
84
|
+
message.callingPartyInfo = callingParty;
|
|
85
|
+
messageinfoArray.push(message);
|
|
86
|
+
});
|
|
87
|
+
const responseDetails = {
|
|
88
|
+
statusCode: response.statusCode,
|
|
89
|
+
data: {
|
|
90
|
+
voicemailList: messageinfoArray,
|
|
91
|
+
},
|
|
92
|
+
message: SUCCESS_MESSAGE,
|
|
93
|
+
};
|
|
94
|
+
return responseDetails;
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const errorInfo = err;
|
|
98
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
99
|
+
return errorStatus;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async getVoicemailContent(messageId) {
|
|
103
|
+
const loggerContext = {
|
|
104
|
+
file: UCM_CONNECTOR_FILE,
|
|
105
|
+
method: 'getVoicemailContent',
|
|
106
|
+
};
|
|
107
|
+
try {
|
|
108
|
+
const response = (await this.getVoicemailContentUcm(messageId));
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
const errorInfo = err;
|
|
113
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
114
|
+
log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
|
|
115
|
+
return errorStatus;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async getVoicemailSummary() {
|
|
119
|
+
return Promise.resolve(null);
|
|
120
|
+
}
|
|
121
|
+
async getVoicemailContentUcm(messageId) {
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}/${CONTENT}`;
|
|
124
|
+
const mercuryApi = `${this.webex.internal.services._serviceUrls.mercuryApi}`;
|
|
125
|
+
this.returnUcmPromise(voicemailContentUrl, mercuryApi)
|
|
126
|
+
.then((response) => {
|
|
127
|
+
if (response.statusCode === 200) {
|
|
128
|
+
resolve(response);
|
|
129
|
+
}
|
|
130
|
+
else if (response.statusCode === 202) {
|
|
131
|
+
this.sdkConnector.registerListener('event:ucm.voicemail_download_complete', async (event) => {
|
|
132
|
+
const responseEvent = event;
|
|
133
|
+
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${responseEvent?.data?.messageId}/${CONTENT}`;
|
|
134
|
+
const response = await this.returnUcmPromise(voicemailContentUrl, mercuryApi);
|
|
135
|
+
if (response.statusCode === 200) {
|
|
136
|
+
this.sdkConnector.unregisterListener('event:ucm.voicemail_download_complete');
|
|
137
|
+
resolve(response);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.sdkConnector.unregisterListener('event:ucm.voicemail_download_complete');
|
|
141
|
+
reject(response);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
reject(response);
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
.catch((err) => {
|
|
150
|
+
reject(err);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async returnUcmPromise(voicemailContentUrl, mercuryApi) {
|
|
155
|
+
const response = await this.webex.request({
|
|
156
|
+
uri: `${voicemailContentUrl}`,
|
|
157
|
+
method: HTTP_METHODS.GET,
|
|
158
|
+
headers: {
|
|
159
|
+
orgId: this.orgId,
|
|
160
|
+
deviceUrl: this.webex.internal.device.url,
|
|
161
|
+
mercuryHostname: mercuryApi,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
const contentInfo = response?.body;
|
|
165
|
+
const respHeaders = response.headers;
|
|
166
|
+
const mediaType = respHeaders?.mediatype;
|
|
167
|
+
const mediaContent = contentInfo;
|
|
168
|
+
const responseDetails = {
|
|
169
|
+
statusCode: response.statusCode,
|
|
170
|
+
data: {
|
|
171
|
+
voicemailContent: {
|
|
172
|
+
type: mediaType,
|
|
173
|
+
content: mediaContent,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
message: SUCCESS_MESSAGE,
|
|
177
|
+
};
|
|
178
|
+
return responseDetails;
|
|
179
|
+
}
|
|
180
|
+
async voicemailMarkAsRead(messageId) {
|
|
181
|
+
const loggerContext = {
|
|
182
|
+
file: UCM_CONNECTOR_FILE,
|
|
183
|
+
method: 'voicemailMarkAsRead',
|
|
184
|
+
};
|
|
185
|
+
try {
|
|
186
|
+
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
|
|
187
|
+
const response = await this.webex.request({
|
|
188
|
+
uri: voicemailContentUrl,
|
|
189
|
+
method: HTTP_METHODS.PUT,
|
|
190
|
+
headers: {
|
|
191
|
+
orgId: this.orgId,
|
|
192
|
+
},
|
|
193
|
+
body: {
|
|
194
|
+
read: 'true',
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
const responseDetails = {
|
|
198
|
+
statusCode: response.statusCode,
|
|
199
|
+
data: {},
|
|
200
|
+
message: SUCCESS_MESSAGE,
|
|
201
|
+
};
|
|
202
|
+
return responseDetails;
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
const errorInfo = err;
|
|
206
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
207
|
+
return errorStatus;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async voicemailMarkAsUnread(messageId) {
|
|
211
|
+
const loggerContext = {
|
|
212
|
+
file: UCM_CONNECTOR_FILE,
|
|
213
|
+
method: 'voicemailMarkAsUnread',
|
|
214
|
+
};
|
|
215
|
+
try {
|
|
216
|
+
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
|
|
217
|
+
const response = await this.webex.request({
|
|
218
|
+
uri: voicemailContentUrl,
|
|
219
|
+
method: HTTP_METHODS.PUT,
|
|
220
|
+
headers: {
|
|
221
|
+
orgId: this.orgId,
|
|
222
|
+
},
|
|
223
|
+
body: {
|
|
224
|
+
read: 'false',
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
const responseDetails = {
|
|
228
|
+
statusCode: response.statusCode,
|
|
229
|
+
data: {},
|
|
230
|
+
message: SUCCESS_MESSAGE,
|
|
231
|
+
};
|
|
232
|
+
return responseDetails;
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
const errorInfo = err;
|
|
236
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
237
|
+
return errorStatus;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async deleteVoicemail(messageId) {
|
|
241
|
+
const loggerContext = {
|
|
242
|
+
file: UCM_CONNECTOR_FILE,
|
|
243
|
+
method: 'deleteVoicemail',
|
|
244
|
+
};
|
|
245
|
+
try {
|
|
246
|
+
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
|
|
247
|
+
const response = await this.webex.request({
|
|
248
|
+
uri: voicemailContentUrl,
|
|
249
|
+
method: HTTP_METHODS.DELETE,
|
|
250
|
+
headers: {
|
|
251
|
+
orgId: this.orgId,
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
const responseDetails = {
|
|
255
|
+
statusCode: response.statusCode,
|
|
256
|
+
data: {},
|
|
257
|
+
message: SUCCESS_MESSAGE,
|
|
258
|
+
};
|
|
259
|
+
return responseDetails;
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
const errorInfo = err;
|
|
263
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
264
|
+
return errorStatus;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async getVMTranscript(messageId) {
|
|
268
|
+
log.info(`Message Id: ${messageId}`, {});
|
|
269
|
+
return Promise.resolve(null);
|
|
270
|
+
}
|
|
271
|
+
resolveContact(callingPartyInfo) {
|
|
272
|
+
log.info(`Calling Party Info: ${callingPartyInfo}`, {});
|
|
273
|
+
return Promise.resolve(null);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import SDKConnector from '../SDKConnector';
|
|
2
|
+
import { CALLING_BACKEND } from '../common/types';
|
|
3
|
+
import log from '../Logger';
|
|
4
|
+
import { getCallingBackEnd } from '../common/Utils';
|
|
5
|
+
import { WxCallBackendConnector } from './WxCallBackendConnector';
|
|
6
|
+
import { BroadworksBackendConnector } from './BroadworksBackendConnector';
|
|
7
|
+
import { Eventing } from '../Events/impl';
|
|
8
|
+
import { UcmBackendConnector } from './UcmBackendConnector';
|
|
9
|
+
import { METRIC_EVENT, METRIC_TYPE, VOICEMAIL_ACTION } from '../Metrics/types';
|
|
10
|
+
import { getMetricManager } from '../Metrics';
|
|
11
|
+
import { VOICEMAIL_FILE } from './constants';
|
|
12
|
+
export class Voicemail extends Eventing {
|
|
13
|
+
logger;
|
|
14
|
+
sdkConnector;
|
|
15
|
+
webex;
|
|
16
|
+
callingBackend;
|
|
17
|
+
backendConnector;
|
|
18
|
+
metricManager;
|
|
19
|
+
constructor(webex, logger) {
|
|
20
|
+
super();
|
|
21
|
+
this.logger = logger;
|
|
22
|
+
this.sdkConnector = SDKConnector;
|
|
23
|
+
if (!this.sdkConnector.getWebex()) {
|
|
24
|
+
SDKConnector.setWebex(webex);
|
|
25
|
+
}
|
|
26
|
+
this.webex = this.sdkConnector.getWebex();
|
|
27
|
+
this.metricManager = getMetricManager(this.webex, undefined);
|
|
28
|
+
this.callingBackend = getCallingBackEnd(this.webex);
|
|
29
|
+
this.initializeBackendConnector();
|
|
30
|
+
log.setLogger(logger.level, VOICEMAIL_FILE);
|
|
31
|
+
}
|
|
32
|
+
init() {
|
|
33
|
+
const response = this.backendConnector.init();
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
initializeBackendConnector() {
|
|
37
|
+
switch (this.callingBackend) {
|
|
38
|
+
case CALLING_BACKEND.WXC: {
|
|
39
|
+
this.backendConnector = new WxCallBackendConnector(this.webex, this.logger);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case CALLING_BACKEND.BWRKS: {
|
|
43
|
+
this.backendConnector = new BroadworksBackendConnector(this.webex, this.logger);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case CALLING_BACKEND.UCM: {
|
|
47
|
+
this.backendConnector = new UcmBackendConnector(this.webex, this.logger);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
default: {
|
|
51
|
+
throw new Error('Calling backend is not identified, exiting....');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
submitMetric(response, metricAction, messageId) {
|
|
56
|
+
const { statusCode, data: { error: errorMessage }, } = response;
|
|
57
|
+
if (statusCode >= 200 && statusCode < 300) {
|
|
58
|
+
this.metricManager.submitVoicemailMetric(METRIC_EVENT.VOICEMAIL, metricAction, METRIC_TYPE.BEHAVIORAL, messageId);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.metricManager.submitVoicemailMetric(METRIC_EVENT.VOICEMAIL_ERROR, metricAction, METRIC_TYPE.BEHAVIORAL, messageId, errorMessage, statusCode);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
65
|
+
const response = await this.backendConnector.getVoicemailList(offset, offsetLimit, sort, refresh);
|
|
66
|
+
this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAILS);
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
async getVoicemailContent(messageId) {
|
|
70
|
+
const response = await this.backendConnector.getVoicemailContent(messageId);
|
|
71
|
+
this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAIL_CONTENT, messageId);
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
async getVoicemailSummary() {
|
|
75
|
+
const response = await this.backendConnector.getVoicemailSummary();
|
|
76
|
+
if (response !== null) {
|
|
77
|
+
this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAIL_SUMMARY);
|
|
78
|
+
}
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
async voicemailMarkAsRead(messageId) {
|
|
82
|
+
const response = await this.backendConnector.voicemailMarkAsRead(messageId);
|
|
83
|
+
this.submitMetric(response, VOICEMAIL_ACTION.MARK_READ, messageId);
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
async voicemailMarkAsUnread(messageId) {
|
|
87
|
+
const response = await this.backendConnector.voicemailMarkAsUnread(messageId);
|
|
88
|
+
this.submitMetric(response, VOICEMAIL_ACTION.MARK_UNREAD, messageId);
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
async deleteVoicemail(messageId) {
|
|
92
|
+
const response = await this.backendConnector.deleteVoicemail(messageId);
|
|
93
|
+
this.submitMetric(response, VOICEMAIL_ACTION.DELETE, messageId);
|
|
94
|
+
return response;
|
|
95
|
+
}
|
|
96
|
+
async getVMTranscript(messageId) {
|
|
97
|
+
const response = await this.backendConnector.getVMTranscript(messageId);
|
|
98
|
+
if (response !== null) {
|
|
99
|
+
this.submitMetric(response, VOICEMAIL_ACTION.TRANSCRIPT, messageId);
|
|
100
|
+
}
|
|
101
|
+
return response;
|
|
102
|
+
}
|
|
103
|
+
resolveContact(callingPartyInfo) {
|
|
104
|
+
return this.backendConnector.resolveContact(callingPartyInfo);
|
|
105
|
+
}
|
|
106
|
+
getSDKConnector() {
|
|
107
|
+
return this.sdkConnector;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export const createVoicemailClient = (webex, logger) => new Voicemail(webex, logger);
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import SDKConnector from '../SDKConnector';
|
|
2
|
+
import { RAW_REQUEST, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, TRANSCRIPT, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, WEBEX_CALLING_CONNECTOR_FILE, } from '../common/constants';
|
|
3
|
+
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, resolveContact, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
|
|
4
|
+
import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
|
|
5
|
+
import log from '../Logger';
|
|
6
|
+
import { JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, TRANSCRIPT_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, TRANSCRIPT_STATUS, MESSAGE_SUMMARY, CALLS, SUMMARY, NEW_MESSAGES, NEW_URGENT_MESSAGES, OLD_URGENT_MESSAGES, OLD_MESSAGES, } from './constants';
|
|
7
|
+
export class WxCallBackendConnector {
|
|
8
|
+
xsiEndpoint;
|
|
9
|
+
userId;
|
|
10
|
+
context;
|
|
11
|
+
sdkConnector;
|
|
12
|
+
xsiVoiceMessageURI;
|
|
13
|
+
webex;
|
|
14
|
+
constructor(webex, logger) {
|
|
15
|
+
this.sdkConnector = SDKConnector;
|
|
16
|
+
if (!this.sdkConnector.getWebex()) {
|
|
17
|
+
SDKConnector.setWebex(webex);
|
|
18
|
+
}
|
|
19
|
+
this.context = Math.random().toString(RADIX_RAND).substring(PREFIX);
|
|
20
|
+
this.webex = this.sdkConnector.getWebex();
|
|
21
|
+
this.userId = this.webex.internal.device.userId;
|
|
22
|
+
log.setLogger(logger.level, WEBEX_CALLING_CONNECTOR_FILE);
|
|
23
|
+
}
|
|
24
|
+
init() {
|
|
25
|
+
const loggerContext = {
|
|
26
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
27
|
+
method: 'init',
|
|
28
|
+
};
|
|
29
|
+
log.info('Initializing Webex calling voicemail connector', loggerContext);
|
|
30
|
+
const response = this.setXsiVoiceMessageURI();
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
getSDKConnector() {
|
|
34
|
+
return this.sdkConnector;
|
|
35
|
+
}
|
|
36
|
+
async setXsiVoiceMessageURI() {
|
|
37
|
+
let responseDetails;
|
|
38
|
+
const loggerContext = {
|
|
39
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
40
|
+
method: 'setXsiVoiceMessageURI',
|
|
41
|
+
};
|
|
42
|
+
this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.WXC);
|
|
43
|
+
log.info(`XsiEndpoint is ${this.xsiEndpoint}`, loggerContext);
|
|
44
|
+
if (this.userId) {
|
|
45
|
+
this.xsiVoiceMessageURI = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${this.userId}/${VOICE_MESSAGING_MESSAGES}`;
|
|
46
|
+
responseDetails = {
|
|
47
|
+
statusCode: SUCCESS_STATUS_CODE,
|
|
48
|
+
data: {},
|
|
49
|
+
message: SUCCESS_MESSAGE,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return responseDetails;
|
|
53
|
+
}
|
|
54
|
+
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
55
|
+
const loggerContext = {
|
|
56
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
57
|
+
method: 'getVoicemailList',
|
|
58
|
+
};
|
|
59
|
+
log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
|
|
60
|
+
let messageinfo;
|
|
61
|
+
if (refresh) {
|
|
62
|
+
const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
|
|
63
|
+
const sortParam = Object.values(SORT).includes(sort) ? sort : SORT.DEFAULT;
|
|
64
|
+
try {
|
|
65
|
+
const response = await this.webex.request({
|
|
66
|
+
uri: `${urlXsi}`,
|
|
67
|
+
method: HTTP_METHODS.GET,
|
|
68
|
+
});
|
|
69
|
+
const voicemailListResponse = response.body;
|
|
70
|
+
if (Object.keys(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList).length === 0) {
|
|
71
|
+
messageinfo = [];
|
|
72
|
+
}
|
|
73
|
+
else if (!Array.isArray(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList?.messageInfo)) {
|
|
74
|
+
messageinfo = Array(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList?.messageInfo);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
messageinfo = voicemailListResponse?.VoiceMessagingMessages?.messageInfoList
|
|
78
|
+
?.messageInfo;
|
|
79
|
+
messageinfo = getSortedVoicemailList(messageinfo, sortParam);
|
|
80
|
+
}
|
|
81
|
+
storeVoicemailList(this.context, messageinfo);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
const errorInfo = err;
|
|
85
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
86
|
+
return errorStatus;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const { messages, moreVMAvailable } = fetchVoicemailList(this.context, offset, offsetLimit, loggerContext);
|
|
90
|
+
const responseDetails = {
|
|
91
|
+
statusCode: moreVMAvailable ? SUCCESS_STATUS_CODE : NO_VOICEMAIL_STATUS_CODE,
|
|
92
|
+
data: {
|
|
93
|
+
voicemailList: messages,
|
|
94
|
+
},
|
|
95
|
+
message: moreVMAvailable ? SUCCESS_MESSAGE : NO_VOICEMAIL_MSG,
|
|
96
|
+
};
|
|
97
|
+
return responseDetails;
|
|
98
|
+
}
|
|
99
|
+
async getVoicemailContent(messageId) {
|
|
100
|
+
const loggerContext = {
|
|
101
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
102
|
+
method: 'getVoicemailContent',
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
106
|
+
const response = await this.webex.request({
|
|
107
|
+
uri: `${voicemailContentUrl}`,
|
|
108
|
+
method: HTTP_METHODS.GET,
|
|
109
|
+
});
|
|
110
|
+
const parser = new DOMParser();
|
|
111
|
+
const xmlDOM = parser.parseFromString(response[RAW_REQUEST].response, XML_TYPE);
|
|
112
|
+
const mediaDetails = xmlDOM.getElementsByTagName(MESSAGE_MEDIA_CONTENT)[0];
|
|
113
|
+
const mediaType = mediaDetails.childNodes[1]?.textContent;
|
|
114
|
+
const mediaContent = mediaDetails.childNodes[2]?.textContent;
|
|
115
|
+
log.info(`Media type is ${mediaType}`, loggerContext);
|
|
116
|
+
const responseDetails = {
|
|
117
|
+
statusCode: response.statusCode,
|
|
118
|
+
data: {
|
|
119
|
+
voicemailContent: {
|
|
120
|
+
type: mediaType,
|
|
121
|
+
content: mediaContent,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
message: SUCCESS_MESSAGE,
|
|
125
|
+
};
|
|
126
|
+
return responseDetails;
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
const errorInfo = err;
|
|
130
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
131
|
+
log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
|
|
132
|
+
return errorStatus;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async getVoicemailSummary() {
|
|
136
|
+
const loggerContext = {
|
|
137
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
138
|
+
method: 'getVoicemailSummary',
|
|
139
|
+
};
|
|
140
|
+
try {
|
|
141
|
+
const voicemailSummaryUrl = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${this.userId}/${CALLS}/${MESSAGE_SUMMARY}`;
|
|
142
|
+
const response = await this.webex.request({
|
|
143
|
+
uri: `${voicemailSummaryUrl}`,
|
|
144
|
+
method: HTTP_METHODS.GET,
|
|
145
|
+
});
|
|
146
|
+
const parser = new DOMParser();
|
|
147
|
+
const xmlDOM = parser.parseFromString(response[RAW_REQUEST].response, XML_TYPE);
|
|
148
|
+
const voicemailSummary = xmlDOM.getElementsByTagName(SUMMARY)[0];
|
|
149
|
+
const newMessages = voicemailSummary.getElementsByTagName(NEW_MESSAGES)[0];
|
|
150
|
+
const newUrgentMessages = voicemailSummary.getElementsByTagName(NEW_URGENT_MESSAGES)[0];
|
|
151
|
+
const oldMessages = voicemailSummary.getElementsByTagName(OLD_MESSAGES)[0];
|
|
152
|
+
const oldUrgentMessages = voicemailSummary.getElementsByTagName(OLD_URGENT_MESSAGES)[0];
|
|
153
|
+
const responseDetails = {
|
|
154
|
+
statusCode: Number(response.statusCode),
|
|
155
|
+
data: {
|
|
156
|
+
voicemailSummary: {
|
|
157
|
+
newMessages: newMessages ? Number(newMessages.textContent) : 0,
|
|
158
|
+
newUrgentMessages: newUrgentMessages ? Number(newUrgentMessages.textContent) : 0,
|
|
159
|
+
oldMessages: oldMessages ? Number(oldMessages.textContent) : 0,
|
|
160
|
+
oldUrgentMessages: oldUrgentMessages ? Number(oldUrgentMessages.textContent) : 0,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
message: SUCCESS_MESSAGE,
|
|
164
|
+
};
|
|
165
|
+
return responseDetails;
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
const errorInfo = err;
|
|
169
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
170
|
+
log.error(new Error(`Voicemail summary error is ${errorStatus}`), loggerContext);
|
|
171
|
+
return errorStatus;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async voicemailMarkAsRead(messageId) {
|
|
175
|
+
const loggerContext = {
|
|
176
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
177
|
+
method: 'voicemailMarkAsRead',
|
|
178
|
+
};
|
|
179
|
+
try {
|
|
180
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
|
|
181
|
+
const response = await this.webex.request({
|
|
182
|
+
uri: voicemailContentUrl,
|
|
183
|
+
method: HTTP_METHODS.PUT,
|
|
184
|
+
});
|
|
185
|
+
const responseDetails = {
|
|
186
|
+
statusCode: response.statusCode,
|
|
187
|
+
data: {},
|
|
188
|
+
message: SUCCESS_MESSAGE,
|
|
189
|
+
};
|
|
190
|
+
return responseDetails;
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
const errorInfo = err;
|
|
194
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
195
|
+
return errorStatus;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async voicemailMarkAsUnread(messageId) {
|
|
199
|
+
const loggerContext = {
|
|
200
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
201
|
+
method: 'voicemailMarkAsUnread',
|
|
202
|
+
};
|
|
203
|
+
try {
|
|
204
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
|
|
205
|
+
const response = await this.webex.request({
|
|
206
|
+
uri: voicemailContentUrl,
|
|
207
|
+
method: HTTP_METHODS.PUT,
|
|
208
|
+
});
|
|
209
|
+
const responseDetails = {
|
|
210
|
+
statusCode: response.statusCode,
|
|
211
|
+
data: {},
|
|
212
|
+
message: SUCCESS_MESSAGE,
|
|
213
|
+
};
|
|
214
|
+
return responseDetails;
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
const errorInfo = err;
|
|
218
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
219
|
+
return errorStatus;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async deleteVoicemail(messageId) {
|
|
223
|
+
const loggerContext = {
|
|
224
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
225
|
+
method: 'deleteVoicemail',
|
|
226
|
+
};
|
|
227
|
+
try {
|
|
228
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
229
|
+
const response = await this.webex.request({
|
|
230
|
+
uri: voicemailContentUrl,
|
|
231
|
+
method: HTTP_METHODS.DELETE,
|
|
232
|
+
});
|
|
233
|
+
const responseDetails = {
|
|
234
|
+
statusCode: response.statusCode,
|
|
235
|
+
data: {},
|
|
236
|
+
message: SUCCESS_MESSAGE,
|
|
237
|
+
};
|
|
238
|
+
return responseDetails;
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
const errorInfo = err;
|
|
242
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
243
|
+
return errorStatus;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async getVMTranscript(messageId) {
|
|
247
|
+
const loggerContext = {
|
|
248
|
+
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
249
|
+
method: 'getVMTranscript',
|
|
250
|
+
};
|
|
251
|
+
try {
|
|
252
|
+
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${TRANSCRIPT}`;
|
|
253
|
+
const response = await this.webex.request({
|
|
254
|
+
uri: voicemailContentUrl,
|
|
255
|
+
method: HTTP_METHODS.GET,
|
|
256
|
+
});
|
|
257
|
+
const parser = new DOMParser();
|
|
258
|
+
const xmlDOM = parser.parseFromString(response[RAW_REQUEST].response, XML_TYPE);
|
|
259
|
+
const status = xmlDOM.getElementsByTagName(TRANSCRIPT_STATUS)[0];
|
|
260
|
+
const transcript = xmlDOM.getElementsByTagName(TRANSCRIPT_CONTENT)[0];
|
|
261
|
+
const responseDetails = {
|
|
262
|
+
statusCode: response.statusCode,
|
|
263
|
+
data: {
|
|
264
|
+
voicemailTranscript: transcript?.textContent,
|
|
265
|
+
},
|
|
266
|
+
message: status.textContent,
|
|
267
|
+
};
|
|
268
|
+
return responseDetails;
|
|
269
|
+
}
|
|
270
|
+
catch (err) {
|
|
271
|
+
const errorInfo = err;
|
|
272
|
+
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
273
|
+
return errorStatus;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
resolveContact(callingPartyInfo) {
|
|
277
|
+
return resolveContact(callingPartyInfo);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const API_V1 = 'api/v1';
|
|
2
|
+
export const VOICEMAIL_FILE = 'VoicemailClient';
|
|
3
|
+
export const BROADWORKS_VOICEMAIL_FILE = 'BroadworksBackendConnector';
|
|
4
|
+
export const CALLS = 'calls';
|
|
5
|
+
export const BW_TOKEN_FETCH_ENDPOINT = '/idp/bwtoken/fetch';
|
|
6
|
+
export const JSON_FORMAT = '?format=json';
|
|
7
|
+
export const LIMIT = '&limit';
|
|
8
|
+
export const MARK_AS_READ = 'MarkAsRead';
|
|
9
|
+
export const MARK_AS_UNREAD = 'MarkAsUnread';
|
|
10
|
+
export const MESSAGE_MEDIA_CONTENT = 'messageMediaContent';
|
|
11
|
+
export const MESSAGE_SUMMARY = 'MessageSummary';
|
|
12
|
+
export const NO_VOICEMAIL_MSG = 'No additional voicemails';
|
|
13
|
+
export const NO_VOICEMAIL_STATUS_CODE = 204;
|
|
14
|
+
export const OFFSET = '?offset';
|
|
15
|
+
export const OFFSET_INDEX = 0;
|
|
16
|
+
export const OFFSET_LIMIT = 100;
|
|
17
|
+
export const PREFIX = 2;
|
|
18
|
+
export const RADIX_RAND = 36;
|
|
19
|
+
export const SORT_ORDER = '&sortOrder';
|
|
20
|
+
export const TRANSCRIPT_STATUS = 'status';
|
|
21
|
+
export const SUMMARY = 'summary';
|
|
22
|
+
export const TRANSCRIPT_CONTENT = 'content';
|
|
23
|
+
export const VMGATEWAY = 'vmgateway';
|
|
24
|
+
export const VOICEMAILS = 'voicemails';
|
|
25
|
+
export const VOICE_MESSAGING_MESSAGES = 'VoiceMessagingMessages';
|
|
26
|
+
export const NEW_MESSAGES = 'newMessages';
|
|
27
|
+
export const OLD_MESSAGES = 'oldMessages';
|
|
28
|
+
export const NEW_URGENT_MESSAGES = 'newUrgentMessages';
|
|
29
|
+
export const OLD_URGENT_MESSAGES = 'oldUrgentMessages';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|