@zohoim/client-sdk 1.1.0-attachmentsList → 1.1.0-calls

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 (72) 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/index.js +3 -1
  4. package/es/application/services/whatsAppPricing/WhatsAppPricingService.js +21 -0
  5. package/es/application/services/whatsAppPricing/index.js +2 -0
  6. package/es/core/constants/ModuleNames.js +3 -1
  7. package/es/core/constants/ModuleTypes.js +5 -0
  8. package/es/core/constants/index.js +2 -1
  9. package/es/core/utils/validateSchema.js +12 -0
  10. package/es/domain/dto/calls/getCallRequest.js +14 -0
  11. package/es/domain/dto/calls/getCallsRequest.js +20 -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 +15 -0
  15. package/es/domain/dto/index.js +3 -1
  16. package/es/domain/dto/sessions/getSessionAttachmentsRequest.js +5 -2
  17. package/es/domain/dto/whatsAppPricing/calculateWhatsAppPricingRequest.js +14 -0
  18. package/es/domain/dto/whatsAppPricing/index.js +1 -0
  19. package/es/domain/entities/Actor/Actor.js +4 -0
  20. package/es/domain/entities/Call/Call.js +47 -0
  21. package/es/domain/entities/Call/index.js +1 -0
  22. package/es/domain/entities/WhatsAppPricing/WhatsAppPricing.js +25 -0
  23. package/es/domain/entities/WhatsAppPricing/WhatsAppPricingCategory.js +22 -0
  24. package/es/domain/entities/WhatsAppPricing/index.js +3 -0
  25. package/es/domain/entities/index.js +3 -1
  26. package/es/domain/enum/call/CallStatus.js +8 -0
  27. package/es/domain/enum/call/index.js +1 -0
  28. package/es/domain/enum/index.js +2 -1
  29. package/es/domain/interfaces/repositories/calls/ICallRepository.js +32 -0
  30. package/es/domain/interfaces/repositories/calls/index.js +1 -0
  31. package/es/domain/interfaces/repositories/index.js +3 -1
  32. package/es/domain/interfaces/repositories/whatsAppPricing/IWhatsAppPricingRepository.js +18 -0
  33. package/es/domain/interfaces/repositories/whatsAppPricing/index.js +2 -0
  34. package/es/domain/schema/call/CallSchema.js +63 -0
  35. package/es/domain/schema/call/index.js +1 -0
  36. package/es/domain/schema/index.js +3 -1
  37. package/es/domain/schema/whatsAppPricing/WhatsAppPricingCategorySchema.js +11 -0
  38. package/es/domain/schema/whatsAppPricing/WhatsAppPricingSchema.js +21 -0
  39. package/es/domain/schema/whatsAppPricing/index.js +3 -0
  40. package/es/frameworks/managers/ModuleFactory.js +59 -23
  41. package/es/frameworks/managers/ModuleManager.js +25 -2
  42. package/es/frameworks/sdk/IMSDK.js +23 -11
  43. package/es/frameworks/sdk/calls/CallSDK.js +27 -0
  44. package/es/frameworks/sdk/calls/index.js +1 -0
  45. package/es/frameworks/sdk/whatsAppPricing/WhatsAppPricingSDK.js +28 -0
  46. package/es/frameworks/sdk/whatsAppPricing/index.js +2 -0
  47. package/es/infrastructure/adapters/calls/CallAdapter.js +31 -0
  48. package/es/infrastructure/adapters/calls/index.js +1 -0
  49. package/es/infrastructure/adapters/index.js +3 -1
  50. package/es/infrastructure/adapters/whatsAppPricing/WhatsAppPricingAdapter.js +22 -0
  51. package/es/infrastructure/adapters/whatsAppPricing/index.js +2 -0
  52. package/es/infrastructure/api/BaseAPI.js +5 -4
  53. package/es/infrastructure/api/calls/CallAPI.js +44 -0
  54. package/es/infrastructure/api/calls/index.js +1 -0
  55. package/es/infrastructure/api/index.js +3 -1
  56. package/es/infrastructure/api/registry/calls/callAPIRegistry.js +29 -0
  57. package/es/infrastructure/api/registry/calls/constructCallEndPoint.js +10 -0
  58. package/es/infrastructure/api/registry/calls/index.js +1 -0
  59. package/es/infrastructure/api/registry/createPublicBaseUrl.js +4 -0
  60. package/es/infrastructure/api/registry/getRegistryConfig.js +5 -1
  61. package/es/infrastructure/api/registry/whatsAppPricing/constructWhatsAppPricingEndPoint.js +10 -0
  62. package/es/infrastructure/api/registry/whatsAppPricing/index.js +2 -0
  63. package/es/infrastructure/api/registry/whatsAppPricing/whatsAppPricingAPIRegistry.js +13 -0
  64. package/es/infrastructure/api/whatsAppPricing/WhatsAppPricingAPI.js +14 -0
  65. package/es/infrastructure/api/whatsAppPricing/index.js +2 -0
  66. package/es/infrastructure/config/configRegistry.js +8 -1
  67. package/es/infrastructure/repositories/calls/CallRepository.js +73 -0
  68. package/es/infrastructure/repositories/calls/index.js +1 -0
  69. package/es/infrastructure/repositories/index.js +3 -1
  70. package/es/infrastructure/repositories/whatsAppPricing/WhatsAppPricingRepository.js +49 -0
  71. package/es/infrastructure/repositories/whatsAppPricing/index.js +2 -0
  72. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { ModuleNames } from '../../core/constants';
1
+ import { ModuleNames, ModuleTypes } from '../../core/constants';
2
2
  import { BotSDK } from '../sdk/bots';
3
3
  import { ChannelSDK } from '../sdk/channels';
4
4
  import { SessionSDK } from '../sdk/sessions';
@@ -7,68 +7,104 @@ import { AgentSDK } from '../sdk/agents';
7
7
  import { ContactSDK } from '../sdk/contacts';
8
8
  import { CannedMessageSDK } from '../sdk/cannedMessages';
9
9
  import { TemplateMessageSDK } from '../sdk/templateMessages';
10
+ import { WhatsAppPricingSDK } from '../sdk/whatsAppPricing';
11
+ import { CallSDK } from '../sdk/calls';
10
12
  const ModuleFactory = {
11
13
  [ModuleNames.CHANNELS]: _ref => {
12
14
  let {
13
15
  config
14
16
  } = _ref;
15
- return new ChannelSDK({
16
- config
17
- }).toJSON();
17
+ return {
18
+ [ModuleTypes.AUTHENTICATED]: new ChannelSDK({
19
+ config
20
+ }).toJSON()
21
+ };
18
22
  },
19
23
  [ModuleNames.SESSIONS]: _ref2 => {
20
24
  let {
21
25
  config
22
26
  } = _ref2;
23
- return new SessionSDK({
24
- config
25
- }).toJSON();
27
+ return {
28
+ [ModuleTypes.AUTHENTICATED]: new SessionSDK({
29
+ config
30
+ }).toJSON()
31
+ };
26
32
  },
27
33
  [ModuleNames.BOTS]: _ref3 => {
28
34
  let {
29
35
  config
30
36
  } = _ref3;
31
- return new BotSDK({
32
- config
33
- }).toJSON();
37
+ return {
38
+ [ModuleTypes.AUTHENTICATED]: new BotSDK({
39
+ config
40
+ }).toJSON()
41
+ };
34
42
  },
35
43
  [ModuleNames.AGENTS]: _ref4 => {
36
44
  let {
37
45
  config
38
46
  } = _ref4;
39
- return new AgentSDK({
40
- config
41
- }).toJSON();
47
+ return {
48
+ [ModuleTypes.AUTHENTICATED]: new AgentSDK({
49
+ config
50
+ }).toJSON()
51
+ };
42
52
  },
43
53
  [ModuleNames.CONTACTS]: _ref5 => {
44
54
  let {
45
55
  config
46
56
  } = _ref5;
47
- return new ContactSDK({
48
- config
49
- }).toJSON();
57
+ return {
58
+ [ModuleTypes.AUTHENTICATED]: new ContactSDK({
59
+ config
60
+ }).toJSON()
61
+ };
50
62
  },
51
63
  [ModuleNames.MESSAGES]: _ref6 => {
52
64
  let {
53
65
  config
54
66
  } = _ref6;
55
- return new MessageSDK({
56
- config
57
- }).toJSON();
67
+ return {
68
+ [ModuleTypes.AUTHENTICATED]: new MessageSDK({
69
+ config
70
+ }).toJSON()
71
+ };
58
72
  },
59
73
  [ModuleNames.CANNED_MESSAGES]: _ref7 => {
60
74
  let {
61
75
  config
62
76
  } = _ref7;
63
- return new CannedMessageSDK({
64
- config
65
- }).toJSON();
77
+ return {
78
+ [ModuleTypes.AUTHENTICATED]: new CannedMessageSDK({
79
+ config
80
+ }).toJSON()
81
+ };
66
82
  },
67
83
  [ModuleNames.TEMPLATE_MESSAGES]: _ref8 => {
68
84
  let {
69
85
  config
70
86
  } = _ref8;
71
- return new TemplateMessageSDK({
87
+ return {
88
+ [ModuleTypes.AUTHENTICATED]: new TemplateMessageSDK({
89
+ config
90
+ }).toJSON()
91
+ };
92
+ },
93
+ [ModuleNames.WHATSAPP_PRICING]: _ref9 => {
94
+ let {
95
+ config
96
+ } = _ref9;
97
+ return {
98
+ [ModuleTypes.PUBLIC]: new WhatsAppPricingSDK({
99
+ config
100
+ }).toJSON()
101
+ };
102
+ },
103
+ [ModuleNames.CALLS]: _ref10 => {
104
+ let {
105
+ config
106
+ } = _ref10;
107
+ return new CallSDK({
72
108
  config
73
109
  }).toJSON();
74
110
  }
@@ -1,9 +1,9 @@
1
- import { ModuleNames } from '../../core/constants';
1
+ import { ModuleNames, ModuleTypes } from '../../core/constants';
2
2
  import ModuleFactory from './ModuleFactory';
3
3
  export default class ModuleManager {
4
4
  constructor() {
5
5
  this._modules = new Map();
6
- this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS, ModuleNames.MESSAGES, ModuleNames.AGENTS, ModuleNames.CONTACTS, ModuleNames.CANNED_MESSAGES, ModuleNames.TEMPLATE_MESSAGES];
6
+ this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS, ModuleNames.MESSAGES, ModuleNames.AGENTS, ModuleNames.CONTACTS, ModuleNames.CANNED_MESSAGES, ModuleNames.TEMPLATE_MESSAGES, ModuleNames.WHATSAPP_PRICING, ModuleNames.CALLS];
7
7
  }
8
8
 
9
9
  initialize(_ref) {
@@ -37,6 +37,29 @@ export default class ModuleManager {
37
37
  return this._modules.get(moduleName);
38
38
  }
39
39
 
40
+ getModuleByType(moduleName) {
41
+ let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ModuleTypes.AUTHENTICATED;
42
+ const moduleEntry = this.getModule(moduleName);
43
+
44
+ if (!moduleEntry) {
45
+ return undefined;
46
+ }
47
+
48
+ return moduleEntry[type];
49
+ }
50
+
51
+ getModulesByType(type) {
52
+ const result = {};
53
+
54
+ this._modules.forEach((moduleEntry, moduleName) => {
55
+ if (moduleEntry[type]) {
56
+ result[moduleName] = moduleEntry[type];
57
+ }
58
+ });
59
+
60
+ return result;
61
+ }
62
+
40
63
  hasModule(moduleName) {
41
64
  return this._modules.has(moduleName);
42
65
  }
@@ -1,4 +1,4 @@
1
- import { ModuleNames } from '../../core/constants';
1
+ import { ModuleNames, ModuleTypes } from '../../core/constants';
2
2
  import configRegistry from '../../infrastructure/config/configRegistry';
3
3
  import { ModuleManager } from '../managers';
4
4
  export default class IMSDK {
@@ -6,11 +6,13 @@ export default class IMSDK {
6
6
  let {
7
7
  baseURL,
8
8
  apiConfig = {},
9
- httpClient
9
+ httpClient,
10
+ publicHttpClient
10
11
  } = _ref;
11
12
  configRegistry.setConfig({
12
13
  baseURL,
13
- httpClient
14
+ httpClient,
15
+ publicHttpClient
14
16
  });
15
17
  this._moduleManager = new ModuleManager();
16
18
 
@@ -20,35 +22,43 @@ export default class IMSDK {
20
22
  }
21
23
 
22
24
  get channels() {
23
- return this._moduleManager.getModule(ModuleNames.CHANNELS);
25
+ return this._moduleManager.getModuleByType(ModuleNames.CHANNELS);
24
26
  }
25
27
 
26
28
  get sessions() {
27
- return this._moduleManager.getModule(ModuleNames.SESSIONS);
29
+ return this._moduleManager.getModuleByType(ModuleNames.SESSIONS);
28
30
  }
29
31
 
30
32
  get bots() {
31
- return this._moduleManager.getModule(ModuleNames.BOTS);
33
+ return this._moduleManager.getModuleByType(ModuleNames.BOTS);
32
34
  }
33
35
 
34
36
  get messages() {
35
- return this._moduleManager.getModule(ModuleNames.MESSAGES);
37
+ return this._moduleManager.getModuleByType(ModuleNames.MESSAGES);
36
38
  }
37
39
 
38
40
  get agents() {
39
- return this._moduleManager.getModule(ModuleNames.AGENTS);
41
+ return this._moduleManager.getModuleByType(ModuleNames.AGENTS);
40
42
  }
41
43
 
42
44
  get contacts() {
43
- return this._moduleManager.getModule(ModuleNames.CONTACTS);
45
+ return this._moduleManager.getModuleByType(ModuleNames.CONTACTS);
44
46
  }
45
47
 
46
48
  get cannedMessages() {
47
- return this._moduleManager.getModule(ModuleNames.CANNED_MESSAGES);
49
+ return this._moduleManager.getModuleByType(ModuleNames.CANNED_MESSAGES);
48
50
  }
49
51
 
50
52
  get templateMessages() {
51
- return this._moduleManager.getModule(ModuleNames.TEMPLATE_MESSAGES);
53
+ return this._moduleManager.getModuleByType(ModuleNames.TEMPLATE_MESSAGES);
54
+ }
55
+
56
+ get public() {
57
+ return this._moduleManager.getModulesByType(ModuleTypes.PUBLIC);
58
+ }
59
+
60
+ get calls() {
61
+ return this._moduleManager.getModule(ModuleNames.CALLS);
52
62
  }
53
63
 
54
64
  hasModule(moduleName) {
@@ -65,6 +75,8 @@ export default class IMSDK {
65
75
  contacts: this.contacts,
66
76
  cannedMessages: this.cannedMessages,
67
77
  templateMessages: this.templateMessages,
78
+ public: this.public,
79
+ calls: this.calls,
68
80
  hasModule: this.hasModule.bind(this)
69
81
  };
70
82
  }
@@ -0,0 +1,27 @@
1
+ import { CallService } from '../../../application/services';
2
+ import { CallRepository } from '../../../infrastructure/repositories';
3
+ export default class CallSDK {
4
+ constructor(_ref) {
5
+ let {
6
+ config
7
+ } = _ref;
8
+ const {
9
+ callAPI,
10
+ callAdapter
11
+ } = config;
12
+ const callRepository = new CallRepository({
13
+ callAPI,
14
+ callAdapter
15
+ }).toJSON();
16
+ const callService = new CallService({
17
+ callRepository
18
+ }).toJSON();
19
+ this.services = { ...callService
20
+ };
21
+ }
22
+
23
+ toJSON() {
24
+ return this.services;
25
+ }
26
+
27
+ }
@@ -0,0 +1 @@
1
+ export { default as CallSDK } from './CallSDK';
@@ -0,0 +1,28 @@
1
+ import { WhatsAppPricingService } from '../../../application/services';
2
+ import { WhatsAppPricingRepository } from '../../../infrastructure/repositories';
3
+
4
+ class WhatsAppPricingSDK {
5
+ constructor(_ref) {
6
+ let {
7
+ config
8
+ } = _ref;
9
+ const {
10
+ whatsAppPricingAPI
11
+ } = config;
12
+ const whatsAppPricingRepository = new WhatsAppPricingRepository({
13
+ whatsAppPricingAPI
14
+ }).toJSON();
15
+ const whatsAppPricingService = new WhatsAppPricingService({
16
+ whatsAppPricingRepository
17
+ }).toJSON();
18
+ this.services = { ...whatsAppPricingService
19
+ };
20
+ }
21
+
22
+ toJSON() {
23
+ return this.services;
24
+ }
25
+
26
+ }
27
+
28
+ export default WhatsAppPricingSDK;
@@ -0,0 +1,2 @@
1
+ import WhatsAppPricingSDK from './WhatsAppPricingSDK';
2
+ export { WhatsAppPricingSDK };
@@ -0,0 +1,31 @@
1
+ import { AdapterError } from '../../../core/errors';
2
+ import { Call } from '../../../domain/entities';
3
+ import { IAdapter } from '../../../domain/interfaces';
4
+ export default class CallAdapter extends IAdapter {
5
+ adapt(callData) {
6
+ if (!callData) {
7
+ throw new AdapterError('Call data is required');
8
+ }
9
+
10
+ try {
11
+ return new Call({
12
+ id: callData.id,
13
+ integrationServiceId: callData.integrationServiceId,
14
+ actor: callData.actor,
15
+ channelId: callData.channelId,
16
+ createdTime: callData.createdTime,
17
+ direction: callData.direction,
18
+ sessionId: callData.sessionId,
19
+ status: callData.status,
20
+ meta: callData.meta,
21
+ participants: callData.participants,
22
+ session: callData.session,
23
+ statuses: callData.statuses,
24
+ duration: callData.duration
25
+ }).toJSON();
26
+ } catch (error) {
27
+ throw new AdapterError(`Failed to adapt message: ${error.message}`);
28
+ }
29
+ }
30
+
31
+ }
@@ -0,0 +1 @@
1
+ export { default as CallAdapter } from './CallAdapter';
@@ -7,4 +7,6 @@ export * from './agents';
7
7
  export * from './contacts';
8
8
  export * from './cannedMessages';
9
9
  export * from './templateMessages';
10
- export * from './customReplyExtension';
10
+ export * from './customReplyExtension';
11
+ export * from './whatsAppPricing';
12
+ export * from './calls';
@@ -0,0 +1,22 @@
1
+ import { AdapterError } from '../../../core/errors';
2
+ import { WhatsAppPricing } from '../../../domain/entities';
3
+ import { IAdapter } from '../../../domain/interfaces';
4
+ export default class WhatsAppPricingAdapter extends IAdapter {
5
+ adapt(whatsAppPricingData) {
6
+ if (!whatsAppPricingData) {
7
+ throw new AdapterError('whatsAppPricing data is required');
8
+ }
9
+
10
+ try {
11
+ return new WhatsAppPricing({
12
+ total: whatsAppPricingData.total,
13
+ creditsCount: whatsAppPricingData.creditsCount,
14
+ actutalCreditsAmount: whatsAppPricingData.actutalCreditsAmount,
15
+ category: whatsAppPricingData.category
16
+ }).toJSON();
17
+ } catch (error) {
18
+ throw new AdapterError(`Failed to adapt WhatsAppPricing: ${error.message}`);
19
+ }
20
+ }
21
+
22
+ }
@@ -0,0 +1,2 @@
1
+ import WhatsAppPricingAdapter from './WhatsAppPricingAdapter';
2
+ export { WhatsAppPricingAdapter };
@@ -1,4 +1,4 @@
1
- import { ResponseTypes } from '../../core/constants';
1
+ import { ModuleTypes, ResponseTypes } from '../../core/constants';
2
2
  import { ResponseUtils } from '../../core/utils';
3
3
  import configRegistry from '../config/configRegistry';
4
4
  import { getRegistryConfig } from './registry';
@@ -7,18 +7,19 @@ export default class BaseAPI {
7
7
  constructor() {
8
8
  let {
9
9
  module,
10
+ moduleType = ModuleTypes.AUTHENTICATED,
10
11
  configProvider = configRegistry,
11
12
  registryProvider = {
12
13
  getRegistryConfig
13
14
  },
14
- urlBuilder = new UrlBuilder()
15
+ urlBuilder
15
16
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
17
  this.configProvider = configProvider;
17
18
  this.registryProvider = registryProvider;
18
- this.httpClient = this.configProvider.getHttpClient();
19
+ this.httpClient = moduleType === ModuleTypes.PUBLIC ? this.configProvider.getPublicHttpClient() : this.configProvider.getHttpClient();
19
20
  this.baseURL = this.configProvider.getBaseURL();
20
21
  this.module = module;
21
- this.urlBuilder = urlBuilder;
22
+ this.urlBuilder = urlBuilder || new UrlBuilder(this.baseURL);
22
23
  }
23
24
 
24
25
  async request(_ref) {
@@ -0,0 +1,44 @@
1
+ import { getCallsRequest, getCallRequest, updateCallStatusRequest, initiateCallRequest } from '../../../domain/dto';
2
+ import { ICallRepository } from '../../../domain/interfaces/repositories';
3
+ export default class CallAPI extends ICallRepository {
4
+ async getCalls() {
5
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCallsRequest();
6
+ const operation = 'getCalls';
7
+ const httpRequest = await this.request({
8
+ operation,
9
+ request
10
+ });
11
+ return httpRequest;
12
+ }
13
+
14
+ async getCall() {
15
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCallRequest();
16
+ const operation = 'getCall';
17
+ const httpRequest = await this.request({
18
+ operation,
19
+ request
20
+ });
21
+ return httpRequest;
22
+ }
23
+
24
+ async updateCallStatus() {
25
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateCallStatusRequest();
26
+ const operation = 'updateCallStatus';
27
+ const httpRequest = await this.request({
28
+ operation,
29
+ request
30
+ });
31
+ return httpRequest;
32
+ }
33
+
34
+ async initiateCall() {
35
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initiateCallRequest();
36
+ const operation = 'initiateCall';
37
+ const httpRequest = await this.request({
38
+ operation,
39
+ request
40
+ });
41
+ return httpRequest;
42
+ }
43
+
44
+ }
@@ -0,0 +1 @@
1
+ export { default as CallAPI } from './CallAPI';
@@ -5,4 +5,6 @@ export * from './messages';
5
5
  export * from './agents';
6
6
  export * from './contacts';
7
7
  export * from './cannedMessages';
8
- export * from './templateMessages';
8
+ export * from './templateMessages';
9
+ export * from './whatsAppPricing';
10
+ 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,4 @@
1
+ import createBaseUrl from './createBaseUrl';
2
+ export default function createPublicBaseUrl(path) {
3
+ return createBaseUrl(`/public${path}`);
4
+ }
@@ -7,6 +7,8 @@ import { agentAPIRegistry } from './agents';
7
7
  import { contactAPIRegistry } from './contacts';
8
8
  import { cannedMessageAPIRegistry } from './cannedMessages';
9
9
  import { templateMessageAPIRegistry } from './templateMessages';
10
+ import { whatsAppPricingAPIRegistry } from './whatsAppPricing';
11
+ import { callAPIRegistry } from './calls';
10
12
  import { ModuleNames } from '../../../core/constants';
11
13
  const APIRegistry = {
12
14
  [ModuleNames.CHANNELS]: channelAPIRegistry,
@@ -16,7 +18,9 @@ const APIRegistry = {
16
18
  [ModuleNames.AGENTS]: agentAPIRegistry,
17
19
  [ModuleNames.CONTACTS]: contactAPIRegistry,
18
20
  [ModuleNames.CANNED_MESSAGES]: cannedMessageAPIRegistry,
19
- [ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry
21
+ [ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry,
22
+ [ModuleNames.WHATSAPP_PRICING]: whatsAppPricingAPIRegistry,
23
+ [ModuleNames.CALLS]: callAPIRegistry
20
24
  };
21
25
  export default function getRegistryConfig(module, operation) {
22
26
  const moduleConfig = selectn(module, APIRegistry);
@@ -0,0 +1,10 @@
1
+ import createPublicBaseUrl from '../createPublicBaseUrl';
2
+ export default function constructWhatsAppPricingEndPoint(extra) {
3
+ const base = '/whatsAppPricing';
4
+
5
+ if (extra) {
6
+ return createPublicBaseUrl(base + extra);
7
+ }
8
+
9
+ return createPublicBaseUrl(base);
10
+ }
@@ -0,0 +1,2 @@
1
+ import whatsAppPricingAPIRegistry from './whatsAppPricingAPIRegistry';
2
+ export { whatsAppPricingAPIRegistry };
@@ -0,0 +1,13 @@
1
+ import { HTTP_METHODS } from '../../../../core/constants';
2
+ import { calculateWhatsAppPricingRequest } from '../../../../domain/dto';
3
+ import createAPIRegistry from '../createAPIRegistry';
4
+ import constructWhatsAppPricingEndPoint from './constructWhatsAppPricingEndPoint';
5
+
6
+ function calculateWhatsAppPricing() {
7
+ return createAPIRegistry(constructWhatsAppPricingEndPoint(), HTTP_METHODS.POST, calculateWhatsAppPricingRequest());
8
+ }
9
+
10
+ const whatsAppPricingAPIRegistry = {
11
+ calculateWhatsAppPricing
12
+ };
13
+ export default whatsAppPricingAPIRegistry;
@@ -0,0 +1,14 @@
1
+ import { calculateWhatsAppPricingRequest } from '../../../domain/dto';
2
+ import { IWhatsAppPricingRepository } from '../../../domain/interfaces/repositories';
3
+ export default class WhatsAppPricingAPI extends IWhatsAppPricingRepository {
4
+ async calculateWhatsAppPricing() {
5
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : calculateWhatsAppPricingRequest();
6
+ const operation = 'calculateWhatsAppPricing';
7
+ const httpRequest = await this.request({
8
+ request,
9
+ operation
10
+ });
11
+ return httpRequest;
12
+ }
13
+
14
+ }
@@ -0,0 +1,2 @@
1
+ import WhatsAppPricingAPI from './WhatsAppPricingAPI';
2
+ export { WhatsAppPricingAPI };
@@ -2,15 +2,18 @@ class ConfigRegistry {
2
2
  constructor() {
3
3
  this.baseURL = null;
4
4
  this.httpClient = null;
5
+ this.publicHttpClient = null;
5
6
  }
6
7
 
7
8
  setConfig(_ref) {
8
9
  let {
9
10
  baseURL,
10
- httpClient
11
+ httpClient,
12
+ publicHttpClient
11
13
  } = _ref;
12
14
  this.baseURL = baseURL;
13
15
  this.httpClient = httpClient;
16
+ this.publicHttpClient = publicHttpClient || null;
14
17
  }
15
18
 
16
19
  getBaseURL() {
@@ -21,6 +24,10 @@ class ConfigRegistry {
21
24
  return this.httpClient;
22
25
  }
23
26
 
27
+ getPublicHttpClient() {
28
+ return this.publicHttpClient;
29
+ }
30
+
24
31
  }
25
32
 
26
33
  const configRegistry = new ConfigRegistry();