@zohoim/client-sdk 1.0.0-poc3 → 1.0.0-poc30
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/urls/base/index.js +11 -0
- package/es/config/urls/bots/bots-api-url.js +8 -0
- package/es/config/urls/bots/index.js +2 -0
- package/es/config/urls/channels/channel-agents-api-url.js +8 -0
- package/es/config/urls/channels/index.js +2 -0
- package/es/config/urls/index.js +16 -0
- package/es/config/urls/sessions/index.js +2 -0
- package/es/config/urls/sessions/sessions-api-url.js +9 -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/index.js +2 -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/Session/Session.js +36 -0
- package/es/domain/entities/Session/index.js +2 -0
- package/es/domain/entities/index.js +4 -2
- package/es/domain/enum/actor/index.js +2 -0
- package/es/domain/enum/bot/BotServiceType.js +5 -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 +74 -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/IChannelAgent.js +6 -2
- package/es/domain/interfaces/channels/index.js +1 -1
- package/es/domain/interfaces/index.js +3 -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/index.js +3 -0
- package/es/domain/schema/session/SessionSchema.js +86 -0
- package/es/domain/schema/session/index.js +2 -0
- package/es/domain/services/bots/BotService.js +33 -0
- package/es/domain/services/bots/index.js +2 -0
- package/es/domain/services/channels/ChannelAgentService.js +25 -6
- package/es/domain/services/channels/index.js +1 -1
- package/es/domain/services/index.js +3 -1
- package/es/domain/services/sessions/SessionService.js +33 -0
- package/es/domain/services/sessions/index.js +2 -0
- package/es/index.js +10 -1
- package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
- package/es/infrastructure/adapters/bots/index.js +2 -0
- package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +30 -0
- package/es/infrastructure/adapters/channels/index.js +2 -0
- package/es/infrastructure/adapters/index.js +3 -0
- package/es/infrastructure/adapters/sessions/SessionAdapter.js +37 -0
- package/es/infrastructure/adapters/sessions/index.js +2 -0
- package/es/infrastructure/api/bots/BotAPI.js +22 -0
- package/es/infrastructure/api/bots/index.js +2 -0
- package/es/infrastructure/api/channels/ChannelAgentAPI.js +22 -0
- package/es/infrastructure/api/channels/index.js +2 -0
- package/es/infrastructure/api/index.js +3 -0
- package/es/infrastructure/api/sessions/SessionAPI.js +22 -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 +18 -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/index.js +1 -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 +23 -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 -7
- 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,11 @@
|
|
|
1
|
+
import { IM_API_PREFIX } from "../../../core/constants";
|
|
2
|
+
|
|
3
|
+
const createBaseUrl = path => `${IM_API_PREFIX}${path}`;
|
|
4
|
+
|
|
5
|
+
const createEndpoint = (url, method, requestInterface) => ({
|
|
6
|
+
url,
|
|
7
|
+
method,
|
|
8
|
+
...requestInterface
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { createBaseUrl, createEndpoint };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTTP_METHODS } from "../../../core/constants";
|
|
2
|
+
import { getBotsRequest } from "../../../infrastructure/interfaces/api";
|
|
3
|
+
import { createBaseUrl, createEndpoint } from "../base";
|
|
4
|
+
const BASE_URL = createBaseUrl('/bots');
|
|
5
|
+
const BOTS_API_URLS = {
|
|
6
|
+
LIST: createEndpoint(BASE_URL, HTTP_METHODS.GET, getBotsRequest())
|
|
7
|
+
};
|
|
8
|
+
export default BOTS_API_URLS;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTTP_METHODS } from "../../../core/constants";
|
|
2
|
+
import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
|
|
3
|
+
import { createBaseUrl, createEndpoint } from "../base";
|
|
4
|
+
const BASE_URL = createBaseUrl('/channels/:channelId/agents');
|
|
5
|
+
const CHANNEL_AGENTS_API_URLS = {
|
|
6
|
+
LIST: createEndpoint(BASE_URL, HTTP_METHODS.GET, getChannelAgentsRequest())
|
|
7
|
+
};
|
|
8
|
+
export default CHANNEL_AGENTS_API_URLS;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModuleNames } from "../../core/constants";
|
|
2
|
+
import { BOTS_API_URLS } from "./bots";
|
|
3
|
+
import { CHANNEL_AGENTS_API_URLS } from "./channels";
|
|
4
|
+
import { SESSIONS_API_URLS } from "./sessions";
|
|
5
|
+
import selectn from 'selectn';
|
|
6
|
+
const urlMapping = {
|
|
7
|
+
[ModuleNames.BOTS]: BOTS_API_URLS,
|
|
8
|
+
[ModuleNames.CHANNELS]: {
|
|
9
|
+
agents: CHANNEL_AGENTS_API_URLS
|
|
10
|
+
},
|
|
11
|
+
[ModuleNames.SESSIONS]: SESSIONS_API_URLS
|
|
12
|
+
};
|
|
13
|
+
export function getUrlConfig(module) {
|
|
14
|
+
const urlConfig = selectn(module, urlMapping) || {};
|
|
15
|
+
return urlConfig;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import { HTTP_METHODS } from "../../../core/constants";
|
|
3
|
+
import { createBaseUrl, createEndpoint } from "../base";
|
|
4
|
+
const BASE_URL = createBaseUrl('/sessions');
|
|
5
|
+
const SINGLE_SESSION_URL = `${BASE_URL}/:sessionId`;
|
|
6
|
+
const SESSIONS_API_URLS = {
|
|
7
|
+
UPDATE_SESSION_ASSIGNEE: createEndpoint(SINGLE_SESSION_URL, HTTP_METHODS.PATCH, updateSessionAssigneeRequest())
|
|
8
|
+
};
|
|
9
|
+
export default SESSIONS_API_URLS;
|
|
@@ -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.botService,
|
|
10
|
+
name: validatedData.name,
|
|
11
|
+
isActive: validatedData.isActive,
|
|
12
|
+
createdTime: validatedData.createdTime,
|
|
13
|
+
logoURL: validatedData.logoURL,
|
|
14
|
+
createdBy: validatedData.createdBy
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toJSON() {
|
|
19
|
+
return { ...this.data
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
channel: validatedData.channel
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toJSON() {
|
|
32
|
+
return { ...this.data
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { configRegistry } from "../../infrastructure/sdk/config";
|
|
2
|
+
export default class BaseAPI {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.httpClient = configRegistry.getHttpClient();
|
|
5
|
+
this.baseURL = configRegistry.getBaseURL();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
replacePathParams(url, params) {
|
|
9
|
+
let _url = url;
|
|
10
|
+
Object.entries(params).forEach(_ref => {
|
|
11
|
+
let [key, value] = _ref;
|
|
12
|
+
_url = url.replace(`:${key}`, value);
|
|
13
|
+
});
|
|
14
|
+
return _url;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
buildUrl(_ref2) {
|
|
18
|
+
let {
|
|
19
|
+
url,
|
|
20
|
+
params,
|
|
21
|
+
query
|
|
22
|
+
} = _ref2;
|
|
23
|
+
|
|
24
|
+
const _params = params || {};
|
|
25
|
+
|
|
26
|
+
const _query = query || {};
|
|
27
|
+
|
|
28
|
+
let _url = this.replacePathParams(url, _params);
|
|
29
|
+
|
|
30
|
+
if (this.baseURL) {
|
|
31
|
+
_url = `${this.baseURL}${_url}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const queryString = this.buildQuery(_query);
|
|
35
|
+
|
|
36
|
+
if (queryString) {
|
|
37
|
+
return `${_url}?${queryString}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return _url;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
buildQuery(query) {
|
|
44
|
+
const filteredQuery = Object.entries(query).filter(_ref3 => {
|
|
45
|
+
let [, value] = _ref3;
|
|
46
|
+
return value !== undefined && value !== null && value !== '';
|
|
47
|
+
}).reduce((acc, _ref4) => {
|
|
48
|
+
let [key, value] = _ref4;
|
|
49
|
+
acc[key] = value;
|
|
50
|
+
return acc;
|
|
51
|
+
}, {});
|
|
52
|
+
return new URLSearchParams(filteredQuery).toString();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async request(_ref5) {
|
|
56
|
+
let {
|
|
57
|
+
urlConfig,
|
|
58
|
+
request
|
|
59
|
+
} = _ref5;
|
|
60
|
+
const url = this.buildUrl({
|
|
61
|
+
url: urlConfig.url,
|
|
62
|
+
params: request.params || {},
|
|
63
|
+
query: request.query || {}
|
|
64
|
+
});
|
|
65
|
+
const httpRequest = await this.httpClient.request({
|
|
66
|
+
url,
|
|
67
|
+
method: urlConfig.method,
|
|
68
|
+
header: urlConfig.header,
|
|
69
|
+
payload: request.body || {}
|
|
70
|
+
});
|
|
71
|
+
return httpRequest;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getBotsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class IBot extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
async getBots() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
|
|
7
|
+
throw new Error('Method not implemented');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class IChannelAgent extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
getAgents() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
|
|
3
7
|
throw new Error('Method not implemented.');
|
|
4
8
|
}
|
|
5
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import IChannelAgent from
|
|
1
|
+
import IChannelAgent from "./IChannelAgent";
|
|
2
2
|
export { IChannelAgent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
|
|
2
|
+
import BaseAPI from "../BaseAPI";
|
|
3
|
+
export default class ISession extends BaseAPI {
|
|
4
|
+
// eslint-disable-next-line no-unused-vars
|
|
5
|
+
updateAssignee() {
|
|
6
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|