NTP-15943 | registerOnCallTransfer
This commit is contained in:
@@ -11,7 +11,7 @@ export enum MessagingType {
|
||||
ON_AMEYO_CALL_DISCONNECTED = 'onAmeyoCallDisconnected',
|
||||
ON_AMEYO_AGENT_ON_BREAK = 'onAmeyoAgentOnBreak',
|
||||
ON_AMEYO_FORCED_LOGOUT = 'onAmeyoForcedLogout',
|
||||
|
||||
ON_AMEYO_CALL_TRANSFER = 'onAmeyoCallTransfer',
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ let http = createRequestObject();
|
||||
enum pushResponseTypes {
|
||||
UserCallModelUpdatedPush = 'UserCallModelUpdatedPush',
|
||||
CustomerCallMemberUpdatedPush = 'CustomerCallMemberUpdatedPush',
|
||||
UserCallMemberUpdatedPush = 'UserCallMemberUpdatedPush',
|
||||
CRMCreateNotifyPush = 'CRMCreateNotifyPush',
|
||||
UserCCRuntimeUpdatedPush = 'UserCCRuntimeUpdatedPush',
|
||||
UserLoggedOffPush = 'UserLoggedOffPush'
|
||||
@@ -86,7 +87,7 @@ function extractUserCallModelUpdatedPush(rawResponse) {
|
||||
res = jsonData;
|
||||
sendCallStatusMessage(res);
|
||||
}
|
||||
if (jsonData.pushType === pushResponseTypes.CustomerCallMemberUpdatedPush) {
|
||||
if (jsonData?.pushType === pushResponseTypes.CustomerCallMemberUpdatedPush) {
|
||||
const payload = jsonData?.data;
|
||||
// handle for transfer call
|
||||
if (payload?.isDisposing &&
|
||||
@@ -94,7 +95,17 @@ function extractUserCallModelUpdatedPush(rawResponse) {
|
||||
payload?.status === 'hungup')
|
||||
sendCallStatusMessage(jsonData);
|
||||
}
|
||||
if (jsonData.pushType === pushResponseTypes.UserCCRuntimeUpdatedPush) {
|
||||
if (jsonData?.pushType === pushResponseTypes.UserCallMemberUpdatedPush) {
|
||||
const payload = jsonData?.data;
|
||||
// handle for transfer call
|
||||
if (payload?.associationType === 'transfer.association' && ['ringing', 'connected', 'hungup'].includes(payload?.status)) {
|
||||
window.postMessage({
|
||||
type: MessagingType.ON_AMEYO_CALL_TRANSFER,
|
||||
data: payload
|
||||
})
|
||||
}
|
||||
}
|
||||
if (jsonData?.pushType === pushResponseTypes.UserCCRuntimeUpdatedPush) {
|
||||
const payload = jsonData?.data;
|
||||
//handle ameyo erroronous condition
|
||||
if (payload?.isOnBreak) {
|
||||
|
||||
@@ -33,6 +33,7 @@ class AmeyoAdapter implements IAdapter {
|
||||
onAgentAvailabilityChange: (isAgentAvailable: boolean) => void
|
||||
onForcedLogout: () => void
|
||||
onAgentsForCallTransfer: (data: GenericObject) => void
|
||||
onCallTransfer: (data: GenericObject) => void;
|
||||
};
|
||||
private currentCallState: string;
|
||||
private eventListenerUrl: string;
|
||||
@@ -71,6 +72,8 @@ class AmeyoAdapter implements IAdapter {
|
||||
onForcedLogout: () => {
|
||||
},
|
||||
onAgentsForCallTransfer: () => {
|
||||
},
|
||||
onCallTransfer: () => {
|
||||
}
|
||||
};
|
||||
this.sessionId = '';
|
||||
@@ -194,6 +197,9 @@ class AmeyoAdapter implements IAdapter {
|
||||
if (data?.type === MessagingType.ON_AMEYO_FORCED_LOGOUT) {
|
||||
this.callbacks.onForcedLogout()
|
||||
}
|
||||
if(data?.type === MessagingType.ON_AMEYO_CALL_TRANSFER){
|
||||
this.callbacks.onCallTransfer(data?.data);
|
||||
}
|
||||
};
|
||||
|
||||
registerOnCallIncoming(callback: (callState: StateType) => void) {
|
||||
@@ -231,6 +237,10 @@ class AmeyoAdapter implements IAdapter {
|
||||
this.callbacks.onAgentsForCallTransfer = callback;
|
||||
}
|
||||
|
||||
registerOnCallTransfer(callback: (data: GenericObject) => void) {
|
||||
this.callbacks.onCallTransfer = callback;
|
||||
}
|
||||
|
||||
acceptCall() {
|
||||
console.log('acceptCall');
|
||||
acceptSipCall();
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
ON_AMEYO_CALL_DISCONNECTED = 'onAmeyoCallDisconnected',
|
||||
ON_AMEYO_AGENT_ON_BREAK = 'onAmeyoAgentOnBreak',
|
||||
ON_AMEYO_FORCED_LOGOUT = 'onAmeyoForcedLogout',
|
||||
ON_AMEYO_CALL_TRANSFER = 'onAmeyoCallTransfer',
|
||||
}
|
||||
|
||||
|
||||
export default MessagingType;
|
||||
export default MessagingType;
|
||||
|
||||
@@ -8,7 +8,7 @@ class IAdapter {
|
||||
registerOnAgentAvailabilityChange(callback: (isAgentAvailable: boolean) => void) {callback(false)}
|
||||
registerOnForcedLogoutListener(callback:()=>void) {callback()}
|
||||
registerOnAgentsForCallTransfer(callback: (data : GenericObject) => void) {callback({})}
|
||||
|
||||
registerOnCallTransfer(callback: (data: GenericObject) => void) {callback({})}
|
||||
acceptCall() {}
|
||||
rejectCall() {}
|
||||
muteCall() {}
|
||||
@@ -22,7 +22,7 @@ class IAdapter {
|
||||
getAgentAvailability(): boolean {return false}
|
||||
getLatestCallState() {return {}}
|
||||
getAvailableAgentsForCallTransfer() {}
|
||||
transferCallToAgent(data: GenericObject) {console.log("transfer call to agent", data)}
|
||||
transferCallToAgent(data: GenericObject) {}
|
||||
}
|
||||
|
||||
export default IAdapter;
|
||||
|
||||
@@ -112,6 +112,10 @@ function UseCallSdk({AdapterClass, adapterOptions}: {
|
||||
adapter.registerOnAgentsForCallTransfer(callback);
|
||||
}
|
||||
|
||||
function registerOnCallTransfer(callback: (data: GenericObject) => void) {
|
||||
adapter.registerOnCallTransfer(callback);
|
||||
}
|
||||
|
||||
function acceptCall() {
|
||||
adapter.acceptCall();
|
||||
}
|
||||
@@ -169,6 +173,7 @@ function UseCallSdk({AdapterClass, adapterOptions}: {
|
||||
registerOnAgentAvailabilityChange,
|
||||
registerOnForcedLogoutListener,
|
||||
registerOnAgentsForCallTransfer,
|
||||
registerOnCallTransfer,
|
||||
acceptCall,
|
||||
rejectCall,
|
||||
disposeCall,
|
||||
|
||||
Reference in New Issue
Block a user