@zohoim/client-sdk 1.0.0-poc33 → 1.0.0-poc35
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/core/utils/ResponseUtils.js +15 -0
- package/es/core/utils/index.js +2 -1
- package/es/domain/services/bots/BotService.js +3 -2
- package/es/domain/services/channels/ChannelAgentService.js +3 -2
- package/es/domain/services/channels/ChannelService.js +3 -2
- package/es/domain/services/sessions/SessionService.js +3 -2
- package/es/infrastructure/api/channels/ChannelAPI.js +1 -1
- package/es/infrastructure/api/channels/ChannelAgentAPI.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class ResponseUtils {
|
|
2
|
+
static adaptListResponse(response, adapter) {
|
|
3
|
+
if (!response) return response;
|
|
4
|
+
if (!response.data) return response;
|
|
5
|
+
return { ...response,
|
|
6
|
+
data: response.data.map(item => adapter(item))
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static adaptSingleResponse(response, adapter) {
|
|
11
|
+
if (!response) return response;
|
|
12
|
+
return adapter(response);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
package/es/core/utils/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getUrlConfig } from "../../../config/urls";
|
|
2
2
|
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
3
4
|
import { BotAdapter } from "../../../infrastructure/adapters";
|
|
4
5
|
import { BotAPI } from "../../../infrastructure/api";
|
|
5
6
|
import { IBot } from "../../interfaces";
|
|
@@ -18,8 +19,8 @@ export default class BotService extends IBot {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async getBots(request) {
|
|
21
|
-
const
|
|
22
|
-
return
|
|
22
|
+
const response = await this.botAPI.getBots(request);
|
|
23
|
+
return ResponseUtils.adaptListResponse(response, this.botAdapter.adapt);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
toJSON() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getUrlConfig } from "../../../config/urls";
|
|
2
2
|
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
3
4
|
import { ChannelAgentAdapter } from "../../../infrastructure/adapters";
|
|
4
5
|
import { ChannelAgentAPI } from "../../../infrastructure/api";
|
|
5
6
|
import { IChannelAgent } from "../../interfaces";
|
|
@@ -18,8 +19,8 @@ export default class ChannelAgentService extends IChannelAgent {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async getAgents(request) {
|
|
21
|
-
const
|
|
22
|
-
return
|
|
22
|
+
const response = await this.channelAgentAPI.getAgents(request);
|
|
23
|
+
return ResponseUtils.adaptListResponse(response, this.channelAgentAdapter.adapt);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
toJSON() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getUrlConfig } from "../../../config/urls";
|
|
2
2
|
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
3
4
|
import { ChannelAdapter } from "../../../infrastructure/adapters";
|
|
4
5
|
import { ChannelAPI } from "../../../infrastructure/api";
|
|
5
6
|
import { IChannel } from "../../interfaces";
|
|
@@ -18,8 +19,8 @@ export default class ChannelService extends IChannel {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async getChannels(request) {
|
|
21
|
-
const
|
|
22
|
-
return
|
|
22
|
+
const response = await this.channelAPI.getChannels(request);
|
|
23
|
+
return ResponseUtils.adaptListResponse(response, this.channelAdapter.adapt);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
toJSON() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getUrlConfig } from "../../../config/urls";
|
|
2
2
|
import { ModuleNames } from "../../../core/constants";
|
|
3
|
+
import { ResponseUtils } from "../../../core/utils";
|
|
3
4
|
import { SessionAdapter } from "../../../infrastructure/adapters";
|
|
4
5
|
import { SessionAPI } from "../../../infrastructure/api";
|
|
5
6
|
import { ISession } from "../../interfaces";
|
|
@@ -18,8 +19,8 @@ export default class SessionService extends ISession {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async updateAssignee(request) {
|
|
21
|
-
const
|
|
22
|
-
return this.sessionAdapter.adapt
|
|
22
|
+
const response = await this.sessionAPI.updateAssignee(request);
|
|
23
|
+
return ResponseUtils.adaptSingleResponse(response, this.sessionAdapter.adapt);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
toJSON() {
|