diff --git a/.npmrc b/.npmrc index 0cd84a2..5c919f0 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -registry=https://nexus.cmd.navi-tech.in/repository/npm-packages \ No newline at end of file +registry=http://localhost:4873/ diff --git a/packages/adapter-ameyo/lib/api.ts b/packages/adapter-ameyo/lib/api.ts index 054581d..321593e 100644 --- a/packages/adapter-ameyo/lib/api.ts +++ b/packages/adapter-ameyo/lib/api.ts @@ -159,6 +159,28 @@ export const ameyoHangupUser = (sessionId: string, userCRTObjectId: string) => { }); }; +export const ameyoDisposeCall = (sessionId: string, campaignId : string,crtObjectId: string, userCRTObjectId: string) => { + return getResponseWithoutCors({ + url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/disposeCall`, + method: 'POST', + requestKey: RequestKeys.HANGUP_USER, + requestType: RequestType.JSON, + data: { + sessionId, + campaignId, + crtObjectId, + userCRTObjectId, + "dispositionCodeId": 21, + "requestId": "d0045ff7-8419-0860-8621-2c67ad4eb02f", + "dispositionParams": {}, + "notes": "" + }, + headers: { + sessionId + } + }); +}; + export const getCampaignId = (sessionId: string) => { return getResponseWithoutCors({ url: `${window.BASE_AMEYO_URL}/ameyorestapi/sessionData/getAllSessionData`, diff --git a/packages/adapter-ameyo/lib/main.ts b/packages/adapter-ameyo/lib/main.ts index d82246f..caab4e6 100644 --- a/packages/adapter-ameyo/lib/main.ts +++ b/packages/adapter-ameyo/lib/main.ts @@ -11,7 +11,7 @@ import { selectCampaign, setAgentActive, setAgentOnBreak, setAutoStatus, - getCampaignId + getCampaignId, ameyoDisposeCall } from "./api.ts"; import { acceptSipCall, @@ -28,9 +28,9 @@ class AmeyoAdapter implements IAdapter { onCallConnected: (data: StateType) => void; onCallDisconnected: (data: StateType) => void; onCallIncoming: (data: StateType) => void, - onAdapterReady: ()=> void, + onAdapterReady: () => void, onAgentAvailabilityChange: (isAgentAvailable: boolean) => void - onForcedLogout: ()=>void + onForcedLogout: () => void }; private eventListenerUrl: string; private baseUrl: string; @@ -42,7 +42,7 @@ class AmeyoAdapter implements IAdapter { private sipAccountInfo: GenericObject; private isAgentAvailable: boolean; - constructor(options : AmeyoInitializationOptions) { + constructor(options: AmeyoInitializationOptions) { console.log('AmeyoAdapter constructor'); const script = document.createElement('script'); script.src = 'https://public-assets.np.navi-gi.in/jarvis/sip5ml.js'; // Assuming it's placed in the public folder @@ -51,24 +51,31 @@ class AmeyoAdapter implements IAdapter { this.baseUrl = options.baseUrl; this.eventListenerUrl = options.eventListenerUrl; this.callbacks = { - onCallIncoming: ()=> {}, - onCallConnected: ()=> {}, - onCallDisconnected: ()=> {}, - onAdapterReady: ()=> {}, - onAgentAvailabilityChange: ()=> {}, - onForcedLogout: ()=> {} + onCallIncoming: () => { + }, + onCallConnected: () => { + }, + onCallDisconnected: () => { + }, + onAdapterReady: () => { + }, + onAgentAvailabilityChange: () => { + }, + onForcedLogout: () => { + } }; this.sessionId = ''; this.userName = options.userName; this.password = options.password; this.campaignId = ''; this.sipAccountInfo = {}; - this.currentCallMetadata= {}; - this.isAgentAvailable= false; + this.currentCallMetadata = {}; + this.isAgentAvailable = false; window.BASE_AMEYO_URL = this.baseUrl; window.AMEYO_LOGIN_URL = options.loginUrl } + init() { console.log('initializing ameyo adapter'); window.addEventListener('message', this._registerMessageListener); @@ -77,7 +84,7 @@ class AmeyoAdapter implements IAdapter { } - _initializeSipStack = ({accountName, userName, domain, password}: SipAccountInfo) => { + _initializeSipStack = ({accountName, userName, domain, password}: SipAccountInfo) => { console.log('initializing sip stack'); const domainOnly = domain.split(':')[0]; const port = domain.split(':')[1]; @@ -89,7 +96,7 @@ class AmeyoAdapter implements IAdapter { } _initializeAmeyo = () => { - loginInAmeyo(this.userName?.toLowerCase(), this.password); + loginInAmeyo(this.userName?.toLowerCase(), this.password); } _onListenForCorsBypassResponse = (payload: GenericObject) => { @@ -104,7 +111,7 @@ class AmeyoAdapter implements IAdapter { if (payload?.data?.requestKey === RequestKeys.AMEYO_HEARTBEAT) { console.log('heartbeat response', payload?.data?.response); } - if(payload?.data?.requestKey === RequestKeys.SIP_ACCOUNT_INFO) { + if (payload?.data?.requestKey === RequestKeys.SIP_ACCOUNT_INFO) { console.log('sip account info', payload?.data?.response); const response = payload?.data?.response; this._initializeSipStack({ @@ -118,74 +125,77 @@ class AmeyoAdapter implements IAdapter { getCampaignId(this.sessionId); setAutoStatus(this.sessionId); } - if(payload?.data?.requestKey === RequestKeys.GET_CAMPAIGN_ID) { + if (payload?.data?.requestKey === RequestKeys.GET_CAMPAIGN_ID) { this.campaignId = payload?.data?.response?.campaignInfos?.[0]?.campaignId; attachOmniqueService(this.sessionId, this.userName.toLowerCase(), this.campaignId); } - if(payload?.data?.requestKey === RequestKeys.AMEYO_AVAILABLE) { - setAutoStatus(this.sessionId); - this.isAgentAvailable = true; - window.postMessage({ type: 'onAmeyoAvailabiltyChange', data: true }); + if (payload?.data?.requestKey === RequestKeys.AMEYO_AVAILABLE) { + setAutoStatus(this.sessionId); + this.isAgentAvailable = true; + window.postMessage({type: 'onAmeyoAvailabiltyChange', data: true}); } if (payload?.data?.requestKey === RequestKeys.OMNIQUEUE_SERVICE) { selectCampaign(this.sessionId, this.userName.toLowerCase(), this.campaignId); } - if(payload?.data?.requestKey === RequestKeys.SELECT_CAMPAIGN) { + if (payload?.data?.requestKey === RequestKeys.SELECT_CAMPAIGN) { console.log('campaign selected', payload?.data?.response); autoSelectExtension(this.sessionId, this.userName.toLowerCase()); this.callbacks.onAdapterReady(); this.callbacks.onAgentAvailabilityChange(true); - window.postMessage({ type: 'onAmeyoAvailabiltyChange', data: false }, ); + window.postMessage({type: 'onAmeyoAvailabiltyChange', data: false},); } - if(payload?.data?.requestKey === RequestKeys.AMEYO_ON_BREAK) { + if (payload?.data?.requestKey === RequestKeys.AMEYO_ON_BREAK) { setAutoStatus(this.sessionId); this.isAgentAvailable = false; this.callbacks.onAgentAvailabilityChange(false); - window.postMessage({ type: 'onAmeyoAvailabiltyChange', data: false }, ); + window.postMessage({type: 'onAmeyoAvailabiltyChange', data: false},); } } - _registerMessageListener = async ({ data }: GenericObject) => { + _registerMessageListener = async ({data}: GenericObject) => { if (data?.type === MessagingType.SET_RESPONSE_WITHOUT_CORS) { this._onListenForCorsBypassResponse(data); } - if(data?.type === MessagingType.ON_AMEYO_CALL_INCOMING) { + if (data?.type === MessagingType.ON_AMEYO_CALL_INCOMING) { this.callbacks.onCallIncoming(data?.data); this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data} } - if(data?.type === MessagingType.ON_AMEYO_CALL_ACCEPTED) { + if (data?.type === MessagingType.ON_AMEYO_CALL_ACCEPTED) { this.callbacks.onCallConnected(data?.data); this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data} } - if(data?.type === MessagingType.ON_AMEYO_CALL_DISCONNECTED) { + if (data?.type === MessagingType.ON_AMEYO_CALL_DISCONNECTED) { this.callbacks.onCallDisconnected(data?.data); ameyoHangupUser(this.sessionId, this.currentCallMetadata?.crtObjectId); this.currentCallMetadata = {...this.currentCallMetadata, ...data?.data} } - if(data?.type === MessagingType.ON_AMEYO_AGENT_ON_BREAK) { + if (data?.type === MessagingType.ON_AMEYO_AGENT_ON_BREAK) { console.log('on availability changedd') this.isAgentAvailable = false; this.callbacks.onAgentAvailabilityChange(false); } - if(data?.type === MessagingType.ON_AMEYO_FORCED_LOGOUT){ + if (data?.type === MessagingType.ON_AMEYO_FORCED_LOGOUT) { this.callbacks.onForcedLogout() } }; - registerOnCallIncoming(callback: (callState: StateType)=> void) { + + registerOnCallIncoming(callback: (callState: StateType) => void) { console.log('registerOnCallIncoming'); this.callbacks.onCallIncoming = callback; } - registerOnCallConnected(callback: (callState: StateType)=> void) { + + registerOnCallConnected(callback: (callState: StateType) => void) { console.log('registerOnCallConnected'); this.callbacks.onCallConnected = callback; } - registerOnCallDisconnected(callback: (callState: StateType)=> void) { + + registerOnCallDisconnected(callback: (callState: StateType) => void) { console.log('registerOnCallDisconnected'); this.callbacks.onCallDisconnected = callback; } - registerOnAdapterReady(callback: ()=> void) { + registerOnAdapterReady(callback: () => void) { console.log('registerOnAdapterReady'); this.callbacks.onAdapterReady = callback; } @@ -204,28 +214,36 @@ class AmeyoAdapter implements IAdapter { console.log('acceptCall'); acceptSipCall(); } + rejectCall() { console.log('rejectCall'); sipHangUp(); } + disposeCall() { + console.log('disposeCall'); + ameyoDisposeCall(this.sessionId, this.campaignId, this.currentCallMetadata?.crtObjectId, this.currentCallMetadata?.userCRTObjectId); + } + setOnBreak() { console.log('setAgentOnBreakk'); setAgentOnBreak(this.sessionId); } setAvailable() { - setAgentActive(this.sessionId); + setAgentActive(this.sessionId); } muteCall() { console.log('muteCall'); sipMuteCall(); } + unmuteCall() { console.log('unmuteCall'); sipUnmuteCall(); } + getAgentAvailability() { return this.isAgentAvailable; } diff --git a/packages/adapter-ameyo/package.json b/packages/adapter-ameyo/package.json index eae8786..2250740 100644 --- a/packages/adapter-ameyo/package.json +++ b/packages/adapter-ameyo/package.json @@ -27,5 +27,5 @@ "vite": "^5.4.8", "vite-plugin-dts": "^4.2.4" }, - "gitHead": "2b9cb67dbb3574023b6a93dc403b38aa82b58f51" + "gitHead": "2c345f2195eade5e14a659cff0bd5fa346e62e88" } diff --git a/packages/common/dist/Interfaces/IAdapter.d.ts b/packages/common/dist/Interfaces/IAdapter.d.ts index d330847..5d2be24 100644 --- a/packages/common/dist/Interfaces/IAdapter.d.ts +++ b/packages/common/dist/Interfaces/IAdapter.d.ts @@ -9,6 +9,7 @@ declare class IAdapter { acceptCall(): void; rejectCall(): void; muteCall(): void; + disposeCall(): void; unmuteCall(): void; setOnBreak(): void; setAvailable(): void; diff --git a/packages/common/dist/types/GenericObject.d.ts b/packages/common/dist/types/GenericObject.d.ts index 0852975..2eb997c 100644 --- a/packages/common/dist/types/GenericObject.d.ts +++ b/packages/common/dist/types/GenericObject.d.ts @@ -1,4 +1,5 @@ export type GenericObject = { [key: string]: any; }; +export type DummyObject = {}; export default GenericObject; diff --git a/packages/common/lib/Interfaces/IAdapter.ts b/packages/common/lib/Interfaces/IAdapter.ts index e239167..82d5f9a 100644 --- a/packages/common/lib/Interfaces/IAdapter.ts +++ b/packages/common/lib/Interfaces/IAdapter.ts @@ -13,6 +13,7 @@ class IAdapter { acceptCall() {} rejectCall() {} muteCall() {} + disposeCall() {} unmuteCall() {} setOnBreak() {} @@ -27,4 +28,4 @@ class IAdapter { } -export default IAdapter; \ No newline at end of file +export default IAdapter;