Skip to content

Commit f9c99a2

Browse files
authored
chore: remove deprecated methods for livechat in 8.0 (#7058)
1 parent ec27a7c commit f9c99a2

File tree

4 files changed

+91
-10
lines changed

4 files changed

+91
-10
lines changed

app/definitions/rest/v1/omnichannel.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,16 @@ export type OmnichannelEndpoints = {
136136
};
137137

138138
'livechat/inquiries.take': {
139-
POST: (params: { inquiryId: string }) => void;
139+
POST: (params: { inquiryId: string; userId?: string }) => {
140+
success: boolean;
141+
};
140142
};
141143

142144
'livechat/inquiries.returnAsInquiry': {
143-
POST: (params: { roomId: string; departmentId?: string }) => boolean;
145+
POST: (params: { roomId: string; departmentId?: string }) => {
146+
result: boolean;
147+
success: boolean;
148+
};
144149
};
145150

146151
'livechat/rooms': {
@@ -251,4 +256,38 @@ export type OmnichannelEndpoints = {
251256
};
252257
}) => void;
253258
};
259+
'livechat/agent.status': {
260+
POST: (params: { agentId?: string }) => {
261+
status: string;
262+
success: boolean;
263+
};
264+
};
265+
'livechat/room.closeByUser': {
266+
POST: (params: {
267+
rid: string;
268+
comment?: string;
269+
forceClose?: boolean;
270+
tags?: string[];
271+
generateTranscriptPdf?: boolean;
272+
transcriptEmail?: { sendToVisitor: boolean; requestData?: { email?: string; subject?: string } };
273+
}) => {
274+
success: boolean;
275+
};
276+
};
277+
'livechat/room.forward': {
278+
POST: (params: { roomId: string; userId?: string; departmentId?: string }) => {
279+
success: boolean;
280+
};
281+
};
282+
'livechat/tags': {
283+
GET: () => {
284+
tags: ILivechatTag[];
285+
success: boolean;
286+
};
287+
};
288+
'livechat/room.resumeOnHold': {
289+
POST: (params: { roomId: string }) => {
290+
success: boolean;
291+
};
292+
};
254293
};

app/definitions/rest/v1/users.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,7 @@ export type UsersEndpoints = {
6969
'users.deleteOwnAccount': {
7070
POST: (params: { password: string; confirmRelinquish: boolean }) => { success: boolean };
7171
};
72+
'users.sendConfirmationEmail': {
73+
POST: (params: { email: string }) => { success: boolean };
74+
};
7275
};

app/ee/omnichannel/lib/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import sdk from '../../../lib/services/sdk';
22
import { compareServerVersion } from '../../../lib/methods/helpers';
33
import EventEmitter from '../../../lib/methods/helpers/events';
4+
import { store as reduxStore } from '../../../lib/store/auxStore';
45
import subscribeInquiry from './subscriptions/inquiry';
56

67
export const isOmnichannelStatusAvailable = (statusLivechat: string | undefined): boolean => statusLivechat === 'available';
78

89
// RC 0.26.0
9-
export const changeLivechatStatus = () => sdk.methodCallWrapper('livechat:changeLivechatStatus');
10+
export const changeLivechatStatus = () => {
11+
const serverVersion = reduxStore.getState().server.version;
12+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) {
13+
return sdk.post('livechat/agent.status');
14+
}
15+
// Method removed in 8.0.0
16+
return sdk.methodCallWrapper('livechat:changeLivechatStatus');
17+
};
1018

1119
// RC 2.4.0
1220
// @ts-ignore
@@ -29,7 +37,14 @@ export const takeInquiry = (inquiryId: string, serverVersion: string) => {
2937
};
3038

3139
// RC 4.26
32-
export const takeResume = (roomId: string) => sdk.methodCallWrapper('livechat:resumeOnHold', roomId);
40+
export const takeResume = (roomId: string) => {
41+
const serverVersion = reduxStore.getState().server.version;
42+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) {
43+
return sdk.post('livechat/room.resumeOnHold', { roomId });
44+
}
45+
// Method removed in 8.0.0
46+
return sdk.methodCallWrapper('livechat:resumeOnHold', roomId);
47+
};
3348

3449
class Omnichannel {
3550
private inquirySub: { stop: () => void } | null;

app/lib/services/restApi.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ export const forgotPassword = (email: string) =>
106106
// RC 0.64.0
107107
sdk.post('users.forgotPassword', { email });
108108

109-
export const sendConfirmationEmail = (email: string): Promise<{ message: string; success: boolean }> =>
110-
sdk.methodCallWrapper('sendConfirmationEmail', email);
109+
export const sendConfirmationEmail = (email: string): Promise<{ success: boolean }> => {
110+
const serverVersion = reduxStore.getState().server.version;
111+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) {
112+
return sdk.post('users.sendConfirmationEmail', { email });
113+
}
114+
115+
return sdk.methodCallWrapper('sendConfirmationEmail', email);
116+
};
111117

112118
export const spotlight = (
113119
search: string,
@@ -411,11 +417,15 @@ export const getTeamListRoom = ({
411417
};
412418

413419
export const closeLivechat = (rid: string, comment?: string, tags?: string[]) => {
420+
const serverVersion = reduxStore.getState().server.version;
414421
// RC 3.2.0
415422
let params;
416423
if (tags && tags?.length) {
417424
params = { tags };
418425
}
426+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) {
427+
return sdk.post('livechat/room.closeByUser', { rid, comment, ...params });
428+
}
419429
// RC 0.29.0
420430
return sdk.methodCallWrapper('livechat:closeRoom', rid, comment, { clientAction: true, ...params });
421431
};
@@ -443,9 +453,14 @@ export const returnLivechat = (rid: string, departmentId?: string): Promise<any>
443453

444454
export const onHoldLivechat = (roomId: string) => sdk.post('livechat/room.onHold', { roomId });
445455

446-
export const forwardLivechat = (transferData: any) =>
456+
export const forwardLivechat = (transferData: any) => {
457+
const serverVersion = reduxStore.getState().server.version;
458+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) {
459+
return sdk.post('livechat/room.forward', transferData);
460+
}
447461
// RC 0.36.0
448-
sdk.methodCallWrapper('livechat:transfer', transferData);
462+
return sdk.methodCallWrapper('livechat:transfer', transferData);
463+
};
449464

450465
export const getDepartmentInfo = (departmentId: string) =>
451466
// RC 2.2.0
@@ -489,9 +504,18 @@ export const getRoutingConfig = async (): Promise<{
489504
return sdk.methodCallWrapper('livechat:getRoutingConfig');
490505
};
491506

492-
export const getTagsList = (): Promise<ILivechatTag[]> =>
507+
export const getTagsList = async (): Promise<ILivechatTag[]> => {
508+
const serverVersion = reduxStore.getState().server.version;
509+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '8.0.0')) {
510+
const result = await sdk.get('livechat/tags');
511+
if (result.success) {
512+
return result.tags || [];
513+
}
514+
return [];
515+
}
493516
// RC 2.0.0
494-
sdk.methodCallWrapper('livechat:getTagsList');
517+
return sdk.methodCallWrapper('livechat:getTagsList');
518+
};
495519

496520
export const getAgentDepartments = (uid: string) =>
497521
// RC 2.4.0

0 commit comments

Comments
 (0)