@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.
Files changed (120) hide show
  1. package/es/application/services/agents/AgentService.js +21 -0
  2. package/es/application/services/agents/index.js +2 -0
  3. package/es/application/services/contacts/ContactService.js +26 -0
  4. package/es/application/services/contacts/index.js +2 -0
  5. package/es/application/services/index.js +4 -1
  6. package/es/application/services/messages/MessageService.js +56 -0
  7. package/es/application/services/messages/index.js +2 -0
  8. package/es/application/services/sessions/SessionService.js +31 -1
  9. package/es/core/constants/ModuleNames.js +4 -1
  10. package/es/domain/dto/agents/getAgentsRequest.js +12 -0
  11. package/es/domain/dto/agents/index.js +1 -0
  12. package/es/domain/dto/bots/index.js +1 -2
  13. package/es/domain/dto/channels/agents/index.js +1 -2
  14. package/es/domain/dto/contacts/getContactsRequest.js +10 -0
  15. package/es/domain/dto/contacts/index.js +2 -0
  16. package/es/domain/dto/contacts/searchContactsRequest.js +11 -0
  17. package/es/domain/dto/index.js +4 -1
  18. package/es/domain/dto/messages/deleteMessageRequest.js +14 -0
  19. package/es/domain/dto/messages/getFullContentRequest.js +14 -0
  20. package/es/domain/dto/messages/getMessagesRequest.js +20 -0
  21. package/es/domain/dto/messages/getSearchedMessagesRequest.js +22 -0
  22. package/es/domain/dto/messages/index.js +8 -0
  23. package/es/domain/dto/messages/initiateSessionRequest.js +21 -0
  24. package/es/domain/dto/messages/resendMessageRequest.js +14 -0
  25. package/es/domain/dto/messages/sendAttachmentRequest.js +20 -0
  26. package/es/domain/dto/messages/sendMessageRequest.js +17 -0
  27. package/es/domain/dto/sessions/getSessionAttachmentsRequest.js +13 -0
  28. package/es/domain/dto/sessions/getSessionLastMessagesRequest.js +13 -0
  29. package/es/domain/dto/sessions/getSessionRequest.js +13 -0
  30. package/es/domain/dto/sessions/getSessionsRequest.js +26 -0
  31. package/es/domain/dto/sessions/index.js +7 -2
  32. package/es/domain/dto/sessions/markSessionAsReadRequest.js +13 -0
  33. package/es/domain/dto/sessions/updateSessionStatusRequest.js +17 -0
  34. package/es/domain/entities/Attachment/Attachment.js +22 -0
  35. package/es/domain/entities/Attachment/index.js +2 -0
  36. package/es/domain/entities/Contact/Contact.js +22 -0
  37. package/es/domain/entities/Contact/index.js +2 -0
  38. package/es/domain/entities/Message/Action.js +19 -0
  39. package/es/domain/entities/Message/ExternalInfo.js +17 -0
  40. package/es/domain/entities/Message/Info.js +21 -0
  41. package/es/domain/entities/Message/Location.js +18 -0
  42. package/es/domain/entities/Message/Message.js +45 -0
  43. package/es/domain/entities/Message/MessageWithSession.js +21 -0
  44. package/es/domain/entities/Message/index.js +6 -0
  45. package/es/domain/entities/index.js +4 -1
  46. package/es/domain/enum/actor/ActorType.js +2 -1
  47. package/es/domain/enum/index.js +2 -1
  48. package/es/domain/enum/message/MessageContentType.js +6 -0
  49. package/es/domain/enum/message/MessageDirection.js +6 -0
  50. package/es/domain/enum/message/MessageStatus.js +11 -0
  51. package/es/domain/enum/message/MessageType.js +11 -0
  52. package/es/domain/enum/message/index.js +5 -0
  53. package/es/domain/interfaces/repositories/agents/IAgentRepository.js +9 -0
  54. package/es/domain/interfaces/repositories/agents/index.js +2 -0
  55. package/es/domain/interfaces/repositories/contacts/IContactRepository.js +14 -0
  56. package/es/domain/interfaces/repositories/contacts/index.js +2 -0
  57. package/es/domain/interfaces/repositories/index.js +4 -1
  58. package/es/domain/interfaces/repositories/messages/IMessageRepository.js +43 -0
  59. package/es/domain/interfaces/repositories/messages/index.js +2 -0
  60. package/es/domain/interfaces/repositories/sessions/ISessionRepository.js +32 -2
  61. package/es/domain/schema/attachment/AttachmentSchema.js +27 -0
  62. package/es/domain/schema/attachment/index.js +2 -0
  63. package/es/domain/schema/contact/ContactSchema.js +27 -0
  64. package/es/domain/schema/contact/index.js +2 -0
  65. package/es/domain/schema/index.js +4 -1
  66. package/es/domain/schema/message/ActionSchema.js +15 -0
  67. package/es/domain/schema/message/ExternalInfoSchema.js +7 -0
  68. package/es/domain/schema/message/InfoSchema.js +21 -0
  69. package/es/domain/schema/message/LocationSchema.js +11 -0
  70. package/es/domain/schema/message/MessageSchema.js +112 -0
  71. package/es/domain/schema/message/MessageWithSessionSchema.js +10 -0
  72. package/es/domain/schema/message/index.js +7 -0
  73. package/es/frameworks/managers/ModuleFactory.js +27 -0
  74. package/es/frameworks/managers/ModuleManager.js +1 -1
  75. package/es/frameworks/sdk/IMSDK.js +15 -0
  76. package/es/frameworks/sdk/agents/AgentSDK.js +30 -0
  77. package/es/frameworks/sdk/agents/index.js +2 -0
  78. package/es/frameworks/sdk/contacts/ContactSDK.js +30 -0
  79. package/es/frameworks/sdk/contacts/index.js +2 -0
  80. package/es/frameworks/sdk/messages/MessageSDK.js +32 -0
  81. package/es/frameworks/sdk/messages/index.js +2 -0
  82. package/es/frameworks/sdk/sessions/SessionSDK.js +6 -2
  83. package/es/infrastructure/adapters/agents/agentAdapter.js +27 -0
  84. package/es/infrastructure/adapters/agents/index.js +2 -0
  85. package/es/infrastructure/adapters/attachments/AttachmentAdapter.js +24 -0
  86. package/es/infrastructure/adapters/attachments/index.js +2 -0
  87. package/es/infrastructure/adapters/contacts/contactAdapter.js +24 -0
  88. package/es/infrastructure/adapters/contacts/index.js +2 -0
  89. package/es/infrastructure/adapters/index.js +5 -1
  90. package/es/infrastructure/adapters/message/MessageAdapter.js +41 -0
  91. package/es/infrastructure/adapters/message/MessageWithSessionAdapter.js +23 -0
  92. package/es/infrastructure/adapters/message/index.js +2 -0
  93. package/es/infrastructure/api/agents/AgentAPI.js +21 -0
  94. package/es/infrastructure/api/agents/index.js +2 -0
  95. package/es/infrastructure/api/contacts/ContactAPI.js +31 -0
  96. package/es/infrastructure/api/contacts/index.js +2 -0
  97. package/es/infrastructure/api/index.js +4 -1
  98. package/es/infrastructure/api/messages/MessageAPI.js +91 -0
  99. package/es/infrastructure/api/messages/index.js +2 -0
  100. package/es/infrastructure/api/registry/agents/agentAPIRegistry.js +12 -0
  101. package/es/infrastructure/api/registry/agents/constructAgentEndPoint.js +10 -0
  102. package/es/infrastructure/api/registry/agents/index.js +2 -0
  103. package/es/infrastructure/api/registry/contacts/constructContactEndPoint.js +10 -0
  104. package/es/infrastructure/api/registry/contacts/contactAPIRegistry.js +17 -0
  105. package/es/infrastructure/api/registry/contacts/index.js +2 -0
  106. package/es/infrastructure/api/registry/getRegistryConfig.js +7 -1
  107. package/es/infrastructure/api/registry/messages/constructMessageEndPoint.js +10 -0
  108. package/es/infrastructure/api/registry/messages/index.js +2 -0
  109. package/es/infrastructure/api/registry/messages/messageAPIRegistry.js +57 -0
  110. package/es/infrastructure/api/registry/sessions/sessionAPIRegistry.js +37 -3
  111. package/es/infrastructure/api/sessions/SessionAPI.js +61 -1
  112. package/es/infrastructure/repositories/agents/AgentRepository.js +27 -0
  113. package/es/infrastructure/repositories/agents/index.js +2 -0
  114. package/es/infrastructure/repositories/contacts/ContactRepository.js +33 -0
  115. package/es/infrastructure/repositories/contacts/index.js +2 -0
  116. package/es/infrastructure/repositories/index.js +4 -1
  117. package/es/infrastructure/repositories/messages/MessageRepository.js +72 -0
  118. package/es/infrastructure/repositories/messages/index.js +2 -0
  119. package/es/infrastructure/repositories/sessions/SessionRepository.js +43 -3
  120. 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,2 @@
1
+ import ContactSDK from "./ContactSDK";
2
+ export { 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;
@@ -0,0 +1,2 @@
1
+ import MessageSDK from "./MessageSDK";
2
+ export { 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,2 @@
1
+ import AgentAdapter from "./agentAdapter";
2
+ export { AgentAdapter };
@@ -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,2 @@
1
+ import AttachmentAdapter from "./AttachmentAdapter";
2
+ export { AttachmentAdapter };
@@ -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,2 @@
1
+ import ContactAdapter from "./contactAdapter";
2
+ export { ContactAdapter };
@@ -1,3 +1,7 @@
1
1
  export * from "./channels";
2
2
  export * from "./sessions";
3
- export * from "./bots";
3
+ export * from "./bots";
4
+ export * from "./attachments";
5
+ export * from "./message";
6
+ export * from "./agents";
7
+ export * from "./contacts";
@@ -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,2 @@
1
+ import MessageAdapter from "./MessageAdapter";
2
+ export { MessageAdapter };
@@ -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,2 @@
1
+ import AgentAPI from "./AgentAPI";
2
+ export { AgentAPI };
@@ -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,2 @@
1
+ import ContactAPI from "./ContactAPI";
2
+ export { ContactAPI };
@@ -1,3 +1,6 @@
1
1
  export * from "./channels";
2
2
  export * from "./sessions";
3
- export * from "./bots";
3
+ export * from "./bots";
4
+ export * from "./messages";
5
+ export * from "./agents";
6
+ export * from "./contacts";
@@ -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,2 @@
1
+ import MessageAPI from "./MessageAPI";
2
+ export { MessageAPI };
@@ -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,10 @@
1
+ import createBaseUrl from "../createBaseUrl";
2
+ export default function constructAgentEndPoint(extra) {
3
+ const base = '/users';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -0,0 +1,2 @@
1
+ import agentAPIRegistry from "./agentAPIRegistry";
2
+ export { agentAPIRegistry };
@@ -0,0 +1,10 @@
1
+ import createBaseUrl from "../createBaseUrl";
2
+ export default function constructContactEndPoint(extra) {
3
+ const base = '/contacts';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ import contactAPIRegistry from "./contactAPIRegistry";
2
+ export { contactAPIRegistry };
@@ -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,10 @@
1
+ import createBaseUrl from "../createBaseUrl";
2
+ export default function constructMessageEndPoint(extra) {
3
+ const base = '/sessions';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -0,0 +1,2 @@
1
+ import messageAPIRegistry from "./messageAPIRegistry";
2
+ export { messageAPIRegistry };
@@ -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('/:sessionId'), HTTP_METHODS.PATCH, updateSessionAssigneeRequest());
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
  };