@zohoim/client-sdk 1.0.0-poc4 → 1.0.0-poc41
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.
- package/es/config/registry/bots/botAPIRegistry.js +12 -0
- package/es/config/registry/bots/constructBotEndPoint.js +10 -0
- package/es/config/registry/bots/index.js +2 -0
- package/es/config/registry/channels/channelAPIRegistry.js +16 -0
- package/es/config/registry/channels/channelAgentAPIRegistry.js +12 -0
- package/es/config/registry/channels/constructChannelEndPoint.js +10 -0
- package/es/config/registry/channels/index.js +2 -0
- package/es/config/registry/createAPIRegistry.js +7 -0
- package/es/config/registry/createBaseUrl.js +3 -0
- package/es/config/registry/getRegistryConfig.js +20 -0
- package/es/config/registry/index.js +2 -0
- package/es/config/registry/sessions/constructSessionEndPoint.js +10 -0
- package/es/config/registry/sessions/index.js +2 -0
- package/es/config/registry/sessions/sessionAPIRegistry.js +12 -0
- package/es/core/constants/HttpMethods.js +8 -0
- package/es/core/constants/ModuleNames.js +6 -0
- package/es/core/constants/index.js +4 -0
- package/es/core/errors/AdapterError.js +7 -0
- package/es/core/errors/index.js +3 -0
- package/es/core/utils/ResponseUtils.js +24 -0
- package/es/core/utils/index.js +3 -0
- package/es/core/utils/validateSchema.js +68 -0
- package/es/domain/entities/Actor/Actor.js +23 -0
- package/es/domain/entities/Actor/index.js +2 -2
- package/es/domain/entities/Agent/Agent.js +13 -102
- package/es/domain/entities/Agent/index.js +1 -1
- package/es/domain/entities/Bot/Bot.js +23 -0
- package/es/domain/entities/Bot/index.js +2 -0
- package/es/domain/entities/Channel/Channel.js +38 -0
- package/es/domain/entities/Channel/index.js +2 -0
- package/es/domain/entities/Session/Session.js +35 -0
- package/es/domain/entities/Session/index.js +2 -0
- package/es/domain/entities/index.js +5 -2
- package/es/domain/enum/actor/index.js +2 -0
- package/es/domain/enum/bot/BotServiceType.js +7 -0
- package/es/domain/enum/bot/index.js +2 -0
- package/es/domain/enum/index.js +4 -0
- package/es/domain/enum/integrationServices/IntegrationServices.js +11 -0
- package/es/domain/enum/integrationServices/index.js +2 -0
- package/es/domain/enum/session/SessionReplyStatus.js +20 -0
- package/es/domain/enum/session/SessionStatus.js +9 -0
- package/es/domain/enum/session/index.js +3 -0
- package/es/domain/interfaces/BaseAPI.js +86 -0
- package/es/domain/interfaces/IAdapter.js +6 -0
- package/es/domain/interfaces/bots/IBot.js +10 -0
- package/es/domain/interfaces/bots/index.js +2 -0
- package/es/domain/interfaces/channels/IChannel.js +10 -0
- package/es/domain/interfaces/channels/IChannelAgent.js +6 -2
- package/es/domain/interfaces/channels/index.js +3 -2
- package/es/domain/interfaces/index.js +5 -1
- package/es/domain/interfaces/sessions/ISession.js +10 -0
- package/es/domain/interfaces/sessions/index.js +2 -0
- package/es/domain/schema/actor/ActorSchema.js +33 -0
- package/es/domain/schema/actor/AgentSchema.js +29 -0
- package/es/domain/schema/actor/index.js +3 -0
- package/es/domain/schema/bot/BotSchema.js +33 -0
- package/es/domain/schema/bot/index.js +2 -0
- package/es/domain/schema/channel/ChannelSchema.js +49 -0
- package/es/domain/schema/channel/index.js +2 -0
- package/es/domain/schema/index.js +5 -0
- package/es/domain/schema/integrationService/IntegrationServiceSchema.js +31 -0
- package/es/domain/schema/integrationService/index.js +2 -0
- package/es/domain/schema/session/SessionSchema.js +82 -0
- package/es/domain/schema/session/index.js +2 -0
- package/es/domain/services/bots/BotService.js +27 -0
- package/es/domain/services/bots/index.js +2 -0
- package/es/domain/services/channels/ChannelAgentService.js +20 -7
- package/es/domain/services/channels/ChannelService.js +27 -0
- package/es/domain/services/channels/index.js +3 -2
- package/es/domain/services/index.js +3 -1
- package/es/domain/services/sessions/SessionService.js +27 -0
- package/es/domain/services/sessions/index.js +2 -0
- package/es/index.js +9 -1
- package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
- package/es/infrastructure/adapters/bots/index.js +2 -0
- package/es/infrastructure/adapters/channels/ChannelAdapter.js +29 -0
- package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +30 -0
- package/es/infrastructure/adapters/channels/index.js +3 -0
- package/es/infrastructure/adapters/index.js +3 -0
- package/es/infrastructure/adapters/sessions/SessionAdapter.js +36 -0
- package/es/infrastructure/adapters/sessions/index.js +2 -0
- package/es/infrastructure/api/bots/BotAPI.js +21 -0
- package/es/infrastructure/api/bots/index.js +2 -0
- package/es/infrastructure/api/channels/ChannelAPI.js +21 -0
- package/es/infrastructure/api/channels/ChannelAgentAPI.js +29 -0
- package/es/infrastructure/api/channels/index.js +3 -0
- package/es/infrastructure/api/index.js +3 -0
- package/es/infrastructure/api/sessions/SessionAPI.js +21 -0
- package/es/infrastructure/api/sessions/index.js +2 -0
- package/es/infrastructure/interfaces/api/base/RequestBuilder.js +42 -0
- package/es/infrastructure/interfaces/api/base/index.js +2 -0
- package/es/infrastructure/interfaces/api/bots/getBotsRequest.js +19 -0
- package/es/infrastructure/interfaces/api/bots/index.js +2 -0
- package/es/infrastructure/interfaces/api/channels/agents/getChannelAgentsRequest.js +19 -0
- package/es/infrastructure/interfaces/api/channels/agents/index.js +2 -0
- package/es/infrastructure/interfaces/api/channels/getChannelsRequest.js +27 -0
- package/es/infrastructure/interfaces/api/channels/index.js +3 -0
- package/es/infrastructure/interfaces/api/index.js +3 -0
- package/es/infrastructure/interfaces/api/sessions/index.js +2 -0
- package/es/infrastructure/interfaces/api/sessions/updateSessionAssigneeRequest.js +18 -0
- package/es/infrastructure/interfaces/index.js +1 -0
- package/es/infrastructure/managers/ModuleFactory.js +31 -0
- package/es/infrastructure/managers/ModuleManager.js +44 -0
- package/es/infrastructure/managers/index.js +2 -0
- package/es/infrastructure/sdk/IMSDK.js +47 -0
- package/es/infrastructure/sdk/bots/BotSDK.js +20 -0
- package/es/infrastructure/sdk/bots/index.js +2 -0
- package/es/infrastructure/sdk/channels/ChannelSDK.js +30 -0
- package/es/infrastructure/sdk/channels/index.js +2 -0
- package/es/infrastructure/sdk/config/configRegistry.js +27 -0
- package/es/infrastructure/sdk/config/index.js +2 -0
- package/es/infrastructure/sdk/index.js +2 -0
- package/es/infrastructure/sdk/sessions/SessionSDK.js +20 -0
- package/es/infrastructure/sdk/sessions/index.js +2 -0
- package/package.json +1 -1
- package/es/domain/index.js +0 -3
- /package/es/{domain → core}/errors/ValidationError.js +0 -0
- /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,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,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,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,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,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
|
|
2
|
-
export {
|
|
1
|
+
import Actor from "./Actor";
|
|
2
|
+
export { Actor };
|
|
@@ -1,110 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { validateSchema } from "../../../core/utils";
|
|
2
|
+
import { AgentSchema } from "../../schema";
|
|
3
3
|
export default class Agent {
|
|
4
4
|
constructor() {
|
|
5
|
-
let {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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,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,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,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,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;
|