@zohoim/client-sdk 1.0.0-poc2 → 1.0.0-poc21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/config/urls/bots/bots-api-url.js +11 -0
- package/es/config/urls/bots/index.js +2 -0
- package/es/config/urls/channels/channel-agents-api-url.js +11 -0
- package/es/config/urls/channels/index.js +2 -0
- package/es/config/urls/sessions/index.js +2 -0
- package/es/config/urls/sessions/sessions-api-url.js +12 -0
- package/es/core/constants/HttpMethods.js +8 -0
- package/es/core/constants/ModuleNames.js +6 -0
- package/es/core/constants/index.js +4 -0
- package/es/core/errors/AdapterError.js +7 -0
- package/es/core/errors/index.js +3 -0
- package/es/core/utils/index.js +2 -0
- package/es/core/utils/validateSchema.js +68 -0
- package/es/domain/entities/Actor/Actor.js +23 -0
- package/es/domain/entities/Actor/index.js +2 -2
- package/es/domain/entities/Agent/Agent.js +13 -102
- package/es/domain/entities/Agent/index.js +1 -1
- package/es/domain/entities/Bot/Bot.js +23 -0
- package/es/domain/entities/Bot/index.js +2 -0
- package/es/domain/entities/Session/Session.js +36 -0
- package/es/domain/entities/Session/index.js +2 -0
- package/es/domain/entities/index.js +3 -1
- package/es/domain/enum/actor/index.js +2 -0
- package/es/domain/enum/bot/BotServiceType.js +5 -0
- package/es/domain/enum/bot/index.js +2 -0
- package/es/domain/enum/index.js +4 -0
- package/es/domain/enum/integrationServices/IntegrationServices.js +11 -0
- package/es/domain/enum/integrationServices/index.js +2 -0
- package/es/domain/enum/session/SessionReplyStatus.js +20 -0
- package/es/domain/enum/session/SessionStatus.js +9 -0
- package/es/domain/enum/session/index.js +3 -0
- package/es/domain/interfaces/BaseAPI.js +63 -0
- package/es/domain/interfaces/bots/IBot.js +10 -0
- package/es/domain/interfaces/bots/index.js +2 -0
- package/es/domain/interfaces/channels/IChannelAgent.js +6 -2
- package/es/domain/interfaces/index.js +3 -1
- package/es/domain/interfaces/sessions/ISession.js +10 -0
- package/es/domain/interfaces/sessions/index.js +2 -0
- package/es/domain/schema/actor/ActorSchema.js +33 -0
- package/es/domain/schema/actor/AgentSchema.js +29 -0
- package/es/domain/schema/actor/index.js +3 -0
- package/es/domain/schema/bot/BotSchema.js +33 -0
- package/es/domain/schema/bot/index.js +2 -0
- package/es/domain/schema/index.js +3 -0
- package/es/domain/schema/session/SessionSchema.js +86 -0
- package/es/domain/schema/session/index.js +2 -0
- package/es/domain/services/bots/BotService.js +31 -0
- package/es/domain/services/bots/index.js +2 -0
- package/es/domain/services/channels/ChannelAgentService.js +23 -6
- package/es/domain/services/index.js +3 -1
- package/es/domain/services/sessions/SessionService.js +31 -0
- package/es/domain/services/sessions/index.js +2 -0
- package/es/index.js +8 -1
- package/es/infrastructure/adapters/BaseAdapter.js +23 -0
- package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
- package/es/infrastructure/adapters/bots/index.js +2 -0
- package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +35 -0
- package/es/infrastructure/adapters/channels/index.js +2 -0
- package/es/infrastructure/adapters/index.js +3 -0
- package/es/infrastructure/adapters/sessions/SessionAdapter.js +37 -0
- package/es/infrastructure/adapters/sessions/index.js +2 -0
- package/es/infrastructure/api/bots/BotAPI.js +22 -0
- package/es/infrastructure/api/bots/index.js +2 -0
- package/es/infrastructure/api/channels/ChannelAgentAPI.js +22 -0
- package/es/infrastructure/api/channels/index.js +2 -0
- package/es/infrastructure/api/index.js +3 -0
- package/es/infrastructure/api/sessions/SessionAPI.js +22 -0
- package/es/infrastructure/api/sessions/index.js +2 -0
- package/es/infrastructure/interfaces/api/bots/GetBotsRequest.js +14 -0
- package/es/infrastructure/interfaces/api/bots/index.js +2 -0
- package/es/infrastructure/interfaces/api/channels/agents/GetChannelAgentsRequest.js +13 -0
- package/es/infrastructure/interfaces/api/channels/agents/index.js +2 -0
- package/es/infrastructure/interfaces/api/channels/index.js +1 -0
- package/es/infrastructure/interfaces/api/index.js +3 -0
- package/es/infrastructure/interfaces/api/sessions/UpdateSessionAssigneeRequest.js +12 -0
- package/es/infrastructure/interfaces/api/sessions/index.js +2 -0
- package/es/infrastructure/interfaces/index.js +1 -0
- package/es/infrastructure/managers/ModuleFactory.js +31 -0
- package/es/infrastructure/managers/ModuleManager.js +44 -0
- package/es/infrastructure/managers/index.js +2 -0
- package/es/infrastructure/sdk/IMSDK.js +47 -0
- package/es/infrastructure/sdk/bots/BotSDK.js +20 -0
- package/es/infrastructure/sdk/bots/index.js +2 -0
- package/es/infrastructure/sdk/channels/ChannelSDK.js +23 -0
- package/es/infrastructure/sdk/channels/index.js +2 -0
- package/es/infrastructure/sdk/config/configRegistry.js +27 -0
- package/es/infrastructure/sdk/config/index.js +2 -0
- package/es/infrastructure/sdk/index.js +2 -0
- package/es/infrastructure/sdk/sessions/SessionSDK.js +20 -0
- package/es/infrastructure/sdk/sessions/index.js +2 -0
- package/package.json +1 -7
- package/es/domain/index.js +0 -3
- /package/es/{domain → core}/errors/ValidationError.js +0 -0
- /package/es/domain/{entities/Actor → enum/actor}/ActorType.js +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BotServiceType } from '../../enum';
|
|
2
|
+
const BotSchema = {
|
|
3
|
+
id: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
botServiceType: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
enum: [BotServiceType.DESK_GC_BOT, BotServiceType.DESK_ZIA_BOT]
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
isActive: {
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
createdTime: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
logoURL: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
createdBy: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default BotSchema;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { IntegrationServices, SessionReplyStatus, SessionStatus } from '../../enum';
|
|
2
|
+
import { ActorSchema } from '../actor';
|
|
3
|
+
const SessionSchema = {
|
|
4
|
+
channelId: {
|
|
5
|
+
type: 'string',
|
|
6
|
+
required: true
|
|
7
|
+
},
|
|
8
|
+
status: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
required: true,
|
|
11
|
+
enum: Object.values(SessionStatus)
|
|
12
|
+
},
|
|
13
|
+
createdTime: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
agentId: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: false
|
|
20
|
+
},
|
|
21
|
+
botId: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
required: false
|
|
24
|
+
},
|
|
25
|
+
actor: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
required: true,
|
|
28
|
+
schema: ActorSchema
|
|
29
|
+
},
|
|
30
|
+
subject: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
messagesCount: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
agentLastActiveTime: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
contactLastActiveTime: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
lastActiveTime: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
required: true
|
|
49
|
+
},
|
|
50
|
+
unreadMessagesCount: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
required: true
|
|
53
|
+
},
|
|
54
|
+
integrationServiceId: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
required: true,
|
|
57
|
+
enum: Object.values(IntegrationServices)
|
|
58
|
+
},
|
|
59
|
+
replyStatus: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
required: true,
|
|
62
|
+
enum: Object.values(SessionReplyStatus)
|
|
63
|
+
},
|
|
64
|
+
id: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
required: true
|
|
67
|
+
},
|
|
68
|
+
contactId: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
required: true
|
|
71
|
+
},
|
|
72
|
+
meta: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
required: false
|
|
75
|
+
},
|
|
76
|
+
assignee: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
required: false,
|
|
79
|
+
schema: ActorSchema
|
|
80
|
+
},
|
|
81
|
+
channel: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
required: true
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export default SessionSchema;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BOTS_API_URLS } from '../../../config/urls/bots';
|
|
2
|
+
import { BotAdapter } from '../../../infrastructure/adapters';
|
|
3
|
+
import { BotAPI } from '../../../infrastructure/api';
|
|
4
|
+
import { GetBotsRequest } from '../../../infrastructure/interfaces/api';
|
|
5
|
+
import { IBot } from '../../interfaces';
|
|
6
|
+
export default class BotService extends IBot {
|
|
7
|
+
constructor(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
botAPI,
|
|
10
|
+
botAdapter
|
|
11
|
+
} = _ref;
|
|
12
|
+
super();
|
|
13
|
+
this.botAPI = botAPI || new BotAPI({
|
|
14
|
+
urlConfig: BOTS_API_URLS
|
|
15
|
+
});
|
|
16
|
+
this.botAdapter = botAdapter || new BotAdapter();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getBots() {
|
|
20
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
|
|
21
|
+
const bots = await this.botAPI.getBots(request);
|
|
22
|
+
return bots.map(this.botAdapter.adapt);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
getBots: this.getBots.bind(this)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CHANNEL_AGENTS_API_URLS } from '../../../config/urls/channels';
|
|
2
|
+
import { ChannelAgentAdapter } from '../../../infrastructure/adapters';
|
|
3
|
+
import { ChannelAgentAPI } from '../../../infrastructure/api';
|
|
4
|
+
import { GetChannelAgentsRequest } from '../../../infrastructure/interfaces/api';
|
|
5
|
+
import { IChannelAgent } from '../../interfaces';
|
|
2
6
|
export default class ChannelAgentService extends IChannelAgent {
|
|
3
|
-
constructor(
|
|
7
|
+
constructor(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
channelAgentAPI,
|
|
10
|
+
channelAgentAdapter
|
|
11
|
+
} = _ref;
|
|
4
12
|
super();
|
|
5
|
-
this.
|
|
6
|
-
|
|
13
|
+
this.channelAgentAPI = channelAgentAPI || new ChannelAgentAPI({
|
|
14
|
+
urlConfig: CHANNEL_AGENTS_API_URLS
|
|
15
|
+
});
|
|
16
|
+
this.channelAgentAdapter = channelAgentAdapter || new ChannelAgentAdapter();
|
|
7
17
|
}
|
|
8
18
|
|
|
9
|
-
async
|
|
10
|
-
|
|
19
|
+
async getAgents() {
|
|
20
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetChannelAgentsRequest;
|
|
21
|
+
const channelAgents = await this.channelAgentAPI.getAgents(request);
|
|
11
22
|
return channelAgents.map(this.channelAgentAdapter.adapt);
|
|
12
23
|
}
|
|
13
24
|
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
getAgents: this.getAgents.bind(this)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
14
31
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SESSIONS_API_URLS } from '../../../config/urls/sessions';
|
|
2
|
+
import { SessionAdapter } from '../../../infrastructure/adapters';
|
|
3
|
+
import { SessionAPI } from '../../../infrastructure/api';
|
|
4
|
+
import { UpdateSessionAssigneeRequest } from '../../../infrastructure/interfaces/api';
|
|
5
|
+
import { ISession } from '../../interfaces';
|
|
6
|
+
export default class SessionService extends ISession {
|
|
7
|
+
constructor(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
sessionAPI,
|
|
10
|
+
sessionAdapter
|
|
11
|
+
} = _ref;
|
|
12
|
+
super();
|
|
13
|
+
this.sessionAPI = sessionAPI || new SessionAPI({
|
|
14
|
+
urlConfig: SESSIONS_API_URLS
|
|
15
|
+
});
|
|
16
|
+
this.sessionAdapter = sessionAdapter || new SessionAdapter();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async updateAssignee() {
|
|
20
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
|
|
21
|
+
const session = await this.sessionAPI.updateAssignee(request);
|
|
22
|
+
return this.sessionAdapter.adapt(session);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
updateAssignee: this.updateAssignee.bind(this)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
package/es/index.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export * from './domain';
|
|
1
|
+
export * from './domain/entities';
|
|
2
|
+
export * from './domain/enum';
|
|
3
|
+
export * from './domain/interfaces';
|
|
4
|
+
export * from './domain/services';
|
|
5
|
+
export * from './infrastructure/sdk';
|
|
6
|
+
export * from './infrastructure/adapters';
|
|
7
|
+
export * from './infrastructure/api';
|
|
8
|
+
export * from './infrastructure/interfaces/api';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AdapterError } from '../../core/errors';
|
|
2
|
+
/**
|
|
3
|
+
* Base adapter class that defines the contract for all adapters
|
|
4
|
+
* @abstract
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export default class BaseAdapter {
|
|
8
|
+
/**
|
|
9
|
+
* Adapts the input data to required format
|
|
10
|
+
* @param {*} data - Data to adapt
|
|
11
|
+
* @throws {AdapterError} When method is not implemented
|
|
12
|
+
*/
|
|
13
|
+
adapt(data) {
|
|
14
|
+
if (this.constructor === BaseAdapter) {
|
|
15
|
+
throw new AdapterError(`${this.constructor.name}: adapt() must be implemented by subclass`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!data) {
|
|
19
|
+
throw new AdapterError(`${this.constructor.name}: data parameter is required`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { Bot } from '../../../domain/entities';
|
|
3
|
+
import BaseAdapter from '../BaseAdapter';
|
|
4
|
+
export default class BotAdapter extends BaseAdapter {
|
|
5
|
+
static adapt(botData) {
|
|
6
|
+
if (!botData) {
|
|
7
|
+
throw new AdapterError('Bot data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Bot({
|
|
12
|
+
id: botData.id,
|
|
13
|
+
botServiceType: botData.botService.id,
|
|
14
|
+
name: botData.name,
|
|
15
|
+
isActive: botData.isActive,
|
|
16
|
+
createdTime: botData.createdTime,
|
|
17
|
+
logoURL: botData.logoURL,
|
|
18
|
+
createdBy: botData.createdBy
|
|
19
|
+
}).toJSON();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new AdapterError(`Failed to adapt bot: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import BaseAdapter from '../BaseAdapter';
|
|
2
|
+
import { AdapterError } from '../../../core/errors';
|
|
3
|
+
import { Agent } from '../../../domain/entities';
|
|
4
|
+
/**
|
|
5
|
+
* Adapter for Channel Agent data
|
|
6
|
+
* @extends BaseAdapter
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default class ChannelAgentAdapter extends BaseAdapter {
|
|
10
|
+
/**
|
|
11
|
+
* Adapts channel agent data to Agent entity
|
|
12
|
+
* @param {Object} channelAgent - Channel agent data to adapt
|
|
13
|
+
* @returns {Object} Adapted agent data
|
|
14
|
+
* @throws {AdapterError} When adaptation fails
|
|
15
|
+
*/
|
|
16
|
+
static adapt(channelAgent) {
|
|
17
|
+
if (!channelAgent) {
|
|
18
|
+
throw new AdapterError('Channel agent data is required');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
return new Agent({
|
|
23
|
+
id: channelAgent.id,
|
|
24
|
+
name: channelAgent.name,
|
|
25
|
+
email: channelAgent.email,
|
|
26
|
+
photoURL: channelAgent.photoURL || '',
|
|
27
|
+
zuid: channelAgent.zuid,
|
|
28
|
+
type: channelAgent.type
|
|
29
|
+
}).toJSON();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new AdapterError(`Failed to adapt channel agent: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import BaseAdapter from '../BaseAdapter';
|
|
2
|
+
import { AdapterError } from '../../../core/errors';
|
|
3
|
+
import { Session } from '../../../domain/entities';
|
|
4
|
+
export default class SessionAdapter extends BaseAdapter {
|
|
5
|
+
static adapt(sessionData) {
|
|
6
|
+
if (!sessionData) {
|
|
7
|
+
throw new AdapterError('Session data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Session({
|
|
12
|
+
id: sessionData.id,
|
|
13
|
+
channelId: sessionData.channelId,
|
|
14
|
+
status: sessionData.status,
|
|
15
|
+
createdTime: sessionData.createdTime,
|
|
16
|
+
agentId: sessionData.agentId,
|
|
17
|
+
botId: sessionData.botId,
|
|
18
|
+
actor: sessionData.actor,
|
|
19
|
+
subject: sessionData.subject,
|
|
20
|
+
messagesCount: sessionData.messagesCount,
|
|
21
|
+
agentLastActiveTime: sessionData.agentLastActiveTime,
|
|
22
|
+
contactLastActiveTime: sessionData.contactLastActiveTime,
|
|
23
|
+
lastActiveTime: sessionData.lastActiveTime,
|
|
24
|
+
unreadMessagesCount: sessionData.unreadMessagesCount,
|
|
25
|
+
integrationServiceId: sessionData.integrationServiceId,
|
|
26
|
+
replyStatus: sessionData.replyStatus,
|
|
27
|
+
contactId: sessionData.contactId,
|
|
28
|
+
meta: sessionData.meta,
|
|
29
|
+
assignee: sessionData.assignee,
|
|
30
|
+
channel: sessionData.channel
|
|
31
|
+
}).toJSON();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw new AdapterError(`Failed to adapt session: ${error.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IBot } from '../../../domain/interfaces';
|
|
2
|
+
import { GetBotsRequest } from '../../interfaces/api';
|
|
3
|
+
export default class BotAPI extends IBot {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
urlConfig
|
|
7
|
+
} = _ref;
|
|
8
|
+
super();
|
|
9
|
+
this.urlConfig = urlConfig;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getBots() {
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
|
|
14
|
+
const urlConfig = this.urlConfig.LIST;
|
|
15
|
+
const httpRequest = await this.request({
|
|
16
|
+
urlConfig,
|
|
17
|
+
request
|
|
18
|
+
});
|
|
19
|
+
return httpRequest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import IChannelAgent from '../../../domain/interfaces/channels/IChannelAgent';
|
|
2
|
+
import { GetChannelAgentsRequest } from '../../interfaces/api';
|
|
3
|
+
export default class ChannelAgentAPI extends IChannelAgent {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
urlConfig
|
|
7
|
+
} = _ref;
|
|
8
|
+
super();
|
|
9
|
+
this.urlConfig = urlConfig;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getAgents() {
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetChannelAgentsRequest;
|
|
14
|
+
const urlConfig = this.urlConfig.LIST;
|
|
15
|
+
const httpRequest = await this.request({
|
|
16
|
+
urlConfig,
|
|
17
|
+
request
|
|
18
|
+
});
|
|
19
|
+
return httpRequest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ISession } from '../../../domain/interfaces';
|
|
2
|
+
import { UpdateSessionAssigneeRequest } from '../../interfaces/api';
|
|
3
|
+
export default class SessionAPI extends ISession {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
urlConfig
|
|
7
|
+
} = _ref;
|
|
8
|
+
super();
|
|
9
|
+
this.urlConfig = urlConfig;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async updateAssignee() {
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
|
|
14
|
+
const urlConfig = this.urlConfig.UPDATE_SESSION_ASSIGNEE;
|
|
15
|
+
const httpRequest = await this.request({
|
|
16
|
+
urlConfig,
|
|
17
|
+
request
|
|
18
|
+
});
|
|
19
|
+
return httpRequest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './agents';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ModuleNames } from '../../core/constants';
|
|
2
|
+
import { BotSDK } from '../sdk/bots';
|
|
3
|
+
import { ChannelSDK } from '../sdk/channels';
|
|
4
|
+
import { SessionSDK } from '../sdk/sessions';
|
|
5
|
+
const ModuleFactory = {
|
|
6
|
+
[ModuleNames.CHANNELS]: _ref => {
|
|
7
|
+
let {
|
|
8
|
+
config
|
|
9
|
+
} = _ref;
|
|
10
|
+
return new ChannelSDK({
|
|
11
|
+
config
|
|
12
|
+
}).toJSON();
|
|
13
|
+
},
|
|
14
|
+
[ModuleNames.SESSIONS]: _ref2 => {
|
|
15
|
+
let {
|
|
16
|
+
config
|
|
17
|
+
} = _ref2;
|
|
18
|
+
return new SessionSDK({
|
|
19
|
+
config
|
|
20
|
+
}).toJSON();
|
|
21
|
+
},
|
|
22
|
+
[ModuleNames.BOTS]: _ref3 => {
|
|
23
|
+
let {
|
|
24
|
+
config
|
|
25
|
+
} = _ref3;
|
|
26
|
+
return new BotSDK({
|
|
27
|
+
config
|
|
28
|
+
}).toJSON();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default ModuleFactory;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ModuleNames } from '../../core/constants';
|
|
2
|
+
import ModuleFactory from './ModuleFactory';
|
|
3
|
+
export default class ModuleManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this._modules = new Map();
|
|
6
|
+
this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
initialize(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
apiConfig
|
|
12
|
+
} = _ref;
|
|
13
|
+
this.supportedModules.forEach(moduleName => {
|
|
14
|
+
const moduleConfig = apiConfig ? apiConfig[moduleName] : {} || {};
|
|
15
|
+
this.initializeModule({
|
|
16
|
+
moduleName,
|
|
17
|
+
config: moduleConfig
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initializeModule(_ref2) {
|
|
23
|
+
let {
|
|
24
|
+
moduleName,
|
|
25
|
+
config
|
|
26
|
+
} = _ref2;
|
|
27
|
+
const createModule = ModuleFactory[moduleName];
|
|
28
|
+
|
|
29
|
+
if (createModule) {
|
|
30
|
+
this._modules.set(moduleName, createModule({
|
|
31
|
+
config
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getModule(moduleName) {
|
|
37
|
+
return this._modules.get(moduleName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
hasModule(moduleName) {
|
|
41
|
+
return this._modules.has(moduleName);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|