162 lines
6.0 KiB
TypeScript
162 lines
6.0 KiB
TypeScript
import getResponseWithoutCors from "@universal-call-sdk/common/lib/utils/getResponseWithoutCors.ts";
|
|
import { 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);
|
|
console.log("***");
|
|
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) => {
|
|
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}|`;
|
|
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) => {
|
|
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|482|${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 s`,
|
|
method: 'POST',
|
|
requestKey: RequestKeys.HANGUP_USER,
|
|
requestType: RequestType.JSON,
|
|
data: { sessionId, userCRTObjectId },
|
|
headers: {
|
|
sessionId
|
|
}
|
|
});
|
|
};
|