@zohoim/client-sdk 1.0.0-poc49 → 1.0.0-poc50
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/application/services/agents/AgentService.js +21 -0
- package/es/application/services/agents/index.js +2 -0
- package/es/application/services/contacts/ContactService.js +26 -0
- package/es/application/services/contacts/index.js +2 -0
- package/es/application/services/index.js +4 -1
- package/es/application/services/messages/MessageService.js +56 -0
- package/es/application/services/messages/index.js +2 -0
- package/es/application/services/sessions/SessionService.js +31 -1
- package/es/core/constants/ModuleNames.js +4 -1
- package/es/domain/dto/agents/getAgentsRequest.js +12 -0
- package/es/domain/dto/agents/index.js +1 -0
- package/es/domain/dto/bots/index.js +1 -2
- package/es/domain/dto/channels/agents/index.js +1 -2
- package/es/domain/dto/contacts/getContactsRequest.js +10 -0
- package/es/domain/dto/contacts/index.js +2 -0
- package/es/domain/dto/contacts/searchContactsRequest.js +11 -0
- package/es/domain/dto/index.js +4 -1
- package/es/domain/dto/messages/deleteMessageRequest.js +14 -0
- package/es/domain/dto/messages/getFullContentRequest.js +14 -0
- package/es/domain/dto/messages/getMessagesRequest.js +20 -0
- package/es/domain/dto/messages/getSearchedMessagesRequest.js +22 -0
- package/es/domain/dto/messages/index.js +8 -0
- package/es/domain/dto/messages/initiateSessionRequest.js +21 -0
- package/es/domain/dto/messages/resendMessageRequest.js +14 -0
- package/es/domain/dto/messages/sendAttachmentRequest.js +20 -0
- package/es/domain/dto/messages/sendMessageRequest.js +17 -0
- package/es/domain/dto/sessions/getSessionAttachmentsRequest.js +13 -0
- package/es/domain/dto/sessions/getSessionLastMessagesRequest.js +13 -0
- package/es/domain/dto/sessions/getSessionRequest.js +13 -0
- package/es/domain/dto/sessions/getSessionsRequest.js +26 -0
- package/es/domain/dto/sessions/index.js +7 -2
- package/es/domain/dto/sessions/markSessionAsReadRequest.js +13 -0
- package/es/domain/dto/sessions/updateSessionStatusRequest.js +17 -0
- package/es/domain/entities/Attachment/Attachment.js +22 -0
- package/es/domain/entities/Attachment/index.js +2 -0
- package/es/domain/entities/Contact/Contact.js +22 -0
- package/es/domain/entities/Contact/index.js +2 -0
- package/es/domain/entities/Message/Action.js +19 -0
- package/es/domain/entities/Message/ExternalInfo.js +17 -0
- package/es/domain/entities/Message/Info.js +21 -0
- package/es/domain/entities/Message/Location.js +18 -0
- package/es/domain/entities/Message/Message.js +45 -0
- package/es/domain/entities/Message/MessageWithSession.js +21 -0
- package/es/domain/entities/Message/index.js +6 -0
- package/es/domain/entities/index.js +4 -1
- package/es/domain/enum/actor/ActorType.js +2 -1
- package/es/domain/enum/index.js +2 -1
- package/es/domain/enum/message/MessageContentType.js +6 -0
- package/es/domain/enum/message/MessageDirection.js +6 -0
- package/es/domain/enum/message/MessageStatus.js +11 -0
- package/es/domain/enum/message/MessageType.js +11 -0
- package/es/domain/enum/message/index.js +5 -0
- package/es/domain/interfaces/repositories/agents/IAgentRepository.js +9 -0
- package/es/domain/interfaces/repositories/agents/index.js +2 -0
- package/es/domain/interfaces/repositories/contacts/IContactRepository.js +14 -0
- package/es/domain/interfaces/repositories/contacts/index.js +2 -0
- package/es/domain/interfaces/repositories/index.js +4 -1
- package/es/domain/interfaces/repositories/messages/IMessageRepository.js +43 -0
- package/es/domain/interfaces/repositories/messages/index.js +2 -0
- package/es/domain/interfaces/repositories/sessions/ISessionRepository.js +32 -2
- package/es/domain/schema/attachment/AttachmentSchema.js +27 -0
- package/es/domain/schema/attachment/index.js +2 -0
- package/es/domain/schema/contact/ContactSchema.js +27 -0
- package/es/domain/schema/contact/index.js +2 -0
- package/es/domain/schema/index.js +4 -1
- package/es/domain/schema/message/ActionSchema.js +15 -0
- package/es/domain/schema/message/ExternalInfoSchema.js +7 -0
- package/es/domain/schema/message/InfoSchema.js +21 -0
- package/es/domain/schema/message/LocationSchema.js +11 -0
- package/es/domain/schema/message/MessageSchema.js +112 -0
- package/es/domain/schema/message/MessageWithSessionSchema.js +10 -0
- package/es/domain/schema/message/index.js +7 -0
- package/es/frameworks/managers/ModuleFactory.js +27 -0
- package/es/frameworks/managers/ModuleManager.js +1 -1
- package/es/frameworks/sdk/IMSDK.js +15 -0
- package/es/frameworks/sdk/agents/AgentSDK.js +30 -0
- package/es/frameworks/sdk/agents/index.js +2 -0
- package/es/frameworks/sdk/contacts/ContactSDK.js +30 -0
- package/es/frameworks/sdk/contacts/index.js +2 -0
- package/es/frameworks/sdk/messages/MessageSDK.js +32 -0
- package/es/frameworks/sdk/messages/index.js +2 -0
- package/es/frameworks/sdk/sessions/SessionSDK.js +6 -2
- package/es/infrastructure/adapters/agents/agentAdapter.js +27 -0
- package/es/infrastructure/adapters/agents/index.js +2 -0
- package/es/infrastructure/adapters/attachments/AttachmentAdapter.js +24 -0
- package/es/infrastructure/adapters/attachments/index.js +2 -0
- package/es/infrastructure/adapters/contacts/contactAdapter.js +24 -0
- package/es/infrastructure/adapters/contacts/index.js +2 -0
- package/es/infrastructure/adapters/index.js +5 -1
- package/es/infrastructure/adapters/message/MessageAdapter.js +41 -0
- package/es/infrastructure/adapters/message/MessageWithSessionAdapter.js +23 -0
- package/es/infrastructure/adapters/message/index.js +2 -0
- package/es/infrastructure/api/agents/AgentAPI.js +21 -0
- package/es/infrastructure/api/agents/index.js +2 -0
- package/es/infrastructure/api/contacts/ContactAPI.js +31 -0
- package/es/infrastructure/api/contacts/index.js +2 -0
- package/es/infrastructure/api/index.js +4 -1
- package/es/infrastructure/api/messages/MessageAPI.js +91 -0
- package/es/infrastructure/api/messages/index.js +2 -0
- package/es/infrastructure/api/registry/agents/agentAPIRegistry.js +12 -0
- package/es/infrastructure/api/registry/agents/constructAgentEndPoint.js +10 -0
- package/es/infrastructure/api/registry/agents/index.js +2 -0
- package/es/infrastructure/api/registry/contacts/constructContactEndPoint.js +10 -0
- package/es/infrastructure/api/registry/contacts/contactAPIRegistry.js +17 -0
- package/es/infrastructure/api/registry/contacts/index.js +2 -0
- package/es/infrastructure/api/registry/getRegistryConfig.js +7 -1
- package/es/infrastructure/api/registry/messages/constructMessageEndPoint.js +10 -0
- package/es/infrastructure/api/registry/messages/index.js +2 -0
- package/es/infrastructure/api/registry/messages/messageAPIRegistry.js +57 -0
- package/es/infrastructure/api/registry/sessions/sessionAPIRegistry.js +37 -3
- package/es/infrastructure/api/sessions/SessionAPI.js +61 -1
- package/es/infrastructure/repositories/agents/AgentRepository.js +27 -0
- package/es/infrastructure/repositories/agents/index.js +2 -0
- package/es/infrastructure/repositories/contacts/ContactRepository.js +33 -0
- package/es/infrastructure/repositories/contacts/index.js +2 -0
- package/es/infrastructure/repositories/index.js +4 -1
- package/es/infrastructure/repositories/messages/MessageRepository.js +72 -0
- package/es/infrastructure/repositories/messages/index.js +2 -0
- package/es/infrastructure/repositories/sessions/SessionRepository.js +43 -3
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ContactService } from "../../../application/services";
|
|
2
|
+
import { ContactRepository } from "../../../infrastructure/repositories";
|
|
3
|
+
|
|
4
|
+
class ContactSDK {
|
|
5
|
+
constructor(_ref) {
|
|
6
|
+
const {
|
|
7
|
+
config
|
|
8
|
+
} = _ref;
|
|
9
|
+
const {
|
|
10
|
+
contactAPI,
|
|
11
|
+
contactAdapter
|
|
12
|
+
} = config;
|
|
13
|
+
const contactRepository = new ContactRepository({
|
|
14
|
+
contactAPI,
|
|
15
|
+
contactAdapter
|
|
16
|
+
}).toJSON();
|
|
17
|
+
const contactService = new ContactService({
|
|
18
|
+
contactRepository
|
|
19
|
+
}).toJSON();
|
|
20
|
+
this.services = { ...contactService
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toJSON() {
|
|
25
|
+
return this.services;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default ContactSDK;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MessageService } from "../../../application/services";
|
|
2
|
+
import { MessageRepository } from "../../../infrastructure/repositories";
|
|
3
|
+
|
|
4
|
+
class MessageSDK {
|
|
5
|
+
constructor(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
config
|
|
8
|
+
} = _ref;
|
|
9
|
+
const {
|
|
10
|
+
messageAPI,
|
|
11
|
+
messageAdapter,
|
|
12
|
+
messageWithSessionAdapter
|
|
13
|
+
} = config;
|
|
14
|
+
const messageRepository = new MessageRepository({
|
|
15
|
+
messageAPI,
|
|
16
|
+
messageAdapter,
|
|
17
|
+
messageWithSessionAdapter
|
|
18
|
+
}).toJSON();
|
|
19
|
+
const messageService = new MessageService({
|
|
20
|
+
messageRepository
|
|
21
|
+
}).toJSON();
|
|
22
|
+
this.services = { ...messageService
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toJSON() {
|
|
27
|
+
return this.services;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default MessageSDK;
|
|
@@ -8,11 +8,15 @@ class SessionSDK {
|
|
|
8
8
|
} = _ref;
|
|
9
9
|
const {
|
|
10
10
|
sessionAPI,
|
|
11
|
-
sessionAdapter
|
|
11
|
+
sessionAdapter,
|
|
12
|
+
attachmentAdapter,
|
|
13
|
+
messageAdapter
|
|
12
14
|
} = config;
|
|
13
15
|
const sessionRepository = new SessionRepository({
|
|
14
16
|
sessionAPI,
|
|
15
|
-
sessionAdapter
|
|
17
|
+
sessionAdapter,
|
|
18
|
+
attachmentAdapter,
|
|
19
|
+
messageAdapter
|
|
16
20
|
}).toJSON();
|
|
17
21
|
const sessionService = new SessionService({
|
|
18
22
|
sessionRepository
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Agent } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class AgentAdapter extends IAdapter {
|
|
5
|
+
adapt(agentData) {
|
|
6
|
+
if (!agentData) {
|
|
7
|
+
throw new AdapterError('Agent data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Agent({
|
|
12
|
+
id: agentData.id,
|
|
13
|
+
name: agentData.name,
|
|
14
|
+
firstName: agentData.firstName,
|
|
15
|
+
lastName: agentData.lastName,
|
|
16
|
+
email: agentData.email,
|
|
17
|
+
zuid: agentData.zuid,
|
|
18
|
+
status: agentData.status,
|
|
19
|
+
role: agentData.rolePermissionType,
|
|
20
|
+
photoURL: agentData.photoURL
|
|
21
|
+
}).toJSON();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new AdapterError(`Failed to adapt Agent: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Attachment } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class AttachmentAdapter extends IAdapter {
|
|
5
|
+
adapt(attachmentData) {
|
|
6
|
+
if (!attachmentData) {
|
|
7
|
+
throw new AdapterError('Attachment data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Attachment({
|
|
12
|
+
id: attachmentData.id,
|
|
13
|
+
name: attachmentData.name,
|
|
14
|
+
type: attachmentData.type,
|
|
15
|
+
createdTime: attachmentData.createdTime,
|
|
16
|
+
size: attachmentData.size,
|
|
17
|
+
url: attachmentData.url
|
|
18
|
+
}).toJSON();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new AdapterError(`Failed to adapt attachment: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Contact } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class ContactAdapter extends IAdapter {
|
|
5
|
+
adapt(contactData) {
|
|
6
|
+
if (!contactData) {
|
|
7
|
+
throw new AdapterError('Contact data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Contact({
|
|
12
|
+
id: contactData.id,
|
|
13
|
+
name: contactData.name,
|
|
14
|
+
photoURL: contactData.photoURL,
|
|
15
|
+
email: contactData.email,
|
|
16
|
+
mobile: contactData.mobile,
|
|
17
|
+
phone: contactData.phone
|
|
18
|
+
}).toJSON();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new AdapterError(`Failed to adapt Contact: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { Message } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
export default class MessageAdapter extends IAdapter {
|
|
5
|
+
adapt(messageData) {
|
|
6
|
+
if (!messageData) {
|
|
7
|
+
throw new AdapterError('Message data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Message({
|
|
12
|
+
id: messageData.id,
|
|
13
|
+
sessionId: messageData.sessionId,
|
|
14
|
+
displayMessage: messageData.displayMessage,
|
|
15
|
+
statusUpdatedTime: messageData.statusUpdatedTime,
|
|
16
|
+
actor: messageData.actor,
|
|
17
|
+
direction: messageData.direction,
|
|
18
|
+
createdTime: messageData.createdTime,
|
|
19
|
+
index: messageData.index,
|
|
20
|
+
replyToMessage: messageData.replyToMessage,
|
|
21
|
+
status: messageData.status,
|
|
22
|
+
info: messageData.info,
|
|
23
|
+
location: messageData.location,
|
|
24
|
+
externalInfo: messageData.externalInfo,
|
|
25
|
+
layout: messageData.layout,
|
|
26
|
+
action: messageData.action,
|
|
27
|
+
meta: messageData.meta,
|
|
28
|
+
contentType: messageData.contentType,
|
|
29
|
+
fullContentURL: messageData.fullContentURL,
|
|
30
|
+
attachment: messageData.attachment,
|
|
31
|
+
template: messageData.template,
|
|
32
|
+
type: messageData.type,
|
|
33
|
+
isRead: messageData.isRead,
|
|
34
|
+
article: messageData.article
|
|
35
|
+
}).toJSON();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new AdapterError(`Failed to adapt message: ${error.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AdapterError } from "../../../core/errors";
|
|
2
|
+
import { MessageWithSession } from "../../../domain/entities";
|
|
3
|
+
import IAdapter from "../../../domain/interfaces/IAdapter";
|
|
4
|
+
import { MessageAdapter, SessionAdapter } from "../index";
|
|
5
|
+
export default class MessageWithSessionAdapter extends IAdapter {
|
|
6
|
+
adapt(messageData) {
|
|
7
|
+
if (!messageData) {
|
|
8
|
+
throw new AdapterError('Message With Session data is required');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const message = new MessageAdapter().adapt(messageData);
|
|
12
|
+
const session = new SessionAdapter().adapt(messageData.session);
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
return new MessageWithSession({ ...message,
|
|
16
|
+
session
|
|
17
|
+
}).toJSON();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error(`Failed to adapt message with session: ${error.message}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import { getAgentsRequest } from "../../../domain/dto";
|
|
3
|
+
import BaseAPI from "../BaseAPI";
|
|
4
|
+
export default class AgentAPI extends BaseAPI {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: ModuleNames.AGENTS
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getAgents() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getAgentsRequest();
|
|
13
|
+
const operation = 'getAgents';
|
|
14
|
+
const httpRequest = await this.request({
|
|
15
|
+
request,
|
|
16
|
+
operation
|
|
17
|
+
});
|
|
18
|
+
return httpRequest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import { getContactsRequest, searchContactsRequest } from "../../../domain/dto";
|
|
3
|
+
import BaseAPI from "../BaseAPI";
|
|
4
|
+
export default class ContactAPI extends BaseAPI {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: ModuleNames.CONTACTS
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getContacts() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getContactsRequest();
|
|
13
|
+
const operation = 'getContacts';
|
|
14
|
+
const httpRequest = await this.request({
|
|
15
|
+
request,
|
|
16
|
+
operation
|
|
17
|
+
});
|
|
18
|
+
return httpRequest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async searchContacts() {
|
|
22
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : searchContactsRequest();
|
|
23
|
+
const operation = 'searchContacts';
|
|
24
|
+
const httpRequest = await this.request({
|
|
25
|
+
request,
|
|
26
|
+
operation
|
|
27
|
+
});
|
|
28
|
+
return httpRequest;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ModuleNames } from "../../../core/constants";
|
|
2
|
+
import { getMessagesRequest, deleteMessageRequest, getFullContentRequest, resendMessageRequest, sendAttachmentRequest, sendMessageRequest, initiateSessionRequest, getSearchedMessagesRequest } from "../../../domain/dto";
|
|
3
|
+
import BaseAPI from "../BaseAPI";
|
|
4
|
+
export default class MessageAPI extends BaseAPI {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
module: ModuleNames.MESSAGES
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getMessages() {
|
|
12
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getMessagesRequest();
|
|
13
|
+
const operation = 'getMessages';
|
|
14
|
+
const httpRequest = await this.request({
|
|
15
|
+
operation,
|
|
16
|
+
request
|
|
17
|
+
});
|
|
18
|
+
return httpRequest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getFullContent() {
|
|
22
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getFullContentRequest();
|
|
23
|
+
const operation = 'getFullContent';
|
|
24
|
+
const httpRequest = await this.request({
|
|
25
|
+
operation,
|
|
26
|
+
request
|
|
27
|
+
});
|
|
28
|
+
return httpRequest;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async sendMessage() {
|
|
32
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : sendMessageRequest();
|
|
33
|
+
const operation = 'sendMessage';
|
|
34
|
+
const httpRequest = await this.request({
|
|
35
|
+
operation,
|
|
36
|
+
request
|
|
37
|
+
});
|
|
38
|
+
return httpRequest;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async sendAttachment() {
|
|
42
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : sendAttachmentRequest();
|
|
43
|
+
const operation = 'sendAttachment';
|
|
44
|
+
const httpRequest = await this.request({
|
|
45
|
+
operation,
|
|
46
|
+
request
|
|
47
|
+
});
|
|
48
|
+
return httpRequest;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async resendMessage() {
|
|
52
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : resendMessageRequest();
|
|
53
|
+
const operation = 'resendMessage';
|
|
54
|
+
const httpRequest = await this.request({
|
|
55
|
+
operation,
|
|
56
|
+
request
|
|
57
|
+
});
|
|
58
|
+
return httpRequest;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async deleteMessage() {
|
|
62
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : deleteMessageRequest();
|
|
63
|
+
const operation = 'deleteMessage';
|
|
64
|
+
const httpRequest = await this.request({
|
|
65
|
+
operation,
|
|
66
|
+
request
|
|
67
|
+
});
|
|
68
|
+
return httpRequest;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async initiateSession() {
|
|
72
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initiateSessionRequest();
|
|
73
|
+
const operation = 'initiateSession';
|
|
74
|
+
const httpRequest = await this.request({
|
|
75
|
+
operation,
|
|
76
|
+
request
|
|
77
|
+
});
|
|
78
|
+
return httpRequest;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async getSearchedMessages() {
|
|
82
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getSearchedMessagesRequest();
|
|
83
|
+
const operation = 'getSearchedMessages';
|
|
84
|
+
const httpRequest = await this.request({
|
|
85
|
+
operation,
|
|
86
|
+
request
|
|
87
|
+
});
|
|
88
|
+
return httpRequest;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTTP_METHODS } from "../../../../core/constants";
|
|
2
|
+
import { getAgentsRequest } from "../../../../domain/dto";
|
|
3
|
+
import createAPIRegistry from "../createAPIRegistry";
|
|
4
|
+
import constructAgentEndPoint from "./constructAgentEndPoint";
|
|
5
|
+
|
|
6
|
+
function getAgents() {
|
|
7
|
+
return createAPIRegistry(constructAgentEndPoint(), HTTP_METHODS.GET, getAgentsRequest());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
getAgents
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HTTP_METHODS } from "../../../../core/constants";
|
|
2
|
+
import { getContactsRequest, searchContactsRequest } from "../../../../domain/dto";
|
|
3
|
+
import createAPIRegistry from "../createAPIRegistry";
|
|
4
|
+
import constructContactEndPoint from "./constructContactEndPoint";
|
|
5
|
+
|
|
6
|
+
function getContacts() {
|
|
7
|
+
return createAPIRegistry(constructContactEndPoint(), HTTP_METHODS.GET, getContactsRequest());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function searchContacts() {
|
|
11
|
+
return createAPIRegistry(constructContactEndPoint(), HTTP_METHODS.GET, searchContactsRequest());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
getContacts,
|
|
16
|
+
searchContacts
|
|
17
|
+
};
|
|
@@ -2,11 +2,17 @@ import selectn from 'selectn';
|
|
|
2
2
|
import { channelAPIRegistry } from "./channels";
|
|
3
3
|
import { sessionAPIRegistry } from "./sessions";
|
|
4
4
|
import { botAPIRegistry } from "./bots";
|
|
5
|
+
import { messageAPIRegistry } from "./messages";
|
|
6
|
+
import { agentAPIRegistry } from "./agents";
|
|
7
|
+
import { contactAPIRegistry } from "./contacts";
|
|
5
8
|
import { ModuleNames } from "../../../core/constants";
|
|
6
9
|
const APIRegistry = {
|
|
7
10
|
[ModuleNames.CHANNELS]: channelAPIRegistry,
|
|
8
11
|
[ModuleNames.SESSIONS]: sessionAPIRegistry,
|
|
9
|
-
[ModuleNames.BOTS]: botAPIRegistry
|
|
12
|
+
[ModuleNames.BOTS]: botAPIRegistry,
|
|
13
|
+
[ModuleNames.MESSAGES]: messageAPIRegistry,
|
|
14
|
+
[ModuleNames.AGENTS]: agentAPIRegistry,
|
|
15
|
+
[ModuleNames.CONTACTS]: contactAPIRegistry
|
|
10
16
|
};
|
|
11
17
|
export default function getRegistryConfig(module, operation) {
|
|
12
18
|
const moduleConfig = selectn(module, APIRegistry);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { HTTP_METHODS } from "../../../../core/constants";
|
|
2
|
+
import { deleteMessageRequest, getFullContentRequest, getMessagesRequest, initiateSessionRequest, resendMessageRequest, sendAttachmentRequest, sendMessageRequest, getSearchedMessagesRequest } from "../../../../domain/dto";
|
|
3
|
+
import constructChannelEndPoint from "../channels/constructChannelEndPoint";
|
|
4
|
+
import constructMessageEndPoint from "./constructMessageEndPoint";
|
|
5
|
+
import createAPIRegistry from "../createAPIRegistry";
|
|
6
|
+
import createBaseUrl from "../createBaseUrl";
|
|
7
|
+
const SINGLE_SESSION_URL = '/:sessionId';
|
|
8
|
+
const MESSAGES_URL = `${SINGLE_SESSION_URL}/messages`;
|
|
9
|
+
const SINGLE_MESSAGE_URL = `${MESSAGES_URL}/:messageId`;
|
|
10
|
+
const FULL_CONTENT_URL = `${SINGLE_MESSAGE_URL}/fullContent`;
|
|
11
|
+
const RESEND_MESSAGE_URL = `${SINGLE_MESSAGE_URL}/resend`;
|
|
12
|
+
const ATTACHMENTS_URL = `${SINGLE_SESSION_URL}/attachments`;
|
|
13
|
+
const INITIATE_SESSION_URL = '/:channelId/initiateSession';
|
|
14
|
+
const SEARCH_MESSAGES_URL = '/messages/search';
|
|
15
|
+
|
|
16
|
+
function getMessages() {
|
|
17
|
+
return createAPIRegistry(constructMessageEndPoint(MESSAGES_URL), HTTP_METHODS.GET, getMessagesRequest());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getFullContent() {
|
|
21
|
+
return createAPIRegistry(constructMessageEndPoint(FULL_CONTENT_URL), HTTP_METHODS.GET, getFullContentRequest());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function sendMessage() {
|
|
25
|
+
return createAPIRegistry(constructMessageEndPoint(MESSAGES_URL), HTTP_METHODS.POST, sendMessageRequest());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function sendAttachment() {
|
|
29
|
+
return createAPIRegistry(constructMessageEndPoint(ATTACHMENTS_URL), HTTP_METHODS.POST, sendAttachmentRequest());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function resendMessage() {
|
|
33
|
+
return createAPIRegistry(constructMessageEndPoint(RESEND_MESSAGE_URL), HTTP_METHODS.POST, resendMessageRequest());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function deleteMessage() {
|
|
37
|
+
return createAPIRegistry(constructMessageEndPoint(SINGLE_MESSAGE_URL), HTTP_METHODS.DELETE, deleteMessageRequest());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function initiateSession() {
|
|
41
|
+
return createAPIRegistry(constructChannelEndPoint(INITIATE_SESSION_URL), HTTP_METHODS.POST, initiateSessionRequest());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getSearchedMessages() {
|
|
45
|
+
return createAPIRegistry(createBaseUrl(SEARCH_MESSAGES_URL), HTTP_METHODS.GET, getSearchedMessagesRequest());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
getMessages,
|
|
50
|
+
getFullContent,
|
|
51
|
+
sendMessage,
|
|
52
|
+
sendAttachment,
|
|
53
|
+
resendMessage,
|
|
54
|
+
deleteMessage,
|
|
55
|
+
initiateSession,
|
|
56
|
+
getSearchedMessages
|
|
57
|
+
};
|
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
import { HTTP_METHODS } from "../../../../core/constants";
|
|
2
|
-
import { updateSessionAssigneeRequest } from "../../../../domain/dto";
|
|
2
|
+
import { updateSessionAssigneeRequest, getSessionAttachmentsRequest, getSessionLastMessagesRequest, getSessionRequest, getSessionsRequest, markSessionAsReadRequest, updateSessionStatusRequest } from "../../../../domain/dto";
|
|
3
3
|
import createAPIRegistry from "../createAPIRegistry";
|
|
4
4
|
import constructSessionEndPoint from "./constructSessionEndPoint";
|
|
5
|
+
const SINGLE_SESSION_URL = '/:sessionId';
|
|
6
|
+
const SESSION_ATTACHMENTS_URL = `${SINGLE_SESSION_URL}/attachments`;
|
|
7
|
+
const SESSION_LAST_MESSAGE = '/lastMessages';
|
|
8
|
+
const MARK_AS_READ = `${SINGLE_SESSION_URL}/markAsRead`;
|
|
5
9
|
|
|
6
10
|
function updateAssignee() {
|
|
7
|
-
return createAPIRegistry(constructSessionEndPoint(
|
|
11
|
+
return createAPIRegistry(constructSessionEndPoint(SINGLE_SESSION_URL), HTTP_METHODS.PATCH, updateSessionAssigneeRequest());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getSessions() {
|
|
15
|
+
return createAPIRegistry(constructSessionEndPoint(), HTTP_METHODS.GET, getSessionsRequest());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getSession() {
|
|
19
|
+
return createAPIRegistry(constructSessionEndPoint(SINGLE_SESSION_URL), HTTP_METHODS.GET, getSessionRequest());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getSessionAttachments() {
|
|
23
|
+
return createAPIRegistry(constructSessionEndPoint(SESSION_ATTACHMENTS_URL), HTTP_METHODS.GET, getSessionAttachmentsRequest());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getSessionLastMessages() {
|
|
27
|
+
return createAPIRegistry(constructSessionEndPoint(SESSION_LAST_MESSAGE), HTTP_METHODS.GET, getSessionLastMessagesRequest());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function markSessionAsRead() {
|
|
31
|
+
return createAPIRegistry(constructSessionEndPoint(MARK_AS_READ), HTTP_METHODS.PATCH, markSessionAsReadRequest());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function updateSessionStatus() {
|
|
35
|
+
return createAPIRegistry(constructSessionEndPoint(SINGLE_SESSION_URL), HTTP_METHODS.PATCH, updateSessionStatusRequest());
|
|
8
36
|
}
|
|
9
37
|
|
|
10
38
|
export default {
|
|
11
|
-
updateAssignee
|
|
39
|
+
updateAssignee,
|
|
40
|
+
getSessions,
|
|
41
|
+
getSession,
|
|
42
|
+
getSessionAttachments,
|
|
43
|
+
getSessionLastMessages,
|
|
44
|
+
markSessionAsRead,
|
|
45
|
+
updateSessionStatus
|
|
12
46
|
};
|