230 lines
8.3 KiB
TypeScript
230 lines
8.3 KiB
TypeScript
import getResponseWithoutCors from "@universal-call-sdk/common/lib/utils/getResponseWithoutCors.ts";
|
|
import {CallTransferData, RequestKeys} from "./types";
|
|
import RequestType from "@universal-call-sdk/common/lib/types/RequestType.ts";
|
|
|
|
|
|
export const loginInAmeyo = (userId: string, password: string) => {
|
|
console.log('loginInAmeyo', userId, password);
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/userLogin/login`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.AMEYO_LOGIN,
|
|
requestType: RequestType.JSON,
|
|
data: {
|
|
domain: window.AMEYO_LOGIN_URL,
|
|
userId: userId,
|
|
token: password,
|
|
userDetails: null,
|
|
clientType: null,
|
|
clientVersion: null,
|
|
forceLogin: true,
|
|
properties: null,
|
|
captchaAuthenticationInputBean: null,
|
|
requestId: null
|
|
}
|
|
});
|
|
};
|
|
export const maintainHeartbeat = (sessionId: string, webcoreTimestamp: string, counter: number) => {
|
|
const HEART_BEAT_REQUEST_TEXT = `7|0|8|${window.BASE_AMEYO_URL}/app/application_ui/|93B024BCBAF3AE5EFEC49890FE64CF5F|com.drishti.ameyo.common.ui.rpc.CommonGwtRpcService|keepAliveWithPingPush|java.lang.String/2004016611|java.lang.Integer/3438268394|${sessionId}|${webcoreTimestamp}|1|2|3|4|3|5|5|6|7|8|6|${counter}|${sessionId}|`;
|
|
setInterval(() => getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyo40/service`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.AMEYO_HEARTBEAT,
|
|
requestType: RequestType.RAW,
|
|
data: HEART_BEAT_REQUEST_TEXT,
|
|
headers: {
|
|
'Content-Type': 'text/x-gwt-rpc; charset=UTF-8',
|
|
'X-GWT-Permutation': '11B39EE372921423BCA4DF11986A500D'
|
|
}
|
|
}), 20000); //20s
|
|
};
|
|
|
|
export const setAgentOnBreak = (sessionId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/cc/userBreak`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.AMEYO_ON_BREAK,
|
|
requestType: RequestType.JSON,
|
|
headers: {
|
|
sessionId: sessionId
|
|
},
|
|
data: {
|
|
breakReason: 'Lunch',
|
|
breakSubCause: null,
|
|
sessionId: 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',
|
|
requestKey: RequestKeys.OMNIQUEUE_SERVICE,
|
|
requestType: RequestType.RAW,
|
|
data: OMNIQUEUE_TEXT,
|
|
headers: {
|
|
'Content-Type': 'text/x-gwt-rpc; charset=UTF-8',
|
|
'X-GWT-Permutation': '11B39EE372921423BCA4DF11986A500D'
|
|
}
|
|
});
|
|
};
|
|
|
|
export const setAgentActive = (sessionId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/cc/userReady`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.AMEYO_AVAILABLE,
|
|
requestType: RequestType.JSON,
|
|
headers: {
|
|
sessionId: sessionId
|
|
},
|
|
data: {
|
|
sessionId: sessionId,
|
|
status: 'Available'
|
|
}
|
|
});
|
|
};
|
|
|
|
export const getSipAccountInfo = (sessionId: string, userId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/sipAccountInfos/getSipAccountInfo?info=false`,
|
|
method: 'GET',
|
|
requestKey: RequestKeys.SIP_ACCOUNT_INFO,
|
|
requestType: RequestType.JSON,
|
|
data: {},
|
|
headers: {
|
|
sessionId: sessionId,
|
|
userId: userId
|
|
}
|
|
});
|
|
};
|
|
|
|
export const autoSelectExtension = (sessionId: string, userId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/autoSelectExtension`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.AUTO_SELECT_EXTENSION,
|
|
requestType: RequestType.JSON,
|
|
data: {
|
|
sessionId: sessionId,
|
|
params: {'user.id': userId}
|
|
},
|
|
headers: {
|
|
sessionId: 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',
|
|
requestKey: RequestKeys.SELECT_CAMPAIGN,
|
|
requestType: RequestType.RAW,
|
|
data: SELECT_CAMPAIGN_TEXT,
|
|
headers: {
|
|
'Content-Type': 'text/x-gwt-rpc; charset=UTF-8',
|
|
'X-GWT-Permutation': '11B39EE372921423BCA4DF11986A500D'
|
|
}
|
|
});
|
|
};
|
|
|
|
export const setAutoStatus = (sessionId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/cc/setAutoStatusForUser`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.SET_AUTO_STATUS,
|
|
requestType: RequestType.JSON,
|
|
data: {userSessionId: sessionId, status: true},
|
|
headers: {
|
|
sessionId: sessionId
|
|
}
|
|
});
|
|
};
|
|
|
|
export const ameyoHangupUser = (sessionId: string, userCRTObjectId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/hangupUser`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.HANGUP_USER,
|
|
requestType: RequestType.JSON,
|
|
data: {sessionId, userCRTObjectId},
|
|
headers: {
|
|
sessionId
|
|
}
|
|
});
|
|
};
|
|
|
|
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.DISPOSE_CALL,
|
|
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`,
|
|
method: 'GET',
|
|
requestKey: RequestKeys.GET_CAMPAIGN_ID,
|
|
requestType: RequestType.JSON,
|
|
data : {},
|
|
headers: {
|
|
sessionId
|
|
}
|
|
});
|
|
}
|
|
|
|
export const getAllAgentsForTransferCall = (sessionId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/getAllUserCampaignVoicePresencesByContactCenterId`,
|
|
method: 'GET',
|
|
requestKey: RequestKeys.GET_AGENTS_FOR_CALL_TRANSFER,
|
|
requestType: RequestType.JSON,
|
|
data: {},
|
|
headers: {
|
|
sessionId
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
export const transferCallToAgent = (data: CallTransferData, sessionId: string, crtObjectId: string, userCRTObjectId: string, campaignId: string) => {
|
|
return getResponseWithoutCors({
|
|
url: `${window.BASE_AMEYO_URL}/ameyorestapi/voice/transferToUserInDifferentCampaign`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.TRANSFER_CALL_TO_AGENT,
|
|
requestType: RequestType.JSON,
|
|
data: {
|
|
sourceCampaignId: campaignId,
|
|
sourceCRTObjectId: userCRTObjectId,
|
|
targetCampaignId: data?.campaignId,
|
|
targetCRTObjectId: data?.targetCRTObjectId,
|
|
transferredCRTObjectIds: [crtObjectId],
|
|
"requestId": "48ae79ab-faad-21f5-b694-ad3d9e4e0690"
|
|
},
|
|
headers: {
|
|
sessionId
|
|
}
|
|
});
|
|
}
|
|
|