@zohoim/client-sdk 1.0.0-calls3 → 1.0.0-canned02

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 (48) hide show
  1. package/es/application/services/index.js +1 -2
  2. package/es/core/constants/ModuleNames.js +1 -2
  3. package/es/domain/dto/index.js +1 -2
  4. package/es/domain/entities/Actor/Actor.js +0 -4
  5. package/es/domain/entities/CannedMessage/CannedMessage.js +25 -3
  6. package/es/domain/entities/index.js +1 -2
  7. package/es/domain/enum/cannedMessage/CannedMessageStatus.js +11 -1
  8. package/es/domain/enum/cannedMessage/CannedMessageType.js +3 -1
  9. package/es/domain/enum/cannedMessage/TemplateItemButtonType.js +6 -1
  10. package/es/domain/enum/index.js +1 -2
  11. package/es/domain/interfaces/repositories/index.js +1 -2
  12. package/es/domain/schema/cannedMessage/CannedMessageSchema.js +12 -0
  13. package/es/domain/schema/index.js +1 -2
  14. package/es/frameworks/managers/ModuleFactory.js +0 -9
  15. package/es/frameworks/managers/ModuleManager.js +1 -1
  16. package/es/frameworks/sdk/IMSDK.js +0 -5
  17. package/es/infrastructure/adapters/index.js +1 -2
  18. package/es/infrastructure/api/index.js +1 -2
  19. package/es/infrastructure/api/registry/getRegistryConfig.js +1 -3
  20. package/es/infrastructure/repositories/cannedMessages/CannedMessageRepository.js +1 -1
  21. package/es/infrastructure/repositories/index.js +1 -2
  22. package/package.json +2 -2
  23. package/es/application/services/calls/CallService.js +0 -36
  24. package/es/application/services/calls/index.js +0 -1
  25. package/es/domain/dto/calls/getCallRequest.js +0 -14
  26. package/es/domain/dto/calls/getCallsRequest.js +0 -19
  27. package/es/domain/dto/calls/index.js +0 -4
  28. package/es/domain/dto/calls/initiateCallRequest.js +0 -15
  29. package/es/domain/dto/calls/updateCallStatusRequest.js +0 -16
  30. package/es/domain/entities/Call/Call.js +0 -44
  31. package/es/domain/entities/Call/index.js +0 -1
  32. package/es/domain/enum/call/CallStatus.js +0 -8
  33. package/es/domain/enum/call/index.js +0 -1
  34. package/es/domain/interfaces/repositories/calls/ICallRepository.js +0 -32
  35. package/es/domain/interfaces/repositories/calls/index.js +0 -1
  36. package/es/domain/schema/call/CallSchema.js +0 -59
  37. package/es/domain/schema/call/index.js +0 -1
  38. package/es/frameworks/sdk/calls/CallSDK.js +0 -27
  39. package/es/frameworks/sdk/calls/index.js +0 -1
  40. package/es/infrastructure/adapters/calls/CallAdapter.js +0 -30
  41. package/es/infrastructure/adapters/calls/index.js +0 -1
  42. package/es/infrastructure/api/calls/CallAPI.js +0 -44
  43. package/es/infrastructure/api/calls/index.js +0 -1
  44. package/es/infrastructure/api/registry/calls/callAPIRegistry.js +0 -29
  45. package/es/infrastructure/api/registry/calls/constructCallEndPoint.js +0 -10
  46. package/es/infrastructure/api/registry/calls/index.js +0 -1
  47. package/es/infrastructure/repositories/calls/CallRepository.js +0 -73
  48. package/es/infrastructure/repositories/calls/index.js +0 -1
@@ -5,5 +5,4 @@ export * from './messages';
5
5
  export * from './agents';
6
6
  export * from './contacts';
7
7
  export * from './cannedMessages';
8
- export * from './templateMessages';
9
- export * from './calls';
8
+ export * from './templateMessages';
@@ -7,7 +7,6 @@ const ModuleNames = {
7
7
  AGENTS: 'agents',
8
8
  CANNED_MESSAGES: 'cannedMessages',
9
9
  TEMPLATE_MESSAGES: 'templateMessages',
10
- CUSTOM_REPLY_EXTENSIONS: 'articles',
11
- CALLS: 'calls'
10
+ CUSTOM_REPLY_EXTENSIONS: 'articles'
12
11
  };
13
12
  export default ModuleNames;
@@ -5,5 +5,4 @@ export * from './messages';
5
5
  export * from './agents';
6
6
  export * from './contacts';
7
7
  export * from './cannedMessages';
8
- export * from './templateMessages';
9
- export * from './calls';
8
+ export * from './templateMessages';
@@ -33,10 +33,6 @@ export default class Actor {
33
33
  return type === ActorType.ENDUSER;
34
34
  }
35
35
 
36
- static isAgent(type) {
37
- return type === ActorType.AGENT;
38
- }
39
-
40
36
  toJSON() {
41
37
  return { ...this.data
42
38
  };
@@ -1,5 +1,5 @@
1
1
  import { validateSchema } from '../../../core/utils';
2
- import { CannedMessageStatus } from '../../enum';
2
+ import { CannedMessageStatus, CannedMessageType } from '../../enum';
3
3
  import { CannedMessageSchema } from '../../schema';
4
4
  import { Actor } from '../Actor';
5
5
  export default class CannedMessage {
@@ -15,7 +15,7 @@ export default class CannedMessage {
15
15
  } = validatedData;
16
16
 
17
17
  if (createdBy && typeof createdBy === 'object' && !Array.isArray(createdBy)) {
18
- createdBy = new Actor(createdBy);
18
+ createdBy = new Actor(createdBy).toJSON();
19
19
  }
20
20
 
21
21
  this.data = {
@@ -34,7 +34,9 @@ export default class CannedMessage {
34
34
  rejectionReason: validatedData.rejectionReason,
35
35
  modifiedTime: validatedData.modifiedTime,
36
36
  translations: validatedData.translations,
37
- parameters: validatedData.parameters
37
+ parameters: validatedData.parameters,
38
+ primaryLanguage: validatedData.primaryLanguage,
39
+ wabaId: validatedData.wabaId
38
40
  };
39
41
  }
40
42
 
@@ -50,6 +52,26 @@ export default class CannedMessage {
50
52
  return status === CannedMessageStatus.PENDING;
51
53
  }
52
54
 
55
+ static isUnknown(status) {
56
+ return status === CannedMessageStatus.UNKNOWN;
57
+ }
58
+
59
+ static isPartiallyApproved(status) {
60
+ return status === CannedMessageStatus.PARTIALLY_APPROVED;
61
+ }
62
+
63
+ static isDeletionInProgress(status) {
64
+ return status === CannedMessageStatus.DELETION_IN_PROGRESS;
65
+ }
66
+
67
+ static isDeletionFailed(status) {
68
+ return status === CannedMessageStatus.DELETION_FAILED;
69
+ }
70
+
71
+ static isTemplate(type) {
72
+ return type === CannedMessageType.TEMPLATE;
73
+ }
74
+
53
75
  toJSON() {
54
76
  return { ...this.data
55
77
  };
@@ -9,5 +9,4 @@ export * from './Contact';
9
9
  export * from './IntegrationService';
10
10
  export * from './CannedMessage';
11
11
  export * from './TemplateMessage';
12
- export * from './CustomReplyExtension';
13
- export * from './Call';
12
+ export * from './CustomReplyExtension';
@@ -2,6 +2,16 @@ const CannedMessageStatus = {
2
2
  APPROVED: 'APPROVED',
3
3
  PENDING: 'PENDING',
4
4
  REJECTED: 'REJECTED',
5
- FAILED: 'FAILED'
5
+ FAILED: 'FAILED',
6
+ DELETION_IN_PROGRESS: 'DELETION_IN_PROGRESS',
7
+ DELETION_FAILED: 'DELETION_FAILED',
8
+ PARTIALLY_APPROVED: 'PARTIALLY_APPROVED',
9
+ UNKNOWN: 'UNKNOWN',
10
+ IN_APPEAL: 'IN_APPEAL',
11
+ PENDING_DELETION: 'PENDING_DELETION',
12
+ DELETED: 'DELETED',
13
+ DISABLED: 'DISABLED',
14
+ PAUSED: 'PAUSED',
15
+ LIMIT_EXCEEDED: 'LIMIT_EXCEEDED'
6
16
  };
7
17
  export default CannedMessageStatus;
@@ -1,5 +1,7 @@
1
1
  const CannedMessageType = {
2
2
  CANNED: 'CANNED',
3
- TEMPLATE: 'TEMPLATE'
3
+ TEMPLATE: 'TEMPLATE',
4
+ AWAY: 'AWAY',
5
+ WELCOMEMSG: 'WELCOMEMSG'
4
6
  };
5
7
  export default CannedMessageType;
@@ -1,6 +1,11 @@
1
1
  const TemplateItemButtonType = {
2
2
  QUICK_REPLY: 'QUICK_REPLY',
3
3
  URL: 'URL',
4
- PHONE_NUMBER: 'PHONE_NUMBER'
4
+ PHONE_NUMBER: 'PHONE_NUMBER',
5
+ OTP: 'OTP',
6
+ CATALOG: 'CATALOG',
7
+ MPM: 'MPM',
8
+ CALL_PERMISSION_REQUEST: 'CALL_PERMISSION_REQUEST',
9
+ VOICE_CALL: 'VOICE_CALL'
5
10
  };
6
11
  export default TemplateItemButtonType;
@@ -5,5 +5,4 @@ export * from './bot';
5
5
  export * from './message';
6
6
  export * from './attachment';
7
7
  export * from './cannedMessage';
8
- export * from './templateMessage';
9
- export * from './call';
8
+ export * from './templateMessage';
@@ -5,5 +5,4 @@ export * from './messages';
5
5
  export * from './agents';
6
6
  export * from './contacts';
7
7
  export * from './cannedMessages';
8
- export * from './templateMessages';
9
- export * from './calls';
8
+ export * from './templateMessages';
@@ -60,6 +60,18 @@ const CannedMessageSchema = {
60
60
  parameters: {
61
61
  type: 'object',
62
62
  required: false
63
+ },
64
+ primaryLanguage: {
65
+ type: 'string',
66
+ required: false
67
+ },
68
+ wabaId: {
69
+ type: 'string',
70
+ required: false
71
+ },
72
+ modifiedTime: {
73
+ type: 'string',
74
+ required: false
63
75
  }
64
76
  };
65
77
  export default CannedMessageSchema;
@@ -8,5 +8,4 @@ export * from './integrationService';
8
8
  export * from './contact';
9
9
  export * from './cannedMessage';
10
10
  export * from './templateMessage';
11
- export * from './customReplyExtension';
12
- export * from './call';
11
+ export * from './customReplyExtension';
@@ -7,7 +7,6 @@ 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 { CallSDK } from '../sdk/calls';
11
10
  const ModuleFactory = {
12
11
  [ModuleNames.CHANNELS]: _ref => {
13
12
  let {
@@ -72,14 +71,6 @@ const ModuleFactory = {
72
71
  return new TemplateMessageSDK({
73
72
  config
74
73
  }).toJSON();
75
- },
76
- [ModuleNames.CALLS]: _ref9 => {
77
- let {
78
- config
79
- } = _ref9;
80
- return new CallSDK({
81
- config
82
- }).toJSON();
83
74
  }
84
75
  };
85
76
  export default ModuleFactory;
@@ -3,7 +3,7 @@ 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, ModuleNames.CALLS];
6
+ this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS, ModuleNames.MESSAGES, ModuleNames.AGENTS, ModuleNames.CONTACTS, ModuleNames.CANNED_MESSAGES, ModuleNames.TEMPLATE_MESSAGES];
7
7
  }
8
8
 
9
9
  initialize(_ref) {
@@ -51,10 +51,6 @@ export default class IMSDK {
51
51
  return this._moduleManager.getModule(ModuleNames.TEMPLATE_MESSAGES);
52
52
  }
53
53
 
54
- get calls() {
55
- return this._moduleManager.getModule(ModuleNames.CALLS);
56
- }
57
-
58
54
  hasModule(moduleName) {
59
55
  return this._moduleManager.hasModule(moduleName);
60
56
  }
@@ -69,7 +65,6 @@ export default class IMSDK {
69
65
  contacts: this.contacts,
70
66
  cannedMessages: this.cannedMessages,
71
67
  templateMessages: this.templateMessages,
72
- calls: this.calls,
73
68
  hasModule: this.hasModule.bind(this)
74
69
  };
75
70
  }
@@ -7,5 +7,4 @@ export * from './agents';
7
7
  export * from './contacts';
8
8
  export * from './cannedMessages';
9
9
  export * from './templateMessages';
10
- export * from './customReplyExtension';
11
- export * from './calls';
10
+ export * from './customReplyExtension';
@@ -5,5 +5,4 @@ export * from './messages';
5
5
  export * from './agents';
6
6
  export * from './contacts';
7
7
  export * from './cannedMessages';
8
- export * from './templateMessages';
9
- export * from './calls';
8
+ export * from './templateMessages';
@@ -7,7 +7,6 @@ import { agentAPIRegistry } from './agents';
7
7
  import { contactAPIRegistry } from './contacts';
8
8
  import { cannedMessageAPIRegistry } from './cannedMessages';
9
9
  import { templateMessageAPIRegistry } from './templateMessages';
10
- import { callAPIRegistry } from './calls';
11
10
  import { ModuleNames } from '../../../core/constants';
12
11
  const APIRegistry = {
13
12
  [ModuleNames.CHANNELS]: channelAPIRegistry,
@@ -17,8 +16,7 @@ const APIRegistry = {
17
16
  [ModuleNames.AGENTS]: agentAPIRegistry,
18
17
  [ModuleNames.CONTACTS]: contactAPIRegistry,
19
18
  [ModuleNames.CANNED_MESSAGES]: cannedMessageAPIRegistry,
20
- [ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry,
21
- [ModuleNames.CALLS]: callAPIRegistry
19
+ [ModuleNames.TEMPLATE_MESSAGES]: templateMessageAPIRegistry
22
20
  };
23
21
  export default function getRegistryConfig(module, operation) {
24
22
  const moduleConfig = selectn(module, APIRegistry);
@@ -89,7 +89,7 @@ export default class CannedMessageRepository extends ICannedMessageRepository {
89
89
  createCannedMessage: this.createCannedMessage.bind(this),
90
90
  updateCannedMessage: this.updateCannedMessage.bind(this),
91
91
  deleteCannedMessage: this.deleteCannedMessage.bind(this),
92
- enableCannedMssage: this.enableCannedMessage.bind(this),
92
+ enableCannedMessage: this.enableCannedMessage.bind(this),
93
93
  disableCannedMessage: this.disableCannedMessage.bind(this)
94
94
  };
95
95
  }
@@ -5,5 +5,4 @@ export * from './messages';
5
5
  export * from './agents';
6
6
  export * from './contacts';
7
7
  export * from './cannedMessages';
8
- export * from './templateMessages';
9
- export * from './calls';
8
+ export * from './templateMessages';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-calls3",
3
+ "version": "1.0.0-canned02",
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
+ }
@@ -1,36 +0,0 @@
1
- import { ICallRepository } from '../../../domain/interfaces/repositories';
2
- export default class CallService extends ICallRepository {
3
- constructor(_ref) {
4
- let {
5
- callRepository
6
- } = _ref;
7
- super();
8
- this.callRepository = callRepository;
9
- }
10
-
11
- async getCalls(request) {
12
- return this.callRepository.getCalls(request);
13
- }
14
-
15
- async getCall(request) {
16
- return this.callRepository.getCall(request);
17
- }
18
-
19
- async updateCallStatus(request) {
20
- return this.callRepository.updateCallStatus(request);
21
- }
22
-
23
- async initiateCall(request) {
24
- return this.callRepository.initiateCall(request);
25
- }
26
-
27
- toJSON() {
28
- return {
29
- getCalls: this.getCalls.bind(this),
30
- getCall: this.getCall.bind(this),
31
- updateCallStatus: this.updateCallStatus.bind(this),
32
- initiateCall: this.initiateCall.bind(this)
33
- };
34
- }
35
-
36
- }
@@ -1 +0,0 @@
1
- export { default as CallService } from './CallService';
@@ -1,14 +0,0 @@
1
- import RequestBuilder from '../RequestBuilder';
2
- export default function getCallRequest() {
3
- let {
4
- params = {},
5
- query = {}
6
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
- return new RequestBuilder().withParams({
8
- callId: null,
9
- ...params
10
- }).withQuery({
11
- include: null,
12
- ...query
13
- }).build();
14
- }
@@ -1,19 +0,0 @@
1
- import RequestBuilder from '../RequestBuilder';
2
- export default function getCallsRequest() {
3
- let {
4
- query = {}
5
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
- return new RequestBuilder().withQuery({
7
- from: 0,
8
- limit: 10,
9
- status: null,
10
- integrationServiceId: null,
11
- userType: null,
12
- callIds: null,
13
- sessionIds: null,
14
- include: null,
15
- userId: null,
16
- channelIds: null,
17
- ...query
18
- }).build();
19
- }
@@ -1,4 +0,0 @@
1
- export { default as getCallRequest } from './getCallRequest';
2
- export { default as getCallsRequest } from './getCallsRequest';
3
- export { default as initiateCallRequest } from './initiateCallRequest';
4
- export { default as updateCallStatusRequest } from './updateCallStatusRequest';
@@ -1,15 +0,0 @@
1
- import RequestBuilder from '../RequestBuilder';
2
- export default function initiateCall() {
3
- let {
4
- params = {},
5
- body = {}
6
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
- return new RequestBuilder().withParams({
8
- callId: null,
9
- ...params
10
- }).withBody({
11
- platform: null,
12
- meta: null,
13
- ...body
14
- }).build();
15
- }
@@ -1,16 +0,0 @@
1
- import RequestBuilder from '../RequestBuilder';
2
- export default function updateCallStatusRequest() {
3
- let {
4
- params = {},
5
- body = {}
6
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
- return new RequestBuilder().withParams({
8
- callId: null,
9
- ...params
10
- }).withBody({
11
- status: null,
12
- meta: null,
13
- message: null,
14
- ...body
15
- }).build();
16
- }
@@ -1,44 +0,0 @@
1
- import { validateSchema } from '../../../core/utils';
2
- import { CallSchema } from '../../schema';
3
- export default class Call {
4
- constructor() {
5
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
- const validatedData = validateSchema({
7
- schema: CallSchema,
8
- data,
9
- entityName: 'Call'
10
- }); // Set required properties from schema
11
-
12
- this.id = validatedData.id;
13
- this.integrationServiceId = validatedData.integrationServiceId;
14
- this.actor = validatedData.actor;
15
- this.channelId = validatedData.channelId;
16
- this.createdTime = validatedData.createdTime;
17
- this.direction = validatedData.direction;
18
- this.sessionId = validatedData.sessionId;
19
- this.status = validatedData.status; // Set optional properties from schema
20
-
21
- this.meta = validatedData.meta || null;
22
- this.participants = validatedData.participants || null;
23
- this.session = validatedData.session || false;
24
- this.statuses = validatedData.statuses || null;
25
- }
26
-
27
- toJSON() {
28
- return {
29
- id: this.id,
30
- integrationServiceId: this.integrationServiceId,
31
- actor: this.actor,
32
- channelId: this.channelId,
33
- createdTime: this.createdTime,
34
- direction: this.direction,
35
- sessionId: this.sessionId,
36
- status: this.status,
37
- meta: this.meta,
38
- participants: this.participants,
39
- session: this.session,
40
- statuses: this.statuses
41
- };
42
- }
43
-
44
- }
@@ -1 +0,0 @@
1
- export { default as Call } from './Call';
@@ -1,8 +0,0 @@
1
- const CallStatus = {
2
- INITIATED: 'INITIATED',
3
- IN_PROGRESS: 'IN_PROGRESS',
4
- ENDED: 'ENDED',
5
- REJECTED: 'REJECTED',
6
- MISSED: 'MISSED'
7
- };
8
- export default CallStatus;
@@ -1 +0,0 @@
1
- export { default as CallStatus } from './CallStatus';
@@ -1,32 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- import { ModuleNames } from '../../../../core/constants';
3
- import BaseAPI from '../../../../infrastructure/api/BaseAPI';
4
- import { getCallsRequest, getCallRequest, initiateCallRequest, updateCallStatusRequest } from '../../../dto';
5
- export default class ICallRepository extends BaseAPI {
6
- constructor() {
7
- super({
8
- module: ModuleNames.CALLS
9
- });
10
- }
11
-
12
- getCalls() {
13
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCallsRequest();
14
- throw new Error('Method not implemented.');
15
- }
16
-
17
- getCall() {
18
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getCallRequest();
19
- throw new Error('Method not implemented.');
20
- }
21
-
22
- updateCallStatus() {
23
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateCallStatusRequest();
24
- throw new Error('Method not implemented.');
25
- }
26
-
27
- initiateCall() {
28
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initiateCallRequest();
29
- throw new Error('Method not implemented.');
30
- }
31
-
32
- }
@@ -1 +0,0 @@
1
- export { default as ICallRepository } from './ICallRepository';
@@ -1,59 +0,0 @@
1
- import { MessageDirection } from '../../enum/message';
2
- import { CallStatus } from '../../enum/call';
3
- import { ActorSchema } from '../actor';
4
- import { IntegrationServices } from '../../enum';
5
- const CallSchema = {
6
- id: {
7
- type: 'string',
8
- required: true
9
- },
10
- actor: {
11
- type: 'object',
12
- required: true,
13
- schema: ActorSchema
14
- },
15
- channelId: {
16
- type: 'string',
17
- required: true
18
- },
19
- createdTime: {
20
- type: 'string',
21
- required: true
22
- },
23
- direction: {
24
- type: 'string',
25
- required: true,
26
- enum: Object.values(MessageDirection)
27
- },
28
- integrationServiceId: {
29
- type: 'string',
30
- required: true,
31
- enum: Object.values(IntegrationServices)
32
- },
33
- meta: {
34
- type: 'array',
35
- required: false
36
- },
37
- participants: {
38
- type: 'array',
39
- required: false
40
- },
41
- sessionId: {
42
- type: 'string',
43
- required: true
44
- },
45
- session: {
46
- type: 'object',
47
- required: false
48
- },
49
- status: {
50
- type: 'string',
51
- required: true,
52
- enum: Object.values(CallStatus)
53
- },
54
- statuses: {
55
- type: 'array',
56
- required: false
57
- }
58
- };
59
- export default CallSchema;
@@ -1 +0,0 @@
1
- export { default as CallSchema } from './CallSchema';
@@ -1,27 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default as CallSDK } from './CallSDK';
@@ -1,30 +0,0 @@
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
- }).toJSON();
25
- } catch (error) {
26
- throw new AdapterError(`Failed to adapt message: ${error.message}`);
27
- }
28
- }
29
-
30
- }
@@ -1 +0,0 @@
1
- export { default as CallAdapter } from './CallAdapter';
@@ -1,44 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default as CallAPI } from './CallAPI';
@@ -1,29 +0,0 @@
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
- };
@@ -1,10 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default as callAPIRegistry } from './callAPIRegistry';
@@ -1,73 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { default as CallRepository } from './CallRepository';