@zohoim/client-sdk 1.0.0-poc4 → 1.0.0-poc40

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 (118) hide show
  1. package/es/config/registry/bots/botAPIRegistry.js +12 -0
  2. package/es/config/registry/bots/constructBotEndPoint.js +10 -0
  3. package/es/config/registry/bots/index.js +2 -0
  4. package/es/config/registry/channels/channelAPIRegistry.js +16 -0
  5. package/es/config/registry/channels/channelAgentAPIRegistry.js +12 -0
  6. package/es/config/registry/channels/constructChannelEndPoint.js +10 -0
  7. package/es/config/registry/channels/index.js +2 -0
  8. package/es/config/registry/createAPIRegistry.js +7 -0
  9. package/es/config/registry/createBaseUrl.js +3 -0
  10. package/es/config/registry/getRegistryConfig.js +20 -0
  11. package/es/config/registry/index.js +2 -0
  12. package/es/config/registry/sessions/constructSessionEndPoint.js +10 -0
  13. package/es/config/registry/sessions/index.js +2 -0
  14. package/es/config/registry/sessions/sessionAPIRegistry.js +12 -0
  15. package/es/core/constants/HttpMethods.js +8 -0
  16. package/es/core/constants/ModuleNames.js +6 -0
  17. package/es/core/constants/index.js +4 -0
  18. package/es/core/errors/AdapterError.js +7 -0
  19. package/es/core/errors/index.js +3 -0
  20. package/es/core/utils/ResponseUtils.js +24 -0
  21. package/es/core/utils/index.js +3 -0
  22. package/es/core/utils/validateSchema.js +68 -0
  23. package/es/domain/entities/Actor/Actor.js +23 -0
  24. package/es/domain/entities/Actor/index.js +2 -2
  25. package/es/domain/entities/Agent/Agent.js +13 -102
  26. package/es/domain/entities/Agent/index.js +1 -1
  27. package/es/domain/entities/Bot/Bot.js +23 -0
  28. package/es/domain/entities/Bot/index.js +2 -0
  29. package/es/domain/entities/Channel/Channel.js +38 -0
  30. package/es/domain/entities/Channel/index.js +2 -0
  31. package/es/domain/entities/Session/Session.js +35 -0
  32. package/es/domain/entities/Session/index.js +2 -0
  33. package/es/domain/entities/index.js +5 -2
  34. package/es/domain/enum/actor/index.js +2 -0
  35. package/es/domain/enum/bot/BotServiceType.js +7 -0
  36. package/es/domain/enum/bot/index.js +2 -0
  37. package/es/domain/enum/index.js +4 -0
  38. package/es/domain/enum/integrationServices/IntegrationServices.js +11 -0
  39. package/es/domain/enum/integrationServices/index.js +2 -0
  40. package/es/domain/enum/session/SessionReplyStatus.js +20 -0
  41. package/es/domain/enum/session/SessionStatus.js +9 -0
  42. package/es/domain/enum/session/index.js +3 -0
  43. package/es/domain/interfaces/BaseAPI.js +86 -0
  44. package/es/domain/interfaces/IAdapter.js +6 -0
  45. package/es/domain/interfaces/bots/IBot.js +10 -0
  46. package/es/domain/interfaces/bots/index.js +2 -0
  47. package/es/domain/interfaces/channels/IChannel.js +10 -0
  48. package/es/domain/interfaces/channels/IChannelAgent.js +6 -2
  49. package/es/domain/interfaces/channels/index.js +3 -2
  50. package/es/domain/interfaces/index.js +5 -1
  51. package/es/domain/interfaces/sessions/ISession.js +10 -0
  52. package/es/domain/interfaces/sessions/index.js +2 -0
  53. package/es/domain/schema/actor/ActorSchema.js +33 -0
  54. package/es/domain/schema/actor/AgentSchema.js +29 -0
  55. package/es/domain/schema/actor/index.js +3 -0
  56. package/es/domain/schema/bot/BotSchema.js +33 -0
  57. package/es/domain/schema/bot/index.js +2 -0
  58. package/es/domain/schema/channel/ChannelSchema.js +49 -0
  59. package/es/domain/schema/channel/index.js +2 -0
  60. package/es/domain/schema/index.js +5 -0
  61. package/es/domain/schema/integrationService/IntegrationServiceSchema.js +31 -0
  62. package/es/domain/schema/integrationService/index.js +2 -0
  63. package/es/domain/schema/session/SessionSchema.js +82 -0
  64. package/es/domain/schema/session/index.js +2 -0
  65. package/es/domain/services/bots/BotService.js +27 -0
  66. package/es/domain/services/bots/index.js +2 -0
  67. package/es/domain/services/channels/ChannelAgentService.js +20 -7
  68. package/es/domain/services/channels/ChannelService.js +27 -0
  69. package/es/domain/services/channels/index.js +3 -2
  70. package/es/domain/services/index.js +3 -1
  71. package/es/domain/services/sessions/SessionService.js +27 -0
  72. package/es/domain/services/sessions/index.js +2 -0
  73. package/es/index.js +10 -1
  74. package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
  75. package/es/infrastructure/adapters/bots/index.js +2 -0
  76. package/es/infrastructure/adapters/channels/ChannelAdapter.js +29 -0
  77. package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +30 -0
  78. package/es/infrastructure/adapters/channels/index.js +3 -0
  79. package/es/infrastructure/adapters/index.js +3 -0
  80. package/es/infrastructure/adapters/sessions/SessionAdapter.js +36 -0
  81. package/es/infrastructure/adapters/sessions/index.js +2 -0
  82. package/es/infrastructure/api/bots/BotAPI.js +21 -0
  83. package/es/infrastructure/api/bots/index.js +2 -0
  84. package/es/infrastructure/api/channels/ChannelAPI.js +21 -0
  85. package/es/infrastructure/api/channels/ChannelAgentAPI.js +29 -0
  86. package/es/infrastructure/api/channels/index.js +3 -0
  87. package/es/infrastructure/api/index.js +3 -0
  88. package/es/infrastructure/api/sessions/SessionAPI.js +21 -0
  89. package/es/infrastructure/api/sessions/index.js +2 -0
  90. package/es/infrastructure/interfaces/api/base/RequestBuilder.js +42 -0
  91. package/es/infrastructure/interfaces/api/base/index.js +2 -0
  92. package/es/infrastructure/interfaces/api/bots/getBotsRequest.js +19 -0
  93. package/es/infrastructure/interfaces/api/bots/index.js +2 -0
  94. package/es/infrastructure/interfaces/api/channels/agents/getChannelAgentsRequest.js +19 -0
  95. package/es/infrastructure/interfaces/api/channels/agents/index.js +2 -0
  96. package/es/infrastructure/interfaces/api/channels/getChannelsRequest.js +27 -0
  97. package/es/infrastructure/interfaces/api/channels/index.js +3 -0
  98. package/es/infrastructure/interfaces/api/index.js +3 -0
  99. package/es/infrastructure/interfaces/api/sessions/index.js +2 -0
  100. package/es/infrastructure/interfaces/api/sessions/updateSessionAssigneeRequest.js +18 -0
  101. package/es/infrastructure/interfaces/index.js +1 -0
  102. package/es/infrastructure/managers/ModuleFactory.js +31 -0
  103. package/es/infrastructure/managers/ModuleManager.js +44 -0
  104. package/es/infrastructure/managers/index.js +2 -0
  105. package/es/infrastructure/sdk/IMSDK.js +47 -0
  106. package/es/infrastructure/sdk/bots/BotSDK.js +20 -0
  107. package/es/infrastructure/sdk/bots/index.js +2 -0
  108. package/es/infrastructure/sdk/channels/ChannelSDK.js +30 -0
  109. package/es/infrastructure/sdk/channels/index.js +2 -0
  110. package/es/infrastructure/sdk/config/configRegistry.js +27 -0
  111. package/es/infrastructure/sdk/config/index.js +2 -0
  112. package/es/infrastructure/sdk/index.js +2 -0
  113. package/es/infrastructure/sdk/sessions/SessionSDK.js +20 -0
  114. package/es/infrastructure/sdk/sessions/index.js +2 -0
  115. package/package.json +1 -1
  116. package/es/domain/index.js +0 -3
  117. /package/es/{domain → core}/errors/ValidationError.js +0 -0
  118. /package/es/domain/{entities/Actor → enum/actor}/ActorType.js +0 -0
@@ -0,0 +1,12 @@
1
+ import { HTTP_METHODS } from "../../../core/constants";
2
+ import { getBotsRequest } from "../../../infrastructure/interfaces/api/bots";
3
+ import createAPIRegistry from "../createAPIRegistry";
4
+ import constructBotEndPoint from "./constructBotEndPoint";
5
+
6
+ function getBots() {
7
+ return createAPIRegistry(constructBotEndPoint(), HTTP_METHODS.GET, getBotsRequest());
8
+ }
9
+
10
+ export default {
11
+ getBots
12
+ };
@@ -0,0 +1,10 @@
1
+ import createBaseUrl from "../createBaseUrl";
2
+ export default function constructBotEndPoint(extra) {
3
+ const base = '/bots';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -0,0 +1,2 @@
1
+ import botAPIRegistry from "./botAPIRegistry";
2
+ export { botAPIRegistry };
@@ -0,0 +1,16 @@
1
+ import { HTTP_METHODS } from "../../../core/constants";
2
+ import { getChannelsRequest } from "../../../infrastructure/interfaces/api/channels";
3
+ import createAPIRegistry from "../createAPIRegistry";
4
+ import channelAgentAPIRegistry from "./channelAgentAPIRegistry";
5
+ import constructChannelEndPoint from "./constructChannelEndPoint";
6
+
7
+ function getChannels() {
8
+ return createAPIRegistry(constructChannelEndPoint(), HTTP_METHODS.GET, getChannelsRequest());
9
+ }
10
+
11
+ const channelAPIRegistry = {
12
+ getChannels,
13
+ agents: { ...channelAgentAPIRegistry
14
+ }
15
+ };
16
+ export default channelAPIRegistry;
@@ -0,0 +1,12 @@
1
+ import { HTTP_METHODS } from "../../../core/constants";
2
+ import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api/channels";
3
+ import createAPIRegistry from "../createAPIRegistry";
4
+ import constructChannelEndPoint from "./constructChannelEndPoint";
5
+
6
+ function getAgents() {
7
+ return createAPIRegistry(constructChannelEndPoint('/:channelId/agents'), HTTP_METHODS.GET, getChannelAgentsRequest());
8
+ }
9
+
10
+ export default {
11
+ getAgents
12
+ };
@@ -0,0 +1,10 @@
1
+ import createBaseUrl from "../createBaseUrl";
2
+ export default function constructChannelEndPoint(extra) {
3
+ const base = '/channels';
4
+
5
+ if (extra) {
6
+ return createBaseUrl(base + extra);
7
+ }
8
+
9
+ return createBaseUrl(base);
10
+ }
@@ -0,0 +1,2 @@
1
+ import channelAPIRegistry from "./channelAPIRegistry";
2
+ export { channelAPIRegistry };
@@ -0,0 +1,7 @@
1
+ export default function createAPIRegistry(endpoint, method, requestDefinition) {
2
+ return {
3
+ endpoint,
4
+ method,
5
+ ...requestDefinition
6
+ };
7
+ }
@@ -0,0 +1,3 @@
1
+ export default function createBaseUrl(path) {
2
+ return `/api/v1${path}`;
3
+ }
@@ -0,0 +1,20 @@
1
+ import selectn from 'selectn';
2
+ import { channelAPIRegistry } from "./channels";
3
+ import { ModuleNames } from "../../core/constants";
4
+ import { sessionAPIRegistry } from "./sessions";
5
+ import { botAPIRegistry } from "./bots";
6
+ const APIRegistry = {
7
+ [ModuleNames.CHANNELS]: channelAPIRegistry,
8
+ [ModuleNames.SESSIONS]: sessionAPIRegistry,
9
+ [ModuleNames.BOTS]: botAPIRegistry
10
+ };
11
+ export default function getRegistryConfig(module, operation) {
12
+ const moduleConfig = selectn(module, APIRegistry);
13
+
14
+ if (!moduleConfig) {
15
+ return null;
16
+ }
17
+
18
+ const operationConfig = moduleConfig[operation];
19
+ return operationConfig ? operationConfig() : null;
20
+ }
@@ -0,0 +1,2 @@
1
+ import getRegistryConfig from "./getRegistryConfig";
2
+ export { getRegistryConfig };
@@ -0,0 +1,10 @@
1
+ import createBaseUrl from "../createBaseUrl";
2
+ export default function constructSessionEndPoint(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 sessionAPIRegistry from "./sessionAPIRegistry";
2
+ export { sessionAPIRegistry };
@@ -0,0 +1,12 @@
1
+ import { HTTP_METHODS } from "../../../core/constants";
2
+ import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api/sessions";
3
+ import createAPIRegistry from "../createAPIRegistry";
4
+ import constructSessionEndPoint from "./constructSessionEndPoint";
5
+
6
+ function updateAssignee() {
7
+ return createAPIRegistry(constructSessionEndPoint('/:sessionId'), HTTP_METHODS.PATCH, updateSessionAssigneeRequest());
8
+ }
9
+
10
+ export default {
11
+ updateAssignee
12
+ };
@@ -0,0 +1,8 @@
1
+ const HTTP_METHODS = {
2
+ GET: 'GET',
3
+ POST: 'POST',
4
+ PUT: 'PUT',
5
+ PATCH: 'PATCH',
6
+ DELETE: 'DELETE'
7
+ };
8
+ export default HTTP_METHODS;
@@ -0,0 +1,6 @@
1
+ const ModuleNames = {
2
+ CHANNELS: 'channels',
3
+ SESSIONS: 'sessions',
4
+ BOTS: 'bots'
5
+ };
6
+ export default ModuleNames;
@@ -0,0 +1,4 @@
1
+ import HTTP_METHODS from "./HttpMethods";
2
+ import ModuleNames from "./ModuleNames";
3
+ const IM_API_PREFIX = '/api/v1';
4
+ export { ModuleNames, IM_API_PREFIX, HTTP_METHODS };
@@ -0,0 +1,7 @@
1
+ export default class AdapterError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'AdapterError';
5
+ }
6
+
7
+ }
@@ -0,0 +1,3 @@
1
+ import AdapterError from "./AdapterError";
2
+ import ValidationError from "./ValidationError";
3
+ export { ValidationError, AdapterError };
@@ -0,0 +1,24 @@
1
+ export default class ResponseUtils {
2
+ static adaptListResponse(response, adapter) {
3
+ if (!response) {
4
+ return response;
5
+ }
6
+
7
+ if (!response.data) {
8
+ return response;
9
+ }
10
+
11
+ return { ...response,
12
+ data: response.data.map(item => adapter(item))
13
+ };
14
+ }
15
+
16
+ static adaptSingleResponse(response, adapter) {
17
+ if (!response) {
18
+ return response;
19
+ }
20
+
21
+ return adapter(response);
22
+ }
23
+
24
+ }
@@ -0,0 +1,3 @@
1
+ import ResponseUtils from "./ResponseUtils";
2
+ import { validateSchema } from "./validateSchema";
3
+ export { validateSchema, ResponseUtils };
@@ -0,0 +1,68 @@
1
+ import { ValidationError } from "../errors";
2
+
3
+ function validateSchemaKeys(schema, data) {
4
+ Object.keys(schema).forEach(key => {
5
+ if (!(key in data)) {
6
+ throw new ValidationError(`Key '${key}' is missing in the data`);
7
+ }
8
+ });
9
+ }
10
+
11
+ function validateRequiredCheck(_ref) {
12
+ let {
13
+ value,
14
+ rules,
15
+ path
16
+ } = _ref;
17
+
18
+ if (rules.required && !value) {
19
+ throw new ValidationError(rules.message || `${path} is required`);
20
+ }
21
+ }
22
+
23
+ function validateEnumCheck(_ref2) {
24
+ let {
25
+ value,
26
+ rules,
27
+ path
28
+ } = _ref2;
29
+
30
+ if (rules.enum && !rules.enum.includes(value)) {
31
+ throw new ValidationError(`${path} must be one of: ${rules.enum.join(', ')}`);
32
+ }
33
+ }
34
+
35
+ export const validateSchema = (schema, data) => {
36
+ const validate = function (schemaObj, dataObj) {
37
+ let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
38
+ // Check if all schema keys exist in data
39
+ validateSchemaKeys(schemaObj, dataObj); // Validate each field
40
+
41
+ Object.entries(schemaObj).forEach(_ref3 => {
42
+ let [field, rules] = _ref3;
43
+ const value = dataObj[field];
44
+ const fieldPath = path ? `${path}.${field}` : field;
45
+ validateRequiredCheck({
46
+ value,
47
+ rules,
48
+ path: fieldPath
49
+ });
50
+
51
+ if (value !== null && value !== undefined) {
52
+ // Enum validation
53
+ validateEnumCheck({
54
+ value,
55
+ rules,
56
+ path: fieldPath
57
+ }); // Nested object validation
58
+
59
+ if (rules.type === 'object' && rules.schema) {
60
+ validate(rules.schema, value, fieldPath);
61
+ }
62
+ }
63
+ });
64
+ return dataObj;
65
+ };
66
+
67
+ return validate(schema, data);
68
+ };
@@ -0,0 +1,23 @@
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { ActorSchema } from "../../schema";
3
+ export default class Actor {
4
+ constructor() {
5
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
+ const validatedData = validateSchema(ActorSchema, data);
7
+ this.data = {
8
+ name: validatedData.name,
9
+ type: validatedData.type,
10
+ photoURL: validatedData.photoURL,
11
+ extId: validatedData.extId,
12
+ id: validatedData.id,
13
+ email: validatedData.email,
14
+ botType: validatedData.botType
15
+ };
16
+ }
17
+
18
+ toJSON() {
19
+ return { ...this.data
20
+ };
21
+ }
22
+
23
+ }
@@ -1,2 +1,2 @@
1
- import ActorType from './ActorType';
2
- export { ActorType };
1
+ import Actor from "./Actor";
2
+ export { Actor };
@@ -1,110 +1,21 @@
1
- import ValidationError from '../../errors/ValidationError';
2
- import ActorType from '../Actor/ActorType';
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { AgentSchema } from "../../schema";
3
3
  export default class Agent {
4
4
  constructor() {
5
- let {
6
- id = '',
7
- name = '',
8
- email = '',
9
- photoURL = '',
10
- zuid = '',
11
- type = ''
12
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
- Agent.validateFields({
14
- id,
15
- email,
16
- name,
17
- zuid
18
- });
19
- this._id = id;
20
- this._name = name;
21
- this._email = email;
22
- this._photoURL = photoURL;
23
- this._zuid = zuid;
24
- this.setType(type);
25
- }
26
-
27
- static validateFields(_ref) {
28
- let {
29
- id,
30
- email,
31
- name,
32
- zuid
33
- } = _ref;
34
- Agent.validateId(id);
35
- Agent.validateEmail(email);
36
- Agent.validateName(name);
37
- Agent.validateZuid(zuid);
38
- }
39
-
40
- static validateId(id) {
41
- if (!id) {
42
- throw new ValidationError('Agent ID is required');
43
- }
44
- }
45
-
46
- static validateEmail(email) {
47
- if (!email) {
48
- throw new ValidationError('Agent email is required');
49
- }
50
- }
51
-
52
- static validateName(name) {
53
- if (!name) {
54
- throw new ValidationError('Agent name is required');
55
- }
56
- }
57
-
58
- static validateZuid(zuid) {
59
- if (!zuid) {
60
- throw new ValidationError('Agent zuid is required');
61
- }
62
- }
63
-
64
- static validateType(type) {
65
- return type === ActorType.AGENT;
66
- }
67
-
68
- setType(type) {
69
- if (!Agent.validateType(type)) {
70
- throw new Error('Invalid actor type. Must be AGENT');
71
- }
72
-
73
- this._type = type;
74
- }
75
-
76
- get id() {
77
- return this._id;
78
- }
79
-
80
- get name() {
81
- return this._name;
82
- }
83
-
84
- get email() {
85
- return this._email;
86
- }
87
-
88
- get photoURL() {
89
- return this._photoURL;
90
- }
91
-
92
- get zuid() {
93
- return this._zuid;
94
- }
95
-
96
- get type() {
97
- return this._type;
5
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
+ const validatedData = validateSchema(AgentSchema, data);
7
+ this.data = {
8
+ id: validatedData.id,
9
+ name: validatedData.name,
10
+ email: validatedData.email,
11
+ photoURL: validatedData.photoURL || '',
12
+ zuid: validatedData.zuid,
13
+ type: validatedData.type
14
+ };
98
15
  }
99
16
 
100
17
  toJSON() {
101
- return {
102
- id: this._id,
103
- name: this._name,
104
- email: this._email,
105
- photoURL: this._photoURL,
106
- zuid: this._zuid,
107
- type: this._type
18
+ return { ...this.data
108
19
  };
109
20
  }
110
21
 
@@ -1,2 +1,2 @@
1
- import Agent from './Agent';
1
+ import Agent from "./Agent";
2
2
  export { Agent };
@@ -0,0 +1,23 @@
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { BotSchema } from "../../schema";
3
+ export default class Bot {
4
+ constructor() {
5
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
+ const validatedData = validateSchema(BotSchema, data);
7
+ this.data = {
8
+ id: validatedData.id,
9
+ botServiceType: validatedData.botServiceType,
10
+ name: validatedData.name,
11
+ isActive: validatedData.isActive,
12
+ createdTime: validatedData.createdTime,
13
+ photoURL: validatedData.photoURL || null,
14
+ createdBy: validatedData.createdBy
15
+ };
16
+ }
17
+
18
+ toJSON() {
19
+ return { ...this.data
20
+ };
21
+ }
22
+
23
+ }
@@ -0,0 +1,2 @@
1
+ import Bot from "./Bot";
2
+ export { Bot };
@@ -0,0 +1,38 @@
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { ChannelSchema } from "../../schema";
3
+ export default class Channel {
4
+ constructor() {
5
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
+ const validatedData = validateSchema(ChannelSchema, data); // Set required properties from schema
7
+
8
+ this.id = validatedData.id;
9
+ this.integrationService = validatedData.integrationService;
10
+ this.name = validatedData.name;
11
+ this.isActive = validatedData.isActive;
12
+ this.createdTime = validatedData.createdTime; // Set optional properties from schema
13
+
14
+ this.defaultBotId = validatedData.defaultBotId || null;
15
+ this.accountName = validatedData.accountName || null;
16
+ this.isSubscribed = validatedData.isSubscribed || false;
17
+ this.createdBy = validatedData.createdBy || null;
18
+ this.isOwner = validatedData.isOwner || false;
19
+ this.photoURL = validatedData.photoURL || null;
20
+ }
21
+
22
+ toJSON() {
23
+ return {
24
+ id: this.id,
25
+ integrationService: this.integrationService,
26
+ name: this.name,
27
+ defaultBotId: this.defaultBotId,
28
+ isActive: this.isActive,
29
+ createdTime: this.createdTime,
30
+ accountName: this.accountName,
31
+ isSubscribed: this.isSubscribed,
32
+ createdBy: this.createdBy,
33
+ isOwner: this.isOwner,
34
+ photoURL: this.photoURL
35
+ };
36
+ }
37
+
38
+ }
@@ -0,0 +1,2 @@
1
+ import Channel from "./Channel";
2
+ export { Channel };
@@ -0,0 +1,35 @@
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { SessionSchema } from "../../schema";
3
+ import { Actor } from "../Actor";
4
+ export default class Session {
5
+ constructor() {
6
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
+ const validatedData = validateSchema(SessionSchema, data);
8
+ this.data = {
9
+ channelId: validatedData.channelId,
10
+ status: validatedData.status,
11
+ createdTime: validatedData.createdTime,
12
+ agentId: validatedData.agentId,
13
+ botId: validatedData.botId,
14
+ actor: new Actor(validatedData.actor).toJSON(),
15
+ subject: validatedData.subject,
16
+ messagesCount: validatedData.messagesCount,
17
+ agentLastActiveTime: validatedData.agentLastActiveTime,
18
+ contactLastActiveTime: validatedData.contactLastActiveTime,
19
+ lastActiveTime: validatedData.lastActiveTime,
20
+ unreadMessagesCount: validatedData.unreadMessagesCount,
21
+ integrationServiceId: validatedData.integrationServiceId,
22
+ replyStatus: validatedData.replyStatus,
23
+ id: validatedData.id,
24
+ contactId: validatedData.contactId,
25
+ meta: validatedData.meta,
26
+ assignee: validatedData.assignee ? new Actor(validatedData.assignee).toJSON() : null
27
+ };
28
+ }
29
+
30
+ toJSON() {
31
+ return { ...this.data
32
+ };
33
+ }
34
+
35
+ }
@@ -0,0 +1,2 @@
1
+ import Session from "./Session";
2
+ export { Session };
@@ -1,2 +1,5 @@
1
- export * from './Actor';
2
- export * from './Agent';
1
+ export * from "./Actor";
2
+ export * from "./Agent";
3
+ export * from "./Session";
4
+ export * from "./Bot";
5
+ export * from "./Channel";
@@ -0,0 +1,2 @@
1
+ import ActorType from "./ActorType";
2
+ export { ActorType };
@@ -0,0 +1,7 @@
1
+ const BotServiceType = {
2
+ DESK_GC_BOT: 'DESK_GC_BOT',
3
+ DESK_ZIA_BOT: 'DESK_ZIA_BOT',
4
+ ZOHO_GC_BOT: 'ZOHO_GC_BOT',
5
+ ZOHO_ZIA_BOT: 'ZOHO_ZIA_BOT'
6
+ };
7
+ export default BotServiceType;
@@ -0,0 +1,2 @@
1
+ import BotServiceType from "./BotServiceType";
2
+ export { BotServiceType };
@@ -0,0 +1,4 @@
1
+ export * from "./integrationServices";
2
+ export * from "./session";
3
+ export * from "./actor";
4
+ export * from "./bot";
@@ -0,0 +1,11 @@
1
+ const IntegrationServices = {
2
+ TWILIO: 'TWILIO',
3
+ WHATSAPP: 'WHATSAPP',
4
+ TELEGRAM: 'TELEGRAM',
5
+ WECHAT: 'WECHAT',
6
+ LINE: 'LINE',
7
+ IM_TALK: 'IM_TALK',
8
+ FACEBOOKMESSENGER: 'FACEBOOKMESSENGER',
9
+ INSTAGRAM: 'INSTAGRAM'
10
+ };
11
+ export default IntegrationServices;
@@ -0,0 +1,2 @@
1
+ import IntegrationServices from "./IntegrationServices";
2
+ export { IntegrationServices };
@@ -0,0 +1,20 @@
1
+ const SessionReplyStatus = {
2
+ ACCEPTED: 'ACCEPTED',
3
+ CHANNEL_INACTIVE: 'CHANNEL_INACTIVE',
4
+ CHANNEL_REVOKED: 'CHANNEL_REVOKED',
5
+ SESSION_ENDED: 'SESSION_ENDED',
6
+ SESSION_BLOCKED: 'SESSION_BLOCKED',
7
+ SESSION_EXPIRED: 'SESSION_EXPIRED',
8
+ UNASSIGNED: 'UNASSIGNED',
9
+ NOT_AN_ASSIGNEE: 'NOT_AN_ASSIGNEE',
10
+ CREDIT_EXHAUSTED: 'CREDIT_EXHAUSTED',
11
+ ACCESSTOKEN_EXPIRED: 'ACCESSTOKEN_EXPIRED',
12
+ PERMISSION_REVOKED: 'PERMISSION_REVOKED',
13
+ UNEXPECTED_ERROR: 'UNEXPECTED_ERROR',
14
+ PAGE_REMOVED: 'PAGE_REMOVED',
15
+ SANDBOX_LIMIT_REACHED: 'SANDBOX_LIMIT_REACHED',
16
+ CHANNEL_DELETED: 'CHANNEL_DELETED',
17
+ ENDUSER_OFFLINE: 'ENDUSER_OFFLINE',
18
+ CONFIG_SKIPPED_CHANNEL: 'CONFIG_SKIPPED_CHANNEL'
19
+ };
20
+ export default SessionReplyStatus;
@@ -0,0 +1,9 @@
1
+ const SessionStatus = {
2
+ CREATED: 'CREATED',
3
+ OPEN: 'OPEN',
4
+ ON_PROGRESS: 'ON_PROGRESS',
5
+ ON_HOLD: 'ON_HOLD',
6
+ ENDED: 'ENDED',
7
+ BLOCKED: 'BLOCKED'
8
+ };
9
+ export default SessionStatus;
@@ -0,0 +1,3 @@
1
+ import SessionReplyStatus from "./SessionReplyStatus";
2
+ import SessionStatus from "./SessionStatus";
3
+ export { SessionStatus, SessionReplyStatus };