@zohoim/client-sdk 1.0.0-poc34 → 1.0.0-poc36

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.
@@ -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
+ }
@@ -1,2 +1,3 @@
1
+ import ResponseUtils from "./ResponseUtils";
1
2
  import { validateSchema } from "./validateSchema";
2
- export { validateSchema };
3
+ export { validateSchema, ResponseUtils };
@@ -10,7 +10,7 @@ export default class Bot {
10
10
  name: validatedData.name,
11
11
  isActive: validatedData.isActive,
12
12
  createdTime: validatedData.createdTime,
13
- logoURL: validatedData.logoURL,
13
+ photoURL: validatedData.photoURL,
14
14
  createdBy: validatedData.createdBy
15
15
  };
16
16
  }
@@ -16,7 +16,7 @@ export default class Channel {
16
16
  this.isSubscribed = validatedData.isSubscribed || false;
17
17
  this.createdBy = validatedData.createdBy || null;
18
18
  this.isOwner = validatedData.isOwner || false;
19
- this.logoURL = validatedData.logoURL || null;
19
+ this.photoURL = validatedData.photoURL || null;
20
20
  }
21
21
 
22
22
  toJSON() {
@@ -31,7 +31,7 @@ export default class Channel {
31
31
  isSubscribed: this.isSubscribed,
32
32
  createdBy: this.createdBy,
33
33
  isOwner: this.isOwner,
34
- logoURL: this.logoURL
34
+ photoURL: this.photoURL
35
35
  };
36
36
  }
37
37
 
@@ -1,5 +1,7 @@
1
1
  const BotServiceType = {
2
2
  DESK_GC_BOT: 'DESK_GC_BOT',
3
- DESK_ZIA_BOT: 'DESK_ZIA_BOT'
3
+ DESK_ZIA_BOT: 'DESK_ZIA_BOT',
4
+ ZOHO_GC_BOT: 'ZOHO_GC_BOT',
5
+ ZOHO_ZIA_BOT: 'ZOHO_ZIA_BOT'
4
6
  };
5
7
  export default BotServiceType;
@@ -1,3 +1,5 @@
1
+ import IAdapter from "./IAdapter";
1
2
  export * from "./channels";
2
3
  export * from "./sessions";
3
- export * from "./bots";
4
+ export * from "./bots";
5
+ export { IAdapter };
@@ -7,7 +7,7 @@ const BotSchema = {
7
7
  botServiceType: {
8
8
  type: 'string',
9
9
  required: true,
10
- enum: [BotServiceType.DESK_GC_BOT, BotServiceType.DESK_ZIA_BOT]
10
+ enum: [BotServiceType.DESK_GC_BOT, BotServiceType.DESK_ZIA_BOT, BotServiceType.ZOHO_GC_BOT, BotServiceType.ZOHO_ZIA_BOT]
11
11
  },
12
12
  name: {
13
13
  type: 'string',
@@ -21,7 +21,7 @@ const BotSchema = {
21
21
  type: 'string',
22
22
  required: true
23
23
  },
24
- logoURL: {
24
+ photoURL: {
25
25
  type: 'string',
26
26
  required: true
27
27
  },
@@ -41,7 +41,7 @@ const ChannelSchema = {
41
41
  type: 'boolean',
42
42
  required: false
43
43
  },
44
- logoURL: {
44
+ photoURL: {
45
45
  type: 'string',
46
46
  required: false
47
47
  }
@@ -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 bots = await this.botAPI.getBots(request);
22
- return bots.data.map(this.botAdapter.adapt);
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 channelAgents = await this.channelAgentAPI.getAgents(request);
22
- return channelAgents.data.map(this.channelAgentAdapter.adapt);
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 channels = await this.channelAPI.getChannels(request);
22
- return channels.data.map(channel => this.channelAdapter.adapt(channel));
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 session = await this.sessionAPI.updateAssignee(request);
22
- return this.sessionAdapter.adapt(session);
22
+ const response = await this.sessionAPI.updateAssignee(request);
23
+ return ResponseUtils.adaptSingleResponse(response, this.sessionAdapter.adapt);
23
24
  }
24
25
 
25
26
  toJSON() {
@@ -14,7 +14,7 @@ export default class BotAdapter extends IAdapter {
14
14
  name: botData.name,
15
15
  isActive: botData.isActive,
16
16
  createdTime: botData.createdTime,
17
- logoURL: botData.logoURL,
17
+ photoURL: botData.logoURL,
18
18
  createdBy: botData.createdBy
19
19
  }).toJSON();
20
20
  } catch (error) {
@@ -19,7 +19,7 @@ export default class ChannelAdapter extends IAdapter {
19
19
  isSubscribed: rawChannel.isSubscribed,
20
20
  createdBy: rawChannel.createdBy,
21
21
  isOwner: rawChannel.isOwner,
22
- logoURL: rawChannel.logoURL
22
+ photoURL: rawChannel.logoURL
23
23
  }).toJSON();
24
24
  } catch (error) {
25
25
  throw new AdapterError(`Failed to adapt channel: ${error.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc34",
3
+ "version": "1.0.0-poc36",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",