TP-89230 | call transfer v0
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
|
||||
|
||||
import messagingType from "../../../types/MessagingType.ts";
|
||||
import {parse} from "path";
|
||||
|
||||
export enum MessagingType {
|
||||
ON_AMEYO_CALL_INCOMING= 'onAmeyoCallIncoming',
|
||||
export enum MessagingType {
|
||||
ON_AMEYO_CALL_INCOMING = 'onAmeyoCallIncoming',
|
||||
ON_AMEYO_CALL_ACCEPTED = 'onAmeyoCallAccepted',
|
||||
ON_AMEYO_CALL_DISCONNECTED = 'onAmeyoCallDisconnected',
|
||||
ON_AMEYO_AGENT_ON_BREAK = 'onAmeyoAgentOnBreak',
|
||||
@@ -43,8 +44,8 @@ let http = createRequestObject();
|
||||
enum pushResponseTypes {
|
||||
UserCallModelUpdatedPush = 'UserCallModelUpdatedPush',
|
||||
CRMCreateNotifyPush = 'CRMCreateNotifyPush',
|
||||
UserCCRuntimeUpdatedPush= 'UserCCRuntimeUpdatedPush',
|
||||
UserLoggedOffPush= 'UserLoggedOffPush'
|
||||
UserCCRuntimeUpdatedPush = 'UserCCRuntimeUpdatedPush',
|
||||
UserLoggedOffPush = 'UserLoggedOffPush'
|
||||
}
|
||||
|
||||
export function parseQuerystring(url: string): Record<string, any> {
|
||||
@@ -69,11 +70,13 @@ function extractUserCallModelUpdatedPush(rawResponse) {
|
||||
if (jsonData?.pushType === pushResponseTypes.CRMCreateNotifyPush) {
|
||||
const crtObjectId = jsonData?.data?.crtObjectId;
|
||||
const parsedObject = parseQuerystring(jsonData?.data?.crmURL);
|
||||
const userCRTObjectId = parsedObject?.userCrtObjectId?.replace('%40', '@');
|
||||
const phoneNumber = parsedObject?.phone;
|
||||
const lan = parsedObject?.loanaccountnumber;
|
||||
const callId = parsedObject?.unique_id;
|
||||
localStorage.setItem(
|
||||
'revEngCustomerInfo',
|
||||
JSON.stringify({ phoneNumber, lan, crtObjectId })
|
||||
JSON.stringify({phoneNumber, lan, crtObjectId, userCRTObjectId, callId})
|
||||
);
|
||||
sendCallStatusMessage(res);
|
||||
}
|
||||
@@ -81,8 +84,8 @@ function extractUserCallModelUpdatedPush(rawResponse) {
|
||||
res = jsonData;
|
||||
sendCallStatusMessage(res);
|
||||
}
|
||||
if(jsonData.pushType === pushResponseTypes.UserCCRuntimeUpdatedPush) {
|
||||
const payload= jsonData?.data;
|
||||
if (jsonData.pushType === pushResponseTypes.UserCCRuntimeUpdatedPush) {
|
||||
const payload = jsonData?.data;
|
||||
//handle ameyo erroronous condition
|
||||
if (payload?.isOnBreak) {
|
||||
window.postMessage({
|
||||
@@ -93,7 +96,7 @@ function extractUserCallModelUpdatedPush(rawResponse) {
|
||||
});
|
||||
}
|
||||
}
|
||||
if(jsonData?.pushType == pushResponseTypes.UserLoggedOffPush) {
|
||||
if (jsonData?.pushType == pushResponseTypes.UserLoggedOffPush) {
|
||||
const payload = jsonData?.data;
|
||||
window.postMessage({
|
||||
type: MessagingType.ON_AMEYO_FORCED_LOGOUT,
|
||||
@@ -108,35 +111,23 @@ function extractUserCallModelUpdatedPush(rawResponse) {
|
||||
|
||||
const sendCallStatusMessage = res => {
|
||||
let message = null;
|
||||
const { phoneNumber, lan, crtObjectId } = JSON.parse(
|
||||
const data = JSON.parse(
|
||||
localStorage.getItem('revEngCustomerInfo') || '{}'
|
||||
);
|
||||
if (res?.data?.status === 'ringing') {
|
||||
message = {
|
||||
type: MessagingType.ON_AMEYO_CALL_INCOMING,
|
||||
data: {
|
||||
phoneNumber,
|
||||
lan,
|
||||
crtObjectId
|
||||
}
|
||||
data
|
||||
};
|
||||
} else if (res?.data?.status === 'connected') {
|
||||
message = {
|
||||
type: MessagingType.ON_AMEYO_CALL_ACCEPTED,
|
||||
data: {
|
||||
phoneNumber,
|
||||
lan,
|
||||
crtObjectId
|
||||
}
|
||||
data
|
||||
};
|
||||
} else if (res?.data?.status === 'hungup') {
|
||||
message = {
|
||||
type: MessagingType.ON_AMEYO_CALL_DISCONNECTED,
|
||||
data: {
|
||||
phoneNumber,
|
||||
lan,
|
||||
crtObjectId
|
||||
}
|
||||
data
|
||||
};
|
||||
}
|
||||
if (message) window.postMessage(message);
|
||||
@@ -210,9 +201,9 @@ function processResponse() {
|
||||
// response
|
||||
}
|
||||
|
||||
function processPush(pushResponse) {
|
||||
function processPush(pushResponse) {
|
||||
console.log('push response', pushResponse);
|
||||
extractUserCallModelUpdatedPush(pushResponse);
|
||||
extractUserCallModelUpdatedPush(pushResponse);
|
||||
//ajaxRequest.handleIntermediateResponse(pushResponse);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user