@zohoim/client-sdk 0.0.5 → 1.0.0-calls1

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 (134) hide show
  1. package/es/application/services/calls/CallService.js +36 -0
  2. package/es/application/services/calls/index.js +1 -0
  3. package/es/application/services/cannedMessages/CannedMessageService.js +51 -0
  4. package/es/application/services/cannedMessages/index.js +2 -0
  5. package/es/application/services/index.js +4 -1
  6. package/es/application/services/templateMessages/TemplateMessageService.js +26 -0
  7. package/es/application/services/templateMessages/index.js +2 -0
  8. package/es/core/constants/ModuleNames.js +5 -1
  9. package/es/core/utils/validateSchema.js +60 -26
  10. package/es/domain/dto/calls/getCallRequest.js +14 -0
  11. package/es/domain/dto/calls/getCallsRequest.js +19 -0
  12. package/es/domain/dto/calls/index.js +4 -0
  13. package/es/domain/dto/calls/initiateCallRequest.js +15 -0
  14. package/es/domain/dto/calls/updateCallStatusRequest.js +16 -0
  15. package/es/domain/dto/cannedMessages/createCannedMessageRequest.js +18 -0
  16. package/es/domain/dto/cannedMessages/deleteCannedMessageRequest.js +13 -0
  17. package/es/domain/dto/cannedMessages/disableCannedMessageRequest.js +13 -0
  18. package/es/domain/dto/cannedMessages/enableCannedMessageRequest.js +13 -0
  19. package/es/domain/dto/cannedMessages/getCannedMessageRequest.js +13 -0
  20. package/es/domain/dto/cannedMessages/getCannedMessagesRequest.js +18 -0
  21. package/es/domain/dto/cannedMessages/index.js +7 -0
  22. package/es/domain/dto/cannedMessages/updateCannedMessageRequest.js +20 -0
  23. package/es/domain/dto/index.js +4 -1
  24. package/es/domain/dto/messages/initiateSessionRequest.js +2 -0
  25. package/es/domain/dto/sessions/getSessionsRequest.js +1 -0
  26. package/es/domain/dto/templateMessages/getTemplateCreditExhaustStatusRequest.js +16 -0
  27. package/es/domain/dto/templateMessages/getTemplateLanguagesRequest.js +7 -0
  28. package/es/domain/dto/templateMessages/index.js +2 -0
  29. package/es/domain/entities/Actor/Actor.js +5 -1
  30. package/es/domain/entities/Agent/Agent.js +5 -1
  31. package/es/domain/entities/Attachment/Attachment.js +5 -1
  32. package/es/domain/entities/Bot/Bot.js +5 -1
  33. package/es/domain/entities/Call/Call.js +44 -0
  34. package/es/domain/entities/Call/index.js +1 -0
  35. package/es/domain/entities/CannedMessage/CannedMessage.js +50 -0
  36. package/es/domain/entities/CannedMessage/index.js +2 -0
  37. package/es/domain/entities/Channel/Channel.js +5 -1
  38. package/es/domain/entities/Contact/Contact.js +5 -1
  39. package/es/domain/entities/CustomReplyExtension/CustomReplyExtension.js +26 -0
  40. package/es/domain/entities/CustomReplyExtension/index.js +2 -0
  41. package/es/domain/entities/IntegrationService/IntegrationService.js +5 -1
  42. package/es/domain/entities/Message/Action.js +5 -1
  43. package/es/domain/entities/Message/ExternalInfo.js +5 -1
  44. package/es/domain/entities/Message/Info.js +5 -1
  45. package/es/domain/entities/Message/InfoTarget.js +5 -1
  46. package/es/domain/entities/Message/Location.js +5 -1
  47. package/es/domain/entities/Message/Message.js +25 -2
  48. package/es/domain/entities/Message/MessageWithSession.js +5 -1
  49. package/es/domain/entities/Session/Session.js +5 -1
  50. package/es/domain/entities/TemplateMessage/TemplateCreditExhaustStatus.js +27 -0
  51. package/es/domain/entities/TemplateMessage/TemplateLanguage.js +22 -0
  52. package/es/domain/entities/TemplateMessage/index.js +3 -0
  53. package/es/domain/entities/index.js +5 -1
  54. package/es/domain/enum/call/CallStatus.js +8 -0
  55. package/es/domain/enum/call/index.js +1 -0
  56. package/es/domain/enum/cannedMessage/CannedMessageStatus.js +7 -0
  57. package/es/domain/enum/cannedMessage/CannedMessageType.js +5 -0
  58. package/es/domain/enum/cannedMessage/TemplateItemButtonType.js +6 -0
  59. package/es/domain/enum/cannedMessage/TemplateItemFooterType.js +4 -0
  60. package/es/domain/enum/cannedMessage/TemplateItemHeaderType.js +7 -0
  61. package/es/domain/enum/cannedMessage/index.js +6 -0
  62. package/es/domain/enum/index.js +4 -1
  63. package/es/domain/enum/message/MessageMeta.js +2 -1
  64. package/es/domain/enum/message/MetaMessageSourceType.js +6 -0
  65. package/es/domain/enum/message/index.js +2 -1
  66. package/es/domain/enum/templateMessage/TemplateCreditExhaustStatusCode.js +4 -0
  67. package/es/domain/enum/templateMessage/index.js +2 -0
  68. package/es/domain/interfaces/repositories/calls/ICallRepository.js +32 -0
  69. package/es/domain/interfaces/repositories/calls/index.js +1 -0
  70. package/es/domain/interfaces/repositories/cannedMessages/ICannedMessageRepository.js +47 -0
  71. package/es/domain/interfaces/repositories/cannedMessages/index.js +2 -0
  72. package/es/domain/interfaces/repositories/index.js +4 -1
  73. package/es/domain/interfaces/repositories/templateMessages/ITemplateMessageRepository.js +21 -0
  74. package/es/domain/interfaces/repositories/templateMessages/index.js +2 -0
  75. package/es/domain/schema/call/CallSchema.js +59 -0
  76. package/es/domain/schema/call/index.js +1 -0
  77. package/es/domain/schema/cannedMessage/CannedMessageSchema.js +61 -0
  78. package/es/domain/schema/cannedMessage/TemplateItem/TemplateItemButtonsSchema.js +17 -0
  79. package/es/domain/schema/cannedMessage/TemplateItem/TemplateItemFooterSchema.js +13 -0
  80. package/es/domain/schema/cannedMessage/TemplateItem/TemplateItemHeaderSchema.js +19 -0
  81. package/es/domain/schema/cannedMessage/TemplateItem/index.js +4 -0
  82. package/es/domain/schema/cannedMessage/TemplateItemsSchema.js +21 -0
  83. package/es/domain/schema/cannedMessage/TranslationsSchema.js +43 -0
  84. package/es/domain/schema/cannedMessage/index.js +2 -0
  85. package/es/domain/schema/customReplyExtension/CustomReplyExtensionSchema.js +28 -0
  86. package/es/domain/schema/customReplyExtension/index.js +2 -0
  87. package/es/domain/schema/index.js +5 -1
  88. package/es/domain/schema/templateMessage/TemplateCreditExhaustStatusSchema.js +11 -0
  89. package/es/domain/schema/templateMessage/TemplateLanguageSchema.js +11 -0
  90. package/es/domain/schema/templateMessage/index.js +3 -0
  91. package/es/frameworks/managers/ModuleFactory.js +27 -0
  92. package/es/frameworks/managers/ModuleManager.js +1 -1
  93. package/es/frameworks/sdk/IMSDK.js +15 -0
  94. package/es/frameworks/sdk/calls/CallSDK.js +27 -0
  95. package/es/frameworks/sdk/calls/index.js +1 -0
  96. package/es/frameworks/sdk/cannedMessages/CannedMessageSDK.js +30 -0
  97. package/es/frameworks/sdk/cannedMessages/index.js +2 -0
  98. package/es/frameworks/sdk/templateMessages/TemplateMessageSDK.js +30 -0
  99. package/es/frameworks/sdk/templateMessages/index.js +2 -0
  100. package/es/infrastructure/adapters/calls/CallAdapter.js +30 -0
  101. package/es/infrastructure/adapters/calls/index.js +1 -0
  102. package/es/infrastructure/adapters/cannedMessages/CannedMessageAdapter.js +28 -0
  103. package/es/infrastructure/adapters/cannedMessages/index.js +2 -0
  104. package/es/infrastructure/adapters/customReplyExtension/CustomReplyExtensionAdapter.js +24 -0
  105. package/es/infrastructure/adapters/customReplyExtension/index.js +2 -0
  106. package/es/infrastructure/adapters/index.js +5 -1
  107. package/es/infrastructure/adapters/templateMessages/TemplateCreditExhaustStatusAdapter.js +20 -0
  108. package/es/infrastructure/adapters/templateMessages/TemplateLanguageAdapter.js +20 -0
  109. package/es/infrastructure/adapters/templateMessages/index.js +3 -0
  110. package/es/infrastructure/api/calls/CallAPI.js +44 -0
  111. package/es/infrastructure/api/calls/index.js +1 -0
  112. package/es/infrastructure/api/cannedMessages/CannedMessageAPI.js +74 -0
  113. package/es/infrastructure/api/cannedMessages/index.js +2 -0
  114. package/es/infrastructure/api/index.js +4 -1
  115. package/es/infrastructure/api/registry/calls/callAPIRegistry.js +29 -0
  116. package/es/infrastructure/api/registry/calls/constructCallEndPoint.js +10 -0
  117. package/es/infrastructure/api/registry/calls/index.js +1 -0
  118. package/es/infrastructure/api/registry/cannedMessages/cannedMessageAPIRegistry.js +42 -0
  119. package/es/infrastructure/api/registry/cannedMessages/constructCannedMessageEndPoint.js +10 -0
  120. package/es/infrastructure/api/registry/cannedMessages/index.js +2 -0
  121. package/es/infrastructure/api/registry/getRegistryConfig.js +7 -1
  122. package/es/infrastructure/api/registry/templateMessages/constructTemplateMessageEndPoint.js +11 -0
  123. package/es/infrastructure/api/registry/templateMessages/index.js +2 -0
  124. package/es/infrastructure/api/registry/templateMessages/templateMessageAPIRegistry.js +18 -0
  125. package/es/infrastructure/api/templateMessages/TemplateMessageAPI.js +24 -0
  126. package/es/infrastructure/api/templateMessages/index.js +2 -0
  127. package/es/infrastructure/repositories/calls/CallRepository.js +73 -0
  128. package/es/infrastructure/repositories/calls/index.js +1 -0
  129. package/es/infrastructure/repositories/cannedMessages/CannedMessageRepository.js +97 -0
  130. package/es/infrastructure/repositories/cannedMessages/index.js +2 -0
  131. package/es/infrastructure/repositories/index.js +4 -1
  132. package/es/infrastructure/repositories/templateMessages/TemplateMessageRepository.js +77 -0
  133. package/es/infrastructure/repositories/templateMessages/index.js +2 -0
  134. package/package.json +2 -2
@@ -0,0 +1,74 @@
1
+ import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, enableCannedMessageRequest, disableCannedMessageRequest } from '../../../domain/dto';
2
+ import { ICannedMessageRepository } from '../../../domain/interfaces/repositories';
3
+ export default class CannedMessageAPI extends ICannedMessageRepository {
4
+ async getCannedMessages() {
5
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCannedMessagesRequest();
6
+ const operation = 'getCannedMessages';
7
+ const httpRequest = await this.request({
8
+ operation,
9
+ request
10
+ });
11
+ return httpRequest;
12
+ }
13
+
14
+ async getCannedMessage() {
15
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCannedMessageRequest();
16
+ const operation = 'getCannedMessage';
17
+ const httpRequest = await this.request({
18
+ operation,
19
+ request
20
+ });
21
+ return httpRequest;
22
+ }
23
+
24
+ async createCannedMessage() {
25
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : createCannedMessageRequest();
26
+ const operation = 'createCannedMessage';
27
+ const httpRequest = await this.request({
28
+ operation,
29
+ request
30
+ });
31
+ return httpRequest;
32
+ }
33
+
34
+ async updateCannedMessage() {
35
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateCannedMessageRequest();
36
+ const operation = 'updateCannedMessage';
37
+ const httpRequest = await this.request({
38
+ operation,
39
+ request
40
+ });
41
+ return httpRequest;
42
+ }
43
+
44
+ async deleteCannedMessage() {
45
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : deleteCannedMessageRequest();
46
+ const operation = 'deleteCannedMessage';
47
+ const httpRequest = await this.request({
48
+ operation,
49
+ request
50
+ });
51
+ return httpRequest;
52
+ }
53
+
54
+ async enableCannedMessage() {
55
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : enableCannedMessageRequest();
56
+ const operation = 'enableCannedMessage';
57
+ const httpRequest = await this.request({
58
+ operation,
59
+ request
60
+ });
61
+ return httpRequest;
62
+ }
63
+
64
+ async disableCannedMessage() {
65
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : disableCannedMessageRequest();
66
+ const operation = 'disableCannedMessage';
67
+ const httpRequest = await this.request({
68
+ operation,
69
+ request
70
+ });
71
+ return httpRequest;
72
+ }
73
+
74
+ }
@@ -0,0 +1,2 @@
1
+ import CannedMessageAPI from './CannedMessageAPI';
2
+ export { CannedMessageAPI };
@@ -3,4 +3,7 @@ export * from './sessions';
3
3
  export * from './bots';
4
4
  export * from './messages';
5
5
  export * from './agents';
6
- export * from './contacts';
6
+ export * from './contacts';
7
+ export * from './cannedMessages';
8
+ export * from './templateMessages';
9
+ export * from './calls';
@@ -0,0 +1,29 @@
1
+ import { HTTP_METHODS } from '../../../../core/constants';
2
+ import { getCallsRequest, getCallRequest, updateCallStatusRequest, initiateCallRequest } from '../../../../domain/dto';
3
+ import constructCallEndPoint from './constructCallEndPoint';
4
+ import createAPIRegistry from '../createAPIRegistry';
5
+ const SINGLE_CALL_URL = '/:callId';
6
+ const UPDATE_CALL_URL = `${SINGLE_CALL_URL}/status`;
7
+
8
+ function getCalls() {
9
+ return createAPIRegistry(constructCallEndPoint(), HTTP_METHODS.GET, getCallsRequest());
10
+ }
11
+
12
+ function getCall() {
13
+ return createAPIRegistry(constructCallEndPoint(SINGLE_CALL_URL), HTTP_METHODS.GET, getCallRequest());
14
+ }
15
+
16
+ function updateCallStatus() {
17
+ return createAPIRegistry(constructCallEndPoint(UPDATE_CALL_URL), HTTP_METHODS.PATCH, updateCallStatusRequest());
18
+ }
19
+
20
+ function initiateCall() {
21
+ return createAPIRegistry(constructCallEndPoint(), HTTP_METHODS.POST, initiateCallRequest());
22
+ }
23
+
24
+ export default {
25
+ getCalls,
26
+ getCall,
27
+ updateCallStatus,
28
+ initiateCall
29
+ };
@@ -0,0 +1,10 @@
1
+ import createBaseUrl from '../createBaseUrl';
2
+ export default function constructCallsEndPoint(extra) {
3
+ const base = '/calls';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -0,0 +1 @@
1
+ export { default as callAPIRegistry } from './callAPIRegistry';
@@ -0,0 +1,42 @@
1
+ import { HTTP_METHODS } from '../../../../core/constants';
2
+ import { getCannedMessageRequest, getCannedMessagesRequest, createCannedMessageRequest, updateCannedMessageRequest, deleteCannedMessageRequest, enableCannedMessageRequest, disableCannedMessageRequest } from '../../../../domain/dto';
3
+ import constructCannedMessageEndPoint from './constructCannedMessageEndPoint';
4
+ import createAPIRegistry from '../createAPIRegistry';
5
+
6
+ function getCannedMessages() {
7
+ return createAPIRegistry(constructCannedMessageEndPoint(), HTTP_METHODS.GET, getCannedMessagesRequest());
8
+ }
9
+
10
+ function getCannedMessage() {
11
+ return createAPIRegistry(constructCannedMessageEndPoint('/:cannedMessageId'), HTTP_METHODS.GET, getCannedMessageRequest());
12
+ }
13
+
14
+ function createCannedMessage() {
15
+ return createAPIRegistry(constructCannedMessageEndPoint(), HTTP_METHODS.POST, createCannedMessageRequest());
16
+ }
17
+
18
+ function updateCannedMessage() {
19
+ return createAPIRegistry(constructCannedMessageEndPoint('/:cannedMessageId'), HTTP_METHODS.PATCH, updateCannedMessageRequest());
20
+ }
21
+
22
+ function enableCannedMessage() {
23
+ return createAPIRegistry(constructCannedMessageEndPoint('/:cannedMessageId/activation'), HTTP_METHODS.PATCH, enableCannedMessageRequest());
24
+ }
25
+
26
+ function disableCannedMessage() {
27
+ return createAPIRegistry(constructCannedMessageEndPoint('/:cannedMessageId/activation'), HTTP_METHODS.DELETE, disableCannedMessageRequest());
28
+ }
29
+
30
+ function deleteCannedMessage() {
31
+ return createAPIRegistry(constructCannedMessageEndPoint('/:cannedMessageId'), HTTP_METHODS.DELETE, deleteCannedMessageRequest());
32
+ }
33
+
34
+ export default {
35
+ getCannedMessage,
36
+ getCannedMessages,
37
+ createCannedMessage,
38
+ updateCannedMessage,
39
+ deleteCannedMessage,
40
+ enableCannedMessage,
41
+ disableCannedMessage
42
+ };
@@ -0,0 +1,10 @@
1
+ import createBaseUrl from '../createBaseUrl';
2
+ export default function constructCannedMessageEndPoint(extra) {
3
+ const base = '/cannedMessages';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -0,0 +1,2 @@
1
+ import cannedMessageAPIRegistry from './cannedMessageAPIRegistry';
2
+ export { cannedMessageAPIRegistry };
@@ -5,6 +5,9 @@ import { botAPIRegistry } from './bots';
5
5
  import { messageAPIRegistry } from './messages';
6
6
  import { agentAPIRegistry } from './agents';
7
7
  import { contactAPIRegistry } from './contacts';
8
+ import { cannedMessageAPIRegistry } from './cannedMessages';
9
+ import { templateMessageAPIRegistry } from './templateMessages';
10
+ import { callAPIRegistry } from './calls';
8
11
  import { ModuleNames } from '../../../core/constants';
9
12
  const APIRegistry = {
10
13
  [ModuleNames.CHANNELS]: channelAPIRegistry,
@@ -12,7 +15,10 @@ const APIRegistry = {
12
15
  [ModuleNames.BOTS]: botAPIRegistry,
13
16
  [ModuleNames.MESSAGES]: messageAPIRegistry,
14
17
  [ModuleNames.AGENTS]: agentAPIRegistry,
15
- [ModuleNames.CONTACTS]: contactAPIRegistry
18
+ [ModuleNames.CONTACTS]: contactAPIRegistry,
19
+ [ModuleNames.CANNED_MESSAGES]: cannedMessageAPIRegistry,
20
+ [ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry,
21
+ [ModuleNames.CALLS]: callAPIRegistry
16
22
  };
17
23
  export default function getRegistryConfig(module, operation) {
18
24
  const moduleConfig = selectn(module, APIRegistry);
@@ -0,0 +1,11 @@
1
+ import { IntegrationServices } from '../../../../domain/enum';
2
+ import createBaseUrl from '../createBaseUrl';
3
+ export default function constructTemplateMessageEndPoint(extra) {
4
+ const base = `/integrations/${IntegrationServices.WHATSAPP}`;
5
+
6
+ if (extra) {
7
+ return createBaseUrl(base + extra);
8
+ }
9
+
10
+ return createBaseUrl(base);
11
+ }
@@ -0,0 +1,2 @@
1
+ import templateMessageAPIRegistry from './templateMessageAPIRegistry';
2
+ export { templateMessageAPIRegistry };
@@ -0,0 +1,18 @@
1
+ import { HTTP_METHODS } from '../../../../core/constants';
2
+ import { getTemplateLanguagesRequest, getTemplateCreditExhaustStatusRequest } from '../../../../domain/dto';
3
+ import createAPIRegistry from '../createAPIRegistry';
4
+ import constructTemplateMessageEndPoint from './constructTemplateMessageEndPoint';
5
+
6
+ function getTemplateLanguages() {
7
+ return createAPIRegistry(constructTemplateMessageEndPoint('/templateLanguages'), HTTP_METHODS.GET, getTemplateLanguagesRequest());
8
+ }
9
+
10
+ function getTemplateCreditExhaustStatus() {
11
+ return createAPIRegistry(constructTemplateMessageEndPoint('/templateCreditExhaustStatus'), // NO I18N
12
+ HTTP_METHODS.GET, getTemplateCreditExhaustStatusRequest());
13
+ }
14
+
15
+ export default {
16
+ getTemplateLanguages,
17
+ getTemplateCreditExhaustStatus
18
+ };
@@ -0,0 +1,24 @@
1
+ import { getTemplateLanguagesRequest, getTemplateCreditExhaustStatusRequest } from '../../../domain/dto';
2
+ import { ITemplateMessageRepository } from '../../../domain/interfaces/repositories';
3
+ export default class TemplateMessageAPI extends ITemplateMessageRepository {
4
+ async getTemplateLanguages() {
5
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplateLanguagesRequest();
6
+ const operation = 'getTemplateLanguages';
7
+ const httpRequest = await this.request({
8
+ request,
9
+ operation
10
+ });
11
+ return httpRequest;
12
+ }
13
+
14
+ async getWhatsAppTemplateCreditExhaustStatus() {
15
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplateCreditExhaustStatusRequest();
16
+ const operation = 'getWhatsAppTemplateCreditExhaustStatus';
17
+ const httpRequest = await this.request({
18
+ request,
19
+ operation
20
+ });
21
+ return httpRequest;
22
+ }
23
+
24
+ }
@@ -0,0 +1,2 @@
1
+ import TemplateMessageAPI from './TemplateMessageAPI';
2
+ export { TemplateMessageAPI };
@@ -0,0 +1,73 @@
1
+ import { CallAdapter } from '../../adapters';
2
+ import { CallAPI } from '../../api';
3
+ import { ICallRepository } from '../../../domain/interfaces/repositories/calls';
4
+ import { ResponseTypes } from '../../../core/constants';
5
+ export default class CallRepository extends ICallRepository {
6
+ constructor(_ref) {
7
+ let {
8
+ callAPI,
9
+ callAdapter
10
+ } = _ref;
11
+ super();
12
+ this.defaultAPI = new CallAPI();
13
+ this.customAPI = callAPI;
14
+ this.callAPI = this.createAPIProxy(this.customAPI, this.defaultAPI);
15
+ this.callAdapter = callAdapter || new CallAdapter();
16
+ }
17
+
18
+ async invokeAPI(_ref2) {
19
+ let {
20
+ operation,
21
+ request,
22
+ adapter = this.callAdapter,
23
+ responseType
24
+ } = _ref2;
25
+ return this.executeAPICall({
26
+ operation,
27
+ request,
28
+ apiProxy: this.callAPI,
29
+ customAPI: this.customAPI,
30
+ adapter,
31
+ responseType
32
+ });
33
+ }
34
+
35
+ async getCalls(request) {
36
+ return this.invokeAPI({
37
+ operation: 'getCalls',
38
+ request,
39
+ responseType: ResponseTypes.LIST
40
+ });
41
+ }
42
+
43
+ async getCall(request) {
44
+ return this.invokeAPI({
45
+ operation: 'getCall',
46
+ request
47
+ });
48
+ }
49
+
50
+ async updateCallStatus(request) {
51
+ return this.invokeAPI({
52
+ operation: 'updateCallStatus',
53
+ request
54
+ });
55
+ }
56
+
57
+ async initiateCall(request) {
58
+ return this.invokeAPI({
59
+ operation: 'initiateCall',
60
+ request
61
+ });
62
+ }
63
+
64
+ toJSON() {
65
+ return {
66
+ getCalls: this.getCalls.bind(this),
67
+ getCall: this.getCall.bind(this),
68
+ updateCallStatus: this.updateCallStatus.bind(this),
69
+ initiateCall: this.initiateCall.bind(this)
70
+ };
71
+ }
72
+
73
+ }
@@ -0,0 +1 @@
1
+ export { default as CallRepository } from './CallRepository';
@@ -0,0 +1,97 @@
1
+ import { CannedMessageAdapter } from '../../adapters';
2
+ import { CannedMessageAPI } from '../../api';
3
+ import { ICannedMessageRepository } from '../../../domain/interfaces/repositories/cannedMessages';
4
+ import { ResponseTypes } from '../../../core/constants';
5
+ export default class CannedMessageRepository extends ICannedMessageRepository {
6
+ constructor(_ref) {
7
+ let {
8
+ cannedMessageAPI,
9
+ cannedMessageAdapter
10
+ } = _ref;
11
+ super();
12
+ this.defaultAPI = new CannedMessageAPI();
13
+ this.customAPI = cannedMessageAPI;
14
+ this.cannedMessageAPI = this.createAPIProxy(this.customAPI, this.defaultAPI);
15
+ this.cannedMessageAdapter = cannedMessageAdapter || new CannedMessageAdapter();
16
+ }
17
+
18
+ async invokeAPI(_ref2) {
19
+ let {
20
+ operation,
21
+ request,
22
+ adapter = this.cannedMessageAdapter,
23
+ responseType
24
+ } = _ref2;
25
+ return this.executeAPICall({
26
+ operation,
27
+ request,
28
+ apiProxy: this.cannedMessageAPI,
29
+ customAPI: this.customAPI,
30
+ adapter,
31
+ responseType
32
+ });
33
+ }
34
+
35
+ async getCannedMessages(request) {
36
+ return this.invokeAPI({
37
+ operation: 'getCannedMessages',
38
+ request,
39
+ responseType: ResponseTypes.LIST
40
+ });
41
+ }
42
+
43
+ async getCannedMessage(request) {
44
+ return this.invokeAPI({
45
+ operation: 'getCannedMessage',
46
+ request
47
+ });
48
+ }
49
+
50
+ async createCannedMessage(request) {
51
+ return this.invokeAPI({
52
+ operation: 'createCannedMessage',
53
+ request
54
+ });
55
+ }
56
+
57
+ async deleteCannedMessage(request) {
58
+ return this.invokeAPI({
59
+ operation: 'deleteCannedMessage',
60
+ request
61
+ });
62
+ }
63
+
64
+ async updateCannedMessage(request) {
65
+ return this.invokeAPI({
66
+ operation: 'updateCannedMessage',
67
+ request
68
+ });
69
+ }
70
+
71
+ async enableCannedMessage(request) {
72
+ return this.invokeAPI({
73
+ operation: 'enableCannedMessage',
74
+ request
75
+ });
76
+ }
77
+
78
+ async disableCannedMessage(request) {
79
+ return this.invokeAPI({
80
+ operation: 'disableCannedMessage',
81
+ request
82
+ });
83
+ }
84
+
85
+ toJSON() {
86
+ return {
87
+ getCannedMessages: this.getCannedMessages.bind(this),
88
+ getCannedMessage: this.getCannedMessage.bind(this),
89
+ createCannedMessage: this.createCannedMessage.bind(this),
90
+ updateCannedMessage: this.updateCannedMessage.bind(this),
91
+ deleteCannedMessage: this.deleteCannedMessage.bind(this),
92
+ enableCannedMssage: this.enableCannedMessage.bind(this),
93
+ disableCannedMessage: this.disableCannedMessage.bind(this)
94
+ };
95
+ }
96
+
97
+ }
@@ -0,0 +1,2 @@
1
+ import CannedMessageRepository from './CannedMessageRepository';
2
+ export { CannedMessageRepository };
@@ -3,4 +3,7 @@ export * from './sessions';
3
3
  export * from './bots';
4
4
  export * from './messages';
5
5
  export * from './agents';
6
- export * from './contacts';
6
+ export * from './contacts';
7
+ export * from './cannedMessages';
8
+ export * from './templateMessages';
9
+ export * from './calls';
@@ -0,0 +1,77 @@
1
+ import { ITemplateMessageRepository } from '../../../domain/interfaces/repositories';
2
+ import { TemplateLanguageAdapter, TemplateCreditExhaustStatusAdapter } from '../../adapters';
3
+ import { TemplateMessageAPI } from '../../api';
4
+ import { ResponseTypes } from '../../../core/constants';
5
+ export default class TemplateMessageRepository extends ITemplateMessageRepository {
6
+ constructor(_ref) {
7
+ let {
8
+ templateMessageAPI,
9
+ templateLanguageAdapter,
10
+ templateCreditExhaustStatusAdapter
11
+ } = _ref;
12
+ super();
13
+ this.defaultAPI = new TemplateMessageAPI();
14
+ this.customAPI = templateMessageAPI;
15
+ this.templateMessageAPI = this.createAPIProxy(this.customAPI, this.defaultAPI);
16
+ this.templateLanguageAdapter = templateLanguageAdapter || new TemplateLanguageAdapter();
17
+ this.templateCreditExhaustStatusAdapter = templateCreditExhaustStatusAdapter || new TemplateCreditExhaustStatusAdapter();
18
+ }
19
+
20
+ async invokeTemplateLanguageAPI(_ref2) {
21
+ let {
22
+ operation,
23
+ request,
24
+ adapter = this.templateLanguageAdapter,
25
+ responseType
26
+ } = _ref2;
27
+ return this.executeAPICall({
28
+ operation,
29
+ request,
30
+ apiProxy: this.templateMessageAPI,
31
+ customAPI: this.customAPI,
32
+ adapter,
33
+ responseType
34
+ });
35
+ }
36
+
37
+ async invokeTemplateCreditExhaustStatusAPI(_ref3) {
38
+ let {
39
+ operation,
40
+ request,
41
+ adapter = this.templateCreditExhaustStatusAdapter,
42
+ responseType
43
+ } = _ref3;
44
+ return this.executeAPICall({
45
+ operation,
46
+ request,
47
+ apiProxy: this.templateMessageAPI,
48
+ customAPI: this.customAPI,
49
+ adapter,
50
+ responseType
51
+ });
52
+ }
53
+
54
+ async getTemplateLanguages(request) {
55
+ return this.invokeTemplateLanguageAPI({
56
+ operation: 'getTemplateLanguages',
57
+ request,
58
+ responseType: ResponseTypes.LIST
59
+ });
60
+ }
61
+
62
+ async getWhatsAppTemplateCreditExhaustStatus(request) {
63
+ return this.invokeTemplateCreditExhaustStatusAPI({
64
+ operation: 'getWhatsAppTemplateCreditExhaustStatus',
65
+ request,
66
+ responseType: ResponseTypes.SINGLE
67
+ });
68
+ }
69
+
70
+ toJSON() {
71
+ return {
72
+ getTemplateLanguages: this.getTemplateLanguages.bind(this),
73
+ getWhatsAppTemplateCreditExhaustStatus: this.getWhatsAppTemplateCreditExhaustStatus.bind(this)
74
+ };
75
+ }
76
+
77
+ }
@@ -0,0 +1,2 @@
1
+ import TemplateMessageRepository from './TemplateMessageRepository';
2
+ export { TemplateMessageRepository };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "0.0.5",
3
+ "version": "1.0.0-calls1",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
@@ -32,4 +32,4 @@
32
32
  "@zohodesk/docs-builder": "1.0.2",
33
33
  "@testing-library/jest-dom": "^5.16.5"
34
34
  }
35
- }
35
+ }