@zohoim/client-sdk 1.0.0-poc19 → 1.0.0-poc20
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/bots/bots-api-url.js +11 -0
- package/es/config/urls/bots/index.js +2 -0
- package/es/config/urls/sessions/index.js +2 -0
- package/es/core/constants/ModuleNames.js +2 -1
- package/es/domain/entities/Bot/Bot.js +23 -0
- package/es/domain/entities/Bot/index.js +2 -0
- package/es/domain/entities/index.js +2 -1
- package/es/domain/enum/bot/BotServiceType.js +5 -0
- package/es/domain/enum/bot/index.js +2 -0
- package/es/domain/enum/index.js +2 -1
- package/es/domain/interfaces/bots/IBot.js +10 -0
- package/es/domain/interfaces/bots/index.js +2 -0
- package/es/domain/interfaces/index.js +2 -1
- package/es/domain/schema/bot/BotSchema.js +33 -0
- package/es/domain/schema/bot/index.js +2 -0
- package/es/domain/schema/index.js +2 -1
- package/es/domain/services/bots/BotService.js +31 -0
- package/es/domain/services/bots/index.js +2 -0
- package/es/domain/services/index.js +3 -1
- package/es/domain/services/sessions/SessionService.js +3 -3
- package/es/infrastructure/adapters/bots/BotAdapter.js +25 -0
- package/es/infrastructure/adapters/bots/index.js +2 -0
- package/es/infrastructure/adapters/index.js +2 -1
- package/es/infrastructure/api/bots/BotAPI.js +22 -0
- package/es/infrastructure/api/bots/index.js +2 -0
- package/es/infrastructure/api/index.js +3 -1
- package/es/infrastructure/interfaces/api/bots/GetBotsRequest.js +14 -0
- package/es/infrastructure/interfaces/api/bots/index.js +2 -0
- package/es/infrastructure/interfaces/api/index.js +2 -1
- package/es/infrastructure/managers/ModuleFactory.js +9 -0
- package/es/infrastructure/managers/ModuleManager.js +1 -1
- package/es/infrastructure/sdk/IMSDK.js +5 -0
- package/es/infrastructure/sdk/bots/BotSDK.js +20 -0
- package/es/infrastructure/sdk/bots/index.js +2 -0
- package/es/infrastructure/sdk/sessions/SessionSDK.js +1 -1
- package/package.json +1 -1
- package/es/config/urls/index.js +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HTTP_METHODS, IM_API_PREFIX } from '../../../core/constants';
|
|
2
|
+
import { GetBotsRequest } from '../../../infrastructure/interfaces/api';
|
|
3
|
+
const BASE_URL = `${IM_API_PREFIX}/bots`;
|
|
4
|
+
const BOTS_API_URLS = {
|
|
5
|
+
LIST: {
|
|
6
|
+
url: BASE_URL,
|
|
7
|
+
method: HTTP_METHODS.GET,
|
|
8
|
+
...GetBotsRequest
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export default BOTS_API_URLS;
|
|
@@ -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
|
+
}
|
package/es/domain/enum/index.js
CHANGED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BotServiceType } from '../../enum';
|
|
2
|
+
const BotSchema = {
|
|
3
|
+
id: {
|
|
4
|
+
type: 'string',
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
botServiceType: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true,
|
|
10
|
+
enum: [BotServiceType.DESK_GC_BOT, BotServiceType.DESK_ZIA_BOT]
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
isActive: {
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
createdTime: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
logoURL: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
createdBy: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default BotSchema;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BOTS_API_URLS } from '../../../config/urls/bots';
|
|
2
|
+
import { BotAdapter } from '../../../infrastructure/adapters';
|
|
3
|
+
import { BotAPI } from '../../../infrastructure/api';
|
|
4
|
+
import { GetBotsRequest } from '../../../infrastructure/interfaces/api';
|
|
5
|
+
import { IBot } from '../../interfaces';
|
|
6
|
+
export default class BotService extends IBot {
|
|
7
|
+
constructor(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
botAPI,
|
|
10
|
+
botAdapter
|
|
11
|
+
} = _ref;
|
|
12
|
+
super();
|
|
13
|
+
this.botAPI = botAPI || new BotAPI({
|
|
14
|
+
urlConfig: BOTS_API_URLS
|
|
15
|
+
});
|
|
16
|
+
this.botAdapter = botAdapter || new BotAdapter();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getBots() {
|
|
20
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
|
|
21
|
+
const bots = await this.botAPI.getBots(request);
|
|
22
|
+
return bots.map(this.botAdapter.adapt);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
getBots: this.getBots.bind(this)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import SESSIONS_API_URLS from '../../../config/urls/sessions
|
|
1
|
+
import { SESSIONS_API_URLS } from '../../../config/urls/sessions';
|
|
2
2
|
import { SessionAdapter } from '../../../infrastructure/adapters';
|
|
3
|
-
import { SessionAPI } from '../../../infrastructure/api
|
|
3
|
+
import { SessionAPI } from '../../../infrastructure/api';
|
|
4
4
|
import { UpdateSessionAssigneeRequest } from '../../../infrastructure/interfaces/api';
|
|
5
5
|
import { ISession } from '../../interfaces';
|
|
6
6
|
export default class SessionService extends ISession {
|
|
@@ -19,7 +19,7 @@ export default class SessionService extends ISession {
|
|
|
19
19
|
async updateAssignee() {
|
|
20
20
|
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
|
|
21
21
|
const session = await this.sessionAPI.updateAssignee(request);
|
|
22
|
-
return this.
|
|
22
|
+
return this.sessionAdapter.adapt(session);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
toJSON() {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdapterError } from '../../../core/errors';
|
|
2
|
+
import { Bot } from '../../../domain/entities';
|
|
3
|
+
import BaseAdapter from '../BaseAdapter';
|
|
4
|
+
export default class BotAdapter extends BaseAdapter {
|
|
5
|
+
static adapt(botData) {
|
|
6
|
+
if (!botData) {
|
|
7
|
+
throw new AdapterError('Bot data is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
return new Bot({
|
|
12
|
+
id: botData.id,
|
|
13
|
+
botServiceType: botData.botService.id,
|
|
14
|
+
name: botData.name,
|
|
15
|
+
isActive: botData.isActive,
|
|
16
|
+
createdTime: botData.createdTime,
|
|
17
|
+
logoURL: botData.logoURL,
|
|
18
|
+
createdBy: botData.createdBy
|
|
19
|
+
}).toJSON();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new AdapterError(`Failed to adapt bot: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IBot } from '../../../domain/interfaces';
|
|
2
|
+
import { GetBotsRequest } from '../../interfaces/api';
|
|
3
|
+
export default class BotAPI extends IBot {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
urlConfig
|
|
7
|
+
} = _ref;
|
|
8
|
+
super();
|
|
9
|
+
this.urlConfig = urlConfig;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getBots() {
|
|
13
|
+
let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
|
|
14
|
+
const urlConfig = this.urlConfig.LIST;
|
|
15
|
+
const httpRequest = await this.request({
|
|
16
|
+
urlConfig,
|
|
17
|
+
request
|
|
18
|
+
});
|
|
19
|
+
return httpRequest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ModuleNames } from '../../core/constants';
|
|
2
|
+
import { BotSDK } from '../sdk/bots';
|
|
2
3
|
import { ChannelSDK } from '../sdk/channels';
|
|
3
4
|
import { SessionSDK } from '../sdk/sessions';
|
|
4
5
|
const ModuleFactory = {
|
|
@@ -17,6 +18,14 @@ const ModuleFactory = {
|
|
|
17
18
|
return new SessionSDK({
|
|
18
19
|
config
|
|
19
20
|
}).toJSON();
|
|
21
|
+
},
|
|
22
|
+
[ModuleNames.BOTS]: _ref3 => {
|
|
23
|
+
let {
|
|
24
|
+
config
|
|
25
|
+
} = _ref3;
|
|
26
|
+
return new BotSDK({
|
|
27
|
+
config
|
|
28
|
+
}).toJSON();
|
|
20
29
|
}
|
|
21
30
|
};
|
|
22
31
|
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];
|
|
6
|
+
this.supportedModules = [ModuleNames.CHANNELS, ModuleNames.SESSIONS, ModuleNames.BOTS];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
initialize(_ref) {
|
|
@@ -27,6 +27,10 @@ export default class IMSDK {
|
|
|
27
27
|
return this._moduleManager.getModule(ModuleNames.SESSIONS);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
get bots() {
|
|
31
|
+
return this._moduleManager.getModule(ModuleNames.BOTS);
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
hasModule(moduleName) {
|
|
31
35
|
return this._modules.has(moduleName);
|
|
32
36
|
}
|
|
@@ -35,6 +39,7 @@ export default class IMSDK {
|
|
|
35
39
|
return {
|
|
36
40
|
channels: this.channels,
|
|
37
41
|
sessions: this.sessions,
|
|
42
|
+
bots: this.bots,
|
|
38
43
|
hasModule: this.hasModule.bind(this)
|
|
39
44
|
};
|
|
40
45
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BotService } from '../../../domain/services';
|
|
2
|
+
|
|
3
|
+
class BotSDK extends BotService {
|
|
4
|
+
constructor(_ref) {
|
|
5
|
+
let {
|
|
6
|
+
config
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
botAPI,
|
|
10
|
+
botAdapter
|
|
11
|
+
} = config;
|
|
12
|
+
super({
|
|
13
|
+
botAPI,
|
|
14
|
+
botAdapter
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default BotSDK;
|
package/package.json
CHANGED
package/es/config/urls/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './channels';
|