From 98fcd359632f4e4637e59c0c6a205a1056fa989a Mon Sep 17 00:00:00 2001 From: Mayank Singh Date: Sun, 17 Nov 2024 20:51:56 +0530 Subject: [PATCH] TP-89230 | campaign id fix --- packages/adapter-ameyo/lib/api.ts | 24 ++++++++++++++++++------ packages/adapter-ameyo/lib/main.ts | 15 +++++++++++---- packages/adapter-ameyo/lib/types.ts | 5 +++-- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/packages/adapter-ameyo/lib/api.ts b/packages/adapter-ameyo/lib/api.ts index dc8476d..d433dc7 100644 --- a/packages/adapter-ameyo/lib/api.ts +++ b/packages/adapter-ameyo/lib/api.ts @@ -6,7 +6,6 @@ import RequestType from "@universal-call-sdk/common/lib/types/RequestType.ts"; export const loginInAmeyo = (userId: string, password: string) => { console.log('loginInAmeyo', userId, password); - console.log("***"); return getResponseWithoutCors({ url: `${window.BASE_AMEYO_URL}/ameyorestapi/userLogin/login`, method: 'POST', @@ -58,8 +57,8 @@ export const setAgentOnBreak = (sessionId: string) => { }); }; -export const attachOmniqueService = (sessionId: string, userId: string) => { - const OMNIQUEUE_TEXT = `7|0|9|${window.BASE_AMEYO_URL}/app/application_ui/|5B1786BFF89E87DC6EAAACDE629A89E2|com.drishti.ameyo.omniqueue.shared.CommonGwtRpcService|selectCamapign|java.lang.String/2004016611|[Ljava.lang.Integer;/1574882222|${sessionId}|${userId}|java.lang.Integer/3438268394|1|2|3|4|3|5|5|6|7|8|6|1|9|482|${sessionId}|`; +export const attachOmniqueService = (sessionId: string, userId: string, campaignId: string) => { + const OMNIQUEUE_TEXT = `7|0|9|${window.BASE_AMEYO_URL}/app/application_ui/|5B1786BFF89E87DC6EAAACDE629A89E2|com.drishti.ameyo.omniqueue.shared.CommonGwtRpcService|selectCamapign|java.lang.String/2004016611|[Ljava.lang.Integer;/1574882222|${sessionId}|${userId}|java.lang.Integer/3438268394|1|2|3|4|3|5|5|6|7|8|6|1|9|${campaignId}|${sessionId}|`; return getResponseWithoutCors({ url: `${window.BASE_AMEYO_URL}/ameyoomniqueue/service`, method: 'POST', @@ -119,8 +118,8 @@ export const autoSelectExtension = (sessionId: string, userId: string) => { }); }; -export const selectCampaign = (sessionId: string, userId: string) => { - const SELECT_CAMPAIGN_TEXT = `7|0|9|${window.BASE_AMEYO_URL}/app/application_ui/|5B1786BFF89E87DC6EAAACDE629A89E2|com.drishti.ameyo.omniqueue.shared.CommonGwtRpcService|selectCamapign|java.lang.String/2004016611|[Ljava.lang.Integer;/1574882222|${sessionId}|${userId}|java.lang.Integer/3438268394|1|2|3|4|3|5|5|6|7|8|6|1|9|5|${sessionId}|`; +export const selectCampaign = (sessionId: string, userId: string, campaignId: string) => { + const SELECT_CAMPAIGN_TEXT = `7|0|9|${window.BASE_AMEYO_URL}/app/application_ui/|5B1786BFF89E87DC6EAAACDE629A89E2|com.drishti.ameyo.omniqueue.shared.CommonGwtRpcService|selectCamapign|java.lang.String/2004016611|[Ljava.lang.Integer;/1574882222|${sessionId}|${userId}|java.lang.Integer/3438268394|1|2|3|4|3|5|5|6|7|8|6|1|9|${campaignId}|${sessionId}|`; return getResponseWithoutCors({ url: `${window.BASE_AMEYO_URL}/ameyoomniqueue/service`, method: 'POST', @@ -149,7 +148,7 @@ export const setAutoStatus = (sessionId: string) => { export const ameyoHangupUser = (sessionId: string, userCRTObjectId: string) => { return getResponseWithoutCors({ - url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/hangupUser s`, + url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/hangupUser`, method: 'POST', requestKey: RequestKeys.HANGUP_USER, requestType: RequestType.JSON, @@ -159,3 +158,16 @@ export const ameyoHangupUser = (sessionId: string, userCRTObjectId: string) => { } }); }; + +export const getCampaignId = (sessionId: string) => { + return getResponseWithoutCors({ + url: `${window.BASE_AMEYO_URL}/ameyorestapi/cc/getAllSessionData`, + method: 'GET', + requestKey: RequestKeys.GET_CAMPAIGN_ID, + requestType: RequestType.JSON, + data : {}, + headers: { + sessionId + } + }); +} diff --git a/packages/adapter-ameyo/lib/main.ts b/packages/adapter-ameyo/lib/main.ts index 00c398f..0eb1774 100644 --- a/packages/adapter-ameyo/lib/main.ts +++ b/packages/adapter-ameyo/lib/main.ts @@ -10,7 +10,8 @@ import { loginInAmeyo, maintainHeartbeat, selectCampaign, setAgentActive, setAgentOnBreak, - setAutoStatus + setAutoStatus, + getCampaignId } from "./api.ts"; import { acceptSipCall, @@ -34,6 +35,7 @@ class AmeyoAdapter implements IAdapter { private eventListenerUrl: string; private baseUrl: string; private sessionId: string; + private campaignId: string; private userName: string; private password: string; private currentCallMetadata: GenericObject; @@ -59,6 +61,7 @@ class AmeyoAdapter implements IAdapter { this.sessionId = ''; this.userName = options.userName; this.password = options.password; + this.campaignId = ''; this.sipAccountInfo = {}; this.currentCallMetadata= {}; this.isAgentAvailable= false; @@ -110,10 +113,14 @@ class AmeyoAdapter implements IAdapter { domain: response?.domain, password: response?.secret }); - this.sipAccountInfo = payload?.data?.response; console.log('sip account info', this.sipAccountInfo) + this.sipAccountInfo = payload?.data?.response; + getCampaignId(this.sessionId); setAutoStatus(this.sessionId); - attachOmniqueService(this.sessionId, this.userName.toLowerCase()); + } + if(payload?.data?.requestKey === RequestKeys.GET_CAMPAIGN_ID) { + this.campaignId = payload?.data?.response?.campaignInfos?.campaignId; + attachOmniqueService(this.sessionId, this.userName.toLowerCase(), this.campaignId); } if(payload?.data?.requestKey === RequestKeys.AMEYO_AVAILABLE) { setAutoStatus(this.sessionId); @@ -122,7 +129,7 @@ class AmeyoAdapter implements IAdapter { } if (payload?.data?.requestKey === RequestKeys.OMNIQUEUE_SERVICE) { - selectCampaign(this.sessionId, this.userName.toLowerCase()); + selectCampaign(this.sessionId, this.userName.toLowerCase(), this.campaignId); } if(payload?.data?.requestKey === RequestKeys.SELECT_CAMPAIGN) { console.log('campaign selected', payload?.data?.response); diff --git a/packages/adapter-ameyo/lib/types.ts b/packages/adapter-ameyo/lib/types.ts index ff75f9b..1d84b22 100644 --- a/packages/adapter-ameyo/lib/types.ts +++ b/packages/adapter-ameyo/lib/types.ts @@ -22,7 +22,8 @@ export enum RequestKeys { SELECT_CAMPAIGN = 'select_campaign', HANGUP_USER = 'hangup_user', AUTO_SELECT_EXTENSION = 'auto_select_extension', - SET_AUTO_STATUS = "set_auto_status" + SET_AUTO_STATUS = "set_auto_status", + GET_CAMPAIGN_ID = "get_campaign_id", } export type AmeyoInitializationOptions = { @@ -53,4 +54,4 @@ export type SipAccountInfo = { userName: string, domain: string, password: string -} \ No newline at end of file +}