@zohoim/client-sdk 1.0.0-poc21 → 1.0.0-poc23

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.
Files changed (92) hide show
  1. package/es/config/urls/base/index.js +7 -0
  2. package/es/config/urls/bots/bots-api-url.js +5 -8
  3. package/es/config/urls/bots/index.js +1 -1
  4. package/es/config/urls/channels/channel-agents-api-url.js +5 -8
  5. package/es/config/urls/channels/index.js +1 -1
  6. package/es/config/urls/index.js +16 -0
  7. package/es/config/urls/sessions/index.js +1 -1
  8. package/es/config/urls/sessions/sessions-api-url.js +5 -8
  9. package/es/core/constants/index.js +2 -2
  10. package/es/core/errors/index.js +2 -2
  11. package/es/core/utils/index.js +1 -1
  12. package/es/core/utils/validateSchema.js +1 -1
  13. package/es/domain/entities/Actor/Actor.js +2 -2
  14. package/es/domain/entities/Actor/index.js +1 -1
  15. package/es/domain/entities/Agent/Agent.js +2 -2
  16. package/es/domain/entities/Agent/index.js +1 -1
  17. package/es/domain/entities/Bot/Bot.js +2 -2
  18. package/es/domain/entities/Bot/index.js +1 -1
  19. package/es/domain/entities/Session/Session.js +3 -3
  20. package/es/domain/entities/Session/index.js +1 -1
  21. package/es/domain/entities/index.js +4 -4
  22. package/es/domain/enum/actor/index.js +1 -1
  23. package/es/domain/enum/bot/index.js +1 -1
  24. package/es/domain/enum/index.js +4 -4
  25. package/es/domain/enum/integrationServices/index.js +1 -1
  26. package/es/domain/enum/session/index.js +2 -2
  27. package/es/domain/interfaces/BaseAPI.js +3 -2
  28. package/es/domain/interfaces/bots/IBot.js +3 -3
  29. package/es/domain/interfaces/bots/index.js +1 -1
  30. package/es/domain/interfaces/channels/IChannelAgent.js +3 -3
  31. package/es/domain/interfaces/channels/index.js +1 -1
  32. package/es/domain/interfaces/index.js +3 -3
  33. package/es/domain/interfaces/sessions/ISession.js +3 -3
  34. package/es/domain/interfaces/sessions/index.js +1 -1
  35. package/es/domain/schema/actor/ActorSchema.js +1 -1
  36. package/es/domain/schema/actor/AgentSchema.js +1 -1
  37. package/es/domain/schema/actor/index.js +2 -2
  38. package/es/domain/schema/bot/BotSchema.js +1 -1
  39. package/es/domain/schema/bot/index.js +1 -1
  40. package/es/domain/schema/index.js +3 -3
  41. package/es/domain/schema/session/SessionSchema.js +2 -2
  42. package/es/domain/schema/session/index.js +1 -1
  43. package/es/domain/services/bots/BotService.js +9 -7
  44. package/es/domain/services/bots/index.js +1 -1
  45. package/es/domain/services/channels/ChannelAgentService.js +9 -7
  46. package/es/domain/services/channels/index.js +1 -1
  47. package/es/domain/services/index.js +3 -3
  48. package/es/domain/services/sessions/SessionService.js +9 -7
  49. package/es/domain/services/sessions/index.js +1 -1
  50. package/es/index.js +8 -8
  51. package/es/infrastructure/adapters/BaseAdapter.js +1 -1
  52. package/es/infrastructure/adapters/bots/BotAdapter.js +3 -3
  53. package/es/infrastructure/adapters/bots/index.js +1 -1
  54. package/es/infrastructure/adapters/channels/ChannelAgentAdapter.js +3 -3
  55. package/es/infrastructure/adapters/channels/index.js +1 -1
  56. package/es/infrastructure/adapters/index.js +3 -3
  57. package/es/infrastructure/adapters/sessions/SessionAdapter.js +3 -3
  58. package/es/infrastructure/adapters/sessions/index.js +1 -1
  59. package/es/infrastructure/api/bots/BotAPI.js +3 -3
  60. package/es/infrastructure/api/bots/index.js +1 -1
  61. package/es/infrastructure/api/channels/ChannelAgentAPI.js +3 -3
  62. package/es/infrastructure/api/channels/index.js +1 -1
  63. package/es/infrastructure/api/index.js +3 -3
  64. package/es/infrastructure/api/sessions/SessionAPI.js +3 -3
  65. package/es/infrastructure/api/sessions/index.js +1 -1
  66. package/es/infrastructure/interfaces/api/base/RequestBuilder.js +42 -0
  67. package/es/infrastructure/interfaces/api/base/index.js +2 -0
  68. package/es/infrastructure/interfaces/api/bots/getBotsRequest.js +14 -0
  69. package/es/infrastructure/interfaces/api/bots/index.js +2 -2
  70. package/es/infrastructure/interfaces/api/channels/agents/getChannelAgentsRequest.js +13 -0
  71. package/es/infrastructure/interfaces/api/channels/agents/index.js +2 -2
  72. package/es/infrastructure/interfaces/api/channels/index.js +1 -1
  73. package/es/infrastructure/interfaces/api/index.js +3 -3
  74. package/es/infrastructure/interfaces/api/sessions/index.js +2 -2
  75. package/es/infrastructure/interfaces/api/sessions/updateSessionAssigneeRequest.js +12 -0
  76. package/es/infrastructure/interfaces/index.js +1 -1
  77. package/es/infrastructure/managers/ModuleFactory.js +4 -4
  78. package/es/infrastructure/managers/ModuleManager.js +2 -2
  79. package/es/infrastructure/managers/index.js +1 -1
  80. package/es/infrastructure/sdk/IMSDK.js +4 -4
  81. package/es/infrastructure/sdk/bots/BotSDK.js +1 -1
  82. package/es/infrastructure/sdk/bots/index.js +1 -1
  83. package/es/infrastructure/sdk/channels/ChannelSDK.js +1 -1
  84. package/es/infrastructure/sdk/channels/index.js +1 -1
  85. package/es/infrastructure/sdk/config/index.js +1 -1
  86. package/es/infrastructure/sdk/index.js +1 -1
  87. package/es/infrastructure/sdk/sessions/SessionSDK.js +1 -1
  88. package/es/infrastructure/sdk/sessions/index.js +1 -1
  89. package/package.json +1 -1
  90. package/es/infrastructure/interfaces/api/bots/GetBotsRequest.js +0 -14
  91. package/es/infrastructure/interfaces/api/channels/agents/GetChannelAgentsRequest.js +0 -13
  92. package/es/infrastructure/interfaces/api/sessions/UpdateSessionAssigneeRequest.js +0 -12
@@ -0,0 +1,7 @@
1
+ import { IM_API_PREFIX } from "../../../core/constants";
2
+ export const createBaseUrl = path => `${IM_API_PREFIX}${path}`;
3
+ export const createEndpoint = (url, method, requestInterface) => ({
4
+ url,
5
+ method,
6
+ ...requestInterface
7
+ });
@@ -1,11 +1,8 @@
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`;
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');
4
5
  const BOTS_API_URLS = {
5
- LIST: {
6
- url: BASE_URL,
7
- method: HTTP_METHODS.GET,
8
- ...GetBotsRequest
9
- }
6
+ LIST: createEndpoint(BASE_URL, HTTP_METHODS.GET, getBotsRequest())
10
7
  };
11
8
  export default BOTS_API_URLS;
@@ -1,2 +1,2 @@
1
- import BOTS_API_URLS from './bots-api-url';
1
+ import BOTS_API_URLS from "./bots-api-url";
2
2
  export { BOTS_API_URLS };
@@ -1,11 +1,8 @@
1
- import { HTTP_METHODS, IM_API_PREFIX } from '../../../core/constants';
2
- import { GetChannelAgentsRequest } from '../../../infrastructure/interfaces/api';
3
- const BASE_URL = `${IM_API_PREFIX}/channels/:channelId/agents`;
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');
4
5
  const CHANNEL_AGENTS_API_URLS = {
5
- LIST: {
6
- url: BASE_URL,
7
- method: HTTP_METHODS.GET,
8
- ...GetChannelAgentsRequest
9
- }
6
+ LIST: createEndpoint(BASE_URL, HTTP_METHODS.GET, getChannelAgentsRequest())
10
7
  };
11
8
  export default CHANNEL_AGENTS_API_URLS;
@@ -1,2 +1,2 @@
1
- import CHANNEL_AGENTS_API_URLS from './channel-agents-api-url';
1
+ import CHANNEL_AGENTS_API_URLS from "./channel-agents-api-url";
2
2
  export { 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
+ }
@@ -1,2 +1,2 @@
1
- import SESSIONS_API_URLS from './sessions-api-url';
1
+ import SESSIONS_API_URLS from "./sessions-api-url";
2
2
  export { SESSIONS_API_URLS };
@@ -1,12 +1,9 @@
1
- import { UpdateSessionAssigneeRequest } from '../../../infrastructure/interfaces/api';
2
- import { HTTP_METHODS, IM_API_PREFIX } from '../../../core/constants';
3
- const BASE_URL = `${IM_API_PREFIX}/sessions`;
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');
4
5
  const SINGLE_SESSION_URL = `${BASE_URL}/:sessionId`;
5
6
  const SESSIONS_API_URLS = {
6
- UPDATE_SESSION_ASSIGNEE: {
7
- url: SINGLE_SESSION_URL,
8
- method: HTTP_METHODS.PATCH,
9
- ...UpdateSessionAssigneeRequest
10
- }
7
+ UPDATE_SESSION_ASSIGNEE: createEndpoint(SINGLE_SESSION_URL, HTTP_METHODS.PATCH, updateSessionAssigneeRequest())
11
8
  };
12
9
  export default SESSIONS_API_URLS;
@@ -1,4 +1,4 @@
1
- import HTTP_METHODS from './HttpMethods';
2
- import ModuleNames from './ModuleNames';
1
+ import HTTP_METHODS from "./HttpMethods";
2
+ import ModuleNames from "./ModuleNames";
3
3
  const IM_API_PREFIX = '/api/v1';
4
4
  export { ModuleNames, IM_API_PREFIX, HTTP_METHODS };
@@ -1,3 +1,3 @@
1
- import AdapterError from './AdapterError';
2
- import ValidationError from './ValidationError';
1
+ import AdapterError from "./AdapterError";
2
+ import ValidationError from "./ValidationError";
3
3
  export { ValidationError, AdapterError };
@@ -1,2 +1,2 @@
1
- import { validateSchema } from './validateSchema';
1
+ import { validateSchema } from "./validateSchema";
2
2
  export { validateSchema };
@@ -1,4 +1,4 @@
1
- import { ValidationError } from '../errors';
1
+ import { ValidationError } from "../errors";
2
2
 
3
3
  function validateSchemaKeys(schema, data) {
4
4
  Object.keys(schema).forEach(key => {
@@ -1,5 +1,5 @@
1
- import { validateSchema } from '../../../core/utils';
2
- import { ActorSchema } from '../../schema';
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { ActorSchema } from "../../schema";
3
3
  export default class Actor {
4
4
  constructor() {
5
5
  let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1,2 +1,2 @@
1
- import Actor from './Actor';
1
+ import Actor from "./Actor";
2
2
  export { Actor };
@@ -1,5 +1,5 @@
1
- import { validateSchema } from '../../../core/utils';
2
- import { AgentSchema } from '../../schema';
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { AgentSchema } from "../../schema";
3
3
  export default class Agent {
4
4
  constructor() {
5
5
  let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1,2 +1,2 @@
1
- import Agent from './Agent';
1
+ import Agent from "./Agent";
2
2
  export { Agent };
@@ -1,5 +1,5 @@
1
- import { validateSchema } from '../../../core/utils';
2
- import { BotSchema } from '../../schema';
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { BotSchema } from "../../schema";
3
3
  export default class Bot {
4
4
  constructor() {
5
5
  let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1,2 +1,2 @@
1
- import Bot from './Bot';
1
+ import Bot from "./Bot";
2
2
  export { Bot };
@@ -1,6 +1,6 @@
1
- import { validateSchema } from '../../../core/utils';
2
- import { SessionSchema } from '../../schema';
3
- import { Actor } from '../Actor';
1
+ import { validateSchema } from "../../../core/utils";
2
+ import { SessionSchema } from "../../schema";
3
+ import { Actor } from "../Actor";
4
4
  export default class Session {
5
5
  constructor() {
6
6
  let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1,2 +1,2 @@
1
- import Session from './Session';
1
+ import Session from "./Session";
2
2
  export { Session };
@@ -1,4 +1,4 @@
1
- export * from './Actor';
2
- export * from './Agent';
3
- export * from './Session';
4
- export * from './Bot';
1
+ export * from "./Actor";
2
+ export * from "./Agent";
3
+ export * from "./Session";
4
+ export * from "./Bot";
@@ -1,2 +1,2 @@
1
- import ActorType from './ActorType';
1
+ import ActorType from "./ActorType";
2
2
  export { ActorType };
@@ -1,2 +1,2 @@
1
- import BotServiceType from './BotServiceType';
1
+ import BotServiceType from "./BotServiceType";
2
2
  export { BotServiceType };
@@ -1,4 +1,4 @@
1
- export * from './integrationServices';
2
- export * from './session';
3
- export * from './actor';
4
- export * from './bot';
1
+ export * from "./integrationServices";
2
+ export * from "./session";
3
+ export * from "./actor";
4
+ export * from "./bot";
@@ -1,2 +1,2 @@
1
- import IntegrationServices from './IntegrationServices';
1
+ import IntegrationServices from "./IntegrationServices";
2
2
  export { IntegrationServices };
@@ -1,3 +1,3 @@
1
- import SessionReplyStatus from './SessionReplyStatus';
2
- import SessionStatus from './SessionStatus';
1
+ import SessionReplyStatus from "./SessionReplyStatus";
2
+ import SessionStatus from "./SessionStatus";
3
3
  export { SessionStatus, SessionReplyStatus };
@@ -1,4 +1,4 @@
1
- import { configRegistry } from '../../infrastructure/sdk/config';
1
+ import { configRegistry } from "../../infrastructure/sdk/config";
2
2
  export default class BaseAPI {
3
3
  constructor() {
4
4
  this.httpClient = configRegistry.getHttpClient();
@@ -55,7 +55,8 @@ export default class BaseAPI {
55
55
  const httpRequest = await this.httpClient.request({
56
56
  url,
57
57
  method: urlConfig.method,
58
- header: urlConfig.header
58
+ header: urlConfig.header,
59
+ payload: request.body || {}
59
60
  });
60
61
  return httpRequest;
61
62
  }
@@ -1,9 +1,9 @@
1
- import { GetBotsRequest } from '../../../infrastructure/interfaces/api';
2
- import BaseAPI from '../BaseAPI';
1
+ import { getBotsRequest } from "../../../infrastructure/interfaces/api";
2
+ import BaseAPI from "../BaseAPI";
3
3
  export default class IBot extends BaseAPI {
4
4
  // eslint-disable-next-line no-unused-vars
5
5
  async getBots() {
6
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
6
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
7
7
  throw new Error('Method not implemented');
8
8
  }
9
9
 
@@ -1,2 +1,2 @@
1
- import IBot from './IBot';
1
+ import IBot from "./IBot";
2
2
  export { IBot };
@@ -1,9 +1,9 @@
1
- import { GetChannelAgentsRequest } from '../../../infrastructure/interfaces/api';
2
- import BaseAPI from '../BaseAPI';
1
+ import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
2
+ import BaseAPI from "../BaseAPI";
3
3
  export default class IChannelAgent extends BaseAPI {
4
4
  // eslint-disable-next-line no-unused-vars
5
5
  getAgents() {
6
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetChannelAgentsRequest;
6
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
7
7
  throw new Error('Method not implemented.');
8
8
  }
9
9
 
@@ -1,2 +1,2 @@
1
- import IChannelAgent from './IChannelAgent';
1
+ import IChannelAgent from "./IChannelAgent";
2
2
  export { IChannelAgent };
@@ -1,3 +1,3 @@
1
- export * from './channels';
2
- export * from './sessions';
3
- export * from './bots';
1
+ export * from "./channels";
2
+ export * from "./sessions";
3
+ export * from "./bots";
@@ -1,9 +1,9 @@
1
- import { UpdateSessionAssigneeRequest } from '../../../infrastructure/interfaces/api';
2
- import BaseAPI from '../BaseAPI';
1
+ import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
2
+ import BaseAPI from "../BaseAPI";
3
3
  export default class ISession extends BaseAPI {
4
4
  // eslint-disable-next-line no-unused-vars
5
5
  updateAssignee() {
6
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
6
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
7
7
  throw new Error('Method not implemented.');
8
8
  }
9
9
 
@@ -1,2 +1,2 @@
1
- import ISession from './ISession';
1
+ import ISession from "./ISession";
2
2
  export { ISession };
@@ -1,4 +1,4 @@
1
- import { ActorType } from '../../enum';
1
+ import { ActorType } from "../../enum";
2
2
  const ActorSchema = {
3
3
  name: {
4
4
  type: 'string',
@@ -1,4 +1,4 @@
1
- import { ActorType } from '../../enum';
1
+ import { ActorType } from "../../enum";
2
2
  const AgentSchema = {
3
3
  id: {
4
4
  type: 'string',
@@ -1,3 +1,3 @@
1
- import ActorSchema from './ActorSchema';
2
- import AgentSchema from './AgentSchema';
1
+ import ActorSchema from "./ActorSchema";
2
+ import AgentSchema from "./AgentSchema";
3
3
  export { ActorSchema, AgentSchema };
@@ -1,4 +1,4 @@
1
- import { BotServiceType } from '../../enum';
1
+ import { BotServiceType } from "../../enum";
2
2
  const BotSchema = {
3
3
  id: {
4
4
  type: 'string',
@@ -1,2 +1,2 @@
1
- import BotSchema from './BotSchema';
1
+ import BotSchema from "./BotSchema";
2
2
  export { BotSchema };
@@ -1,3 +1,3 @@
1
- export * from './actor';
2
- export * from './session';
3
- export * from './bot';
1
+ export * from "./actor";
2
+ export * from "./session";
3
+ export * from "./bot";
@@ -1,5 +1,5 @@
1
- import { IntegrationServices, SessionReplyStatus, SessionStatus } from '../../enum';
2
- import { ActorSchema } from '../actor';
1
+ import { IntegrationServices, SessionReplyStatus, SessionStatus } from "../../enum";
2
+ import { ActorSchema } from "../actor";
3
3
  const SessionSchema = {
4
4
  channelId: {
5
5
  type: 'string',
@@ -1,2 +1,2 @@
1
- import SessionSchema from './SessionSchema';
1
+ import SessionSchema from "./SessionSchema";
2
2
  export { SessionSchema };
@@ -1,8 +1,9 @@
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';
1
+ import { getUrlConfig } from "../../../config/urls";
2
+ import { ModuleNames } from "../../../core/constants";
3
+ import { BotAdapter } from "../../../infrastructure/adapters";
4
+ import { BotAPI } from "../../../infrastructure/api";
5
+ import { getBotsRequest } from "../../../infrastructure/interfaces/api";
6
+ import { IBot } from "../../interfaces";
6
7
  export default class BotService extends IBot {
7
8
  constructor(_ref) {
8
9
  let {
@@ -10,14 +11,15 @@ export default class BotService extends IBot {
10
11
  botAdapter
11
12
  } = _ref;
12
13
  super();
14
+ const urlConfig = getUrlConfig(ModuleNames.BOTS);
13
15
  this.botAPI = botAPI || new BotAPI({
14
- urlConfig: BOTS_API_URLS
16
+ urlConfig
15
17
  });
16
18
  this.botAdapter = botAdapter || new BotAdapter();
17
19
  }
18
20
 
19
21
  async getBots() {
20
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
22
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
21
23
  const bots = await this.botAPI.getBots(request);
22
24
  return bots.map(this.botAdapter.adapt);
23
25
  }
@@ -1,2 +1,2 @@
1
- import BotService from './BotService';
1
+ import BotService from "./BotService";
2
2
  export { BotService };
@@ -1,8 +1,9 @@
1
- import { CHANNEL_AGENTS_API_URLS } from '../../../config/urls/channels';
2
- import { ChannelAgentAdapter } from '../../../infrastructure/adapters';
3
- import { ChannelAgentAPI } from '../../../infrastructure/api';
4
- import { GetChannelAgentsRequest } from '../../../infrastructure/interfaces/api';
5
- import { IChannelAgent } from '../../interfaces';
1
+ import { getUrlConfig } from "../../../config/urls";
2
+ import { ModuleNames } from "../../../core/constants";
3
+ import { ChannelAgentAdapter } from "../../../infrastructure/adapters";
4
+ import { ChannelAgentAPI } from "../../../infrastructure/api";
5
+ import { getChannelAgentsRequest } from "../../../infrastructure/interfaces/api";
6
+ import { IChannelAgent } from "../../interfaces";
6
7
  export default class ChannelAgentService extends IChannelAgent {
7
8
  constructor(_ref) {
8
9
  let {
@@ -10,14 +11,15 @@ export default class ChannelAgentService extends IChannelAgent {
10
11
  channelAgentAdapter
11
12
  } = _ref;
12
13
  super();
14
+ const urlConfig = getUrlConfig(`${ModuleNames.CHANNELS}.agents`);
13
15
  this.channelAgentAPI = channelAgentAPI || new ChannelAgentAPI({
14
- urlConfig: CHANNEL_AGENTS_API_URLS
16
+ urlConfig
15
17
  });
16
18
  this.channelAgentAdapter = channelAgentAdapter || new ChannelAgentAdapter();
17
19
  }
18
20
 
19
21
  async getAgents() {
20
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetChannelAgentsRequest;
22
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
21
23
  const channelAgents = await this.channelAgentAPI.getAgents(request);
22
24
  return channelAgents.map(this.channelAgentAdapter.adapt);
23
25
  }
@@ -1,2 +1,2 @@
1
- import ChannelAgentService from './ChannelAgentService';
1
+ import ChannelAgentService from "./ChannelAgentService";
2
2
  export { ChannelAgentService };
@@ -1,3 +1,3 @@
1
- export * from './channels';
2
- export * from './sessions';
3
- export * from './bots';
1
+ export * from "./channels";
2
+ export * from "./sessions";
3
+ export * from "./bots";
@@ -1,8 +1,9 @@
1
- import { SESSIONS_API_URLS } from '../../../config/urls/sessions';
2
- import { SessionAdapter } from '../../../infrastructure/adapters';
3
- import { SessionAPI } from '../../../infrastructure/api';
4
- import { UpdateSessionAssigneeRequest } from '../../../infrastructure/interfaces/api';
5
- import { ISession } from '../../interfaces';
1
+ import { getUrlConfig } from "../../../config/urls";
2
+ import { ModuleNames } from "../../../core/constants";
3
+ import { SessionAdapter } from "../../../infrastructure/adapters";
4
+ import { SessionAPI } from "../../../infrastructure/api";
5
+ import { updateSessionAssigneeRequest } from "../../../infrastructure/interfaces/api";
6
+ import { ISession } from "../../interfaces";
6
7
  export default class SessionService extends ISession {
7
8
  constructor(_ref) {
8
9
  let {
@@ -10,14 +11,15 @@ export default class SessionService extends ISession {
10
11
  sessionAdapter
11
12
  } = _ref;
12
13
  super();
14
+ const urlConfig = getUrlConfig(ModuleNames.SESSIONS);
13
15
  this.sessionAPI = sessionAPI || new SessionAPI({
14
- urlConfig: SESSIONS_API_URLS
16
+ urlConfig
15
17
  });
16
18
  this.sessionAdapter = sessionAdapter || new SessionAdapter();
17
19
  }
18
20
 
19
21
  async updateAssignee() {
20
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
22
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
21
23
  const session = await this.sessionAPI.updateAssignee(request);
22
24
  return this.sessionAdapter.adapt(session);
23
25
  }
@@ -1,2 +1,2 @@
1
- import SessionService from './SessionService';
1
+ import SessionService from "./SessionService";
2
2
  export { SessionService };
package/es/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export * from './domain/entities';
2
- export * from './domain/enum';
3
- export * from './domain/interfaces';
4
- export * from './domain/services';
5
- export * from './infrastructure/sdk';
6
- export * from './infrastructure/adapters';
7
- export * from './infrastructure/api';
8
- export * from './infrastructure/interfaces/api';
1
+ export * from "./domain/entities";
2
+ export * from "./domain/enum";
3
+ export * from "./domain/interfaces";
4
+ export * from "./domain/services";
5
+ export * from "./infrastructure/sdk";
6
+ export * from "./infrastructure/adapters";
7
+ export * from "./infrastructure/api";
8
+ export * from "./infrastructure/interfaces/api";
@@ -1,4 +1,4 @@
1
- import { AdapterError } from '../../core/errors';
1
+ import { AdapterError } from "../../core/errors";
2
2
  /**
3
3
  * Base adapter class that defines the contract for all adapters
4
4
  * @abstract
@@ -1,6 +1,6 @@
1
- import { AdapterError } from '../../../core/errors';
2
- import { Bot } from '../../../domain/entities';
3
- import BaseAdapter from '../BaseAdapter';
1
+ import { AdapterError } from "../../../core/errors";
2
+ import { Bot } from "../../../domain/entities";
3
+ import BaseAdapter from "../BaseAdapter";
4
4
  export default class BotAdapter extends BaseAdapter {
5
5
  static adapt(botData) {
6
6
  if (!botData) {
@@ -1,2 +1,2 @@
1
- import BotAdapter from './BotAdapter';
1
+ import BotAdapter from "./BotAdapter";
2
2
  export { BotAdapter };
@@ -1,6 +1,6 @@
1
- import BaseAdapter from '../BaseAdapter';
2
- import { AdapterError } from '../../../core/errors';
3
- import { Agent } from '../../../domain/entities';
1
+ import BaseAdapter from "../BaseAdapter";
2
+ import { AdapterError } from "../../../core/errors";
3
+ import { Agent } from "../../../domain/entities";
4
4
  /**
5
5
  * Adapter for Channel Agent data
6
6
  * @extends BaseAdapter
@@ -1,2 +1,2 @@
1
- import ChannelAgentAdapter from './ChannelAgentAdapter';
1
+ import ChannelAgentAdapter from "./ChannelAgentAdapter";
2
2
  export { ChannelAgentAdapter };
@@ -1,3 +1,3 @@
1
- export * from './channels';
2
- export * from './sessions';
3
- export * from './bots';
1
+ export * from "./channels";
2
+ export * from "./sessions";
3
+ export * from "./bots";
@@ -1,6 +1,6 @@
1
- import BaseAdapter from '../BaseAdapter';
2
- import { AdapterError } from '../../../core/errors';
3
- import { Session } from '../../../domain/entities';
1
+ import BaseAdapter from "../BaseAdapter";
2
+ import { AdapterError } from "../../../core/errors";
3
+ import { Session } from "../../../domain/entities";
4
4
  export default class SessionAdapter extends BaseAdapter {
5
5
  static adapt(sessionData) {
6
6
  if (!sessionData) {
@@ -1,2 +1,2 @@
1
- import SessionAdapter from './SessionAdapter';
1
+ import SessionAdapter from "./SessionAdapter";
2
2
  export { SessionAdapter };
@@ -1,5 +1,5 @@
1
- import { IBot } from '../../../domain/interfaces';
2
- import { GetBotsRequest } from '../../interfaces/api';
1
+ import { IBot } from "../../../domain/interfaces";
2
+ import { getBotsRequest } from "../../interfaces/api";
3
3
  export default class BotAPI extends IBot {
4
4
  constructor(_ref) {
5
5
  let {
@@ -10,7 +10,7 @@ export default class BotAPI extends IBot {
10
10
  }
11
11
 
12
12
  async getBots() {
13
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetBotsRequest;
13
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBotsRequest();
14
14
  const urlConfig = this.urlConfig.LIST;
15
15
  const httpRequest = await this.request({
16
16
  urlConfig,
@@ -1,2 +1,2 @@
1
- import BotAPI from './BotAPI';
1
+ import BotAPI from "./BotAPI";
2
2
  export { BotAPI };
@@ -1,5 +1,5 @@
1
- import IChannelAgent from '../../../domain/interfaces/channels/IChannelAgent';
2
- import { GetChannelAgentsRequest } from '../../interfaces/api';
1
+ import IChannelAgent from "../../../domain/interfaces/channels/IChannelAgent";
2
+ import { getChannelAgentsRequest } from "../../interfaces/api";
3
3
  export default class ChannelAgentAPI extends IChannelAgent {
4
4
  constructor(_ref) {
5
5
  let {
@@ -10,7 +10,7 @@ export default class ChannelAgentAPI extends IChannelAgent {
10
10
  }
11
11
 
12
12
  async getAgents() {
13
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : GetChannelAgentsRequest;
13
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getChannelAgentsRequest();
14
14
  const urlConfig = this.urlConfig.LIST;
15
15
  const httpRequest = await this.request({
16
16
  urlConfig,
@@ -1,2 +1,2 @@
1
- import ChannelAgentAPI from './ChannelAgentAPI';
1
+ import ChannelAgentAPI from "./ChannelAgentAPI";
2
2
  export { ChannelAgentAPI };
@@ -1,3 +1,3 @@
1
- export * from './channels';
2
- export * from './sessions';
3
- export * from './bots';
1
+ export * from "./channels";
2
+ export * from "./sessions";
3
+ export * from "./bots";
@@ -1,5 +1,5 @@
1
- import { ISession } from '../../../domain/interfaces';
2
- import { UpdateSessionAssigneeRequest } from '../../interfaces/api';
1
+ import { ISession } from "../../../domain/interfaces";
2
+ import { updateSessionAssigneeRequest } from "../../interfaces/api";
3
3
  export default class SessionAPI extends ISession {
4
4
  constructor(_ref) {
5
5
  let {
@@ -10,7 +10,7 @@ export default class SessionAPI extends ISession {
10
10
  }
11
11
 
12
12
  async updateAssignee() {
13
- let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UpdateSessionAssigneeRequest;
13
+ let request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : updateSessionAssigneeRequest();
14
14
  const urlConfig = this.urlConfig.UPDATE_SESSION_ASSIGNEE;
15
15
  const httpRequest = await this.request({
16
16
  urlConfig,
@@ -1,2 +1,2 @@
1
- import SessionAPI from './SessionAPI';
1
+ import SessionAPI from "./SessionAPI";
2
2
  export { SessionAPI };
@@ -0,0 +1,42 @@
1
+ class RequestBuilder {
2
+ constructor() {
3
+ this._params = {};
4
+ this._query = {};
5
+ this._body = {};
6
+ }
7
+
8
+ withParams() {
9
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
+ this._params = { ...this._params,
11
+ ...params
12
+ };
13
+ return this;
14
+ }
15
+
16
+ withQuery() {
17
+ let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
+ this._query = { ...this._query,
19
+ ...query
20
+ };
21
+ return this;
22
+ }
23
+
24
+ withBody() {
25
+ let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ this._body = { ...this._body,
27
+ ...body
28
+ };
29
+ return this;
30
+ }
31
+
32
+ build() {
33
+ return {
34
+ params: this._params,
35
+ query: this._query,
36
+ body: Object.keys(this._body).length ? this._body : undefined
37
+ };
38
+ }
39
+
40
+ }
41
+
42
+ export default RequestBuilder;
@@ -0,0 +1,2 @@
1
+ import RequestBuilder from "./RequestBuilder";
2
+ export { RequestBuilder };
@@ -0,0 +1,14 @@
1
+ import { RequestBuilder } from "../base";
2
+
3
+ function getBotsRequest() {
4
+ return new RequestBuilder().withQuery({
5
+ from: 0,
6
+ limit: 10,
7
+ modifiedAfter: null,
8
+ botServiceId: null,
9
+ externalAccountId: null,
10
+ searchStr: null
11
+ }).build();
12
+ }
13
+
14
+ export default getBotsRequest;
@@ -1,2 +1,2 @@
1
- import GetBotsRequest from './GetBotsRequest';
2
- export { GetBotsRequest };
1
+ import getBotsRequest from "./getBotsRequest";
2
+ export { getBotsRequest };
@@ -0,0 +1,13 @@
1
+ import { RequestBuilder } from "../../base";
2
+
3
+ function getChannelAgentsRequest() {
4
+ return new RequestBuilder().withQuery({
5
+ from: 0,
6
+ limit: 10,
7
+ searchStr: null
8
+ }).withParams({
9
+ channelId: null
10
+ }).build();
11
+ }
12
+
13
+ export default getChannelAgentsRequest;
@@ -1,2 +1,2 @@
1
- import GetChannelAgentsRequest from './GetChannelAgentsRequest';
2
- export { GetChannelAgentsRequest };
1
+ import getChannelAgentsRequest from "./getChannelAgentsRequest";
2
+ export { getChannelAgentsRequest };
@@ -1 +1 @@
1
- export * from './agents';
1
+ export * from "./agents";
@@ -1,3 +1,3 @@
1
- export * from './channels';
2
- export * from './sessions';
3
- export * from './bots';
1
+ export * from "./channels";
2
+ export * from "./sessions";
3
+ export * from "./bots";
@@ -1,2 +1,2 @@
1
- import UpdateSessionAssigneeRequest from './UpdateSessionAssigneeRequest';
2
- export { UpdateSessionAssigneeRequest };
1
+ import updateSessionAssigneeRequest from "./updateSessionAssigneeRequest";
2
+ export { updateSessionAssigneeRequest };
@@ -0,0 +1,12 @@
1
+ import { RequestBuilder } from "../base";
2
+
3
+ function updateSessionAssigneeRequest() {
4
+ return new RequestBuilder().withParams({
5
+ channelId: null
6
+ }).withBody({
7
+ agentId: null,
8
+ botId: null
9
+ }).build();
10
+ }
11
+
12
+ export default updateSessionAssigneeRequest;
@@ -1 +1 @@
1
- export * from './api';
1
+ export * from "./api";
@@ -1,7 +1,7 @@
1
- import { ModuleNames } from '../../core/constants';
2
- import { BotSDK } from '../sdk/bots';
3
- import { ChannelSDK } from '../sdk/channels';
4
- import { SessionSDK } from '../sdk/sessions';
1
+ import { ModuleNames } from "../../core/constants";
2
+ import { BotSDK } from "../sdk/bots";
3
+ import { ChannelSDK } from "../sdk/channels";
4
+ import { SessionSDK } from "../sdk/sessions";
5
5
  const ModuleFactory = {
6
6
  [ModuleNames.CHANNELS]: _ref => {
7
7
  let {
@@ -1,5 +1,5 @@
1
- import { ModuleNames } from '../../core/constants';
2
- import ModuleFactory from './ModuleFactory';
1
+ import { ModuleNames } from "../../core/constants";
2
+ import ModuleFactory from "./ModuleFactory";
3
3
  export default class ModuleManager {
4
4
  constructor() {
5
5
  this._modules = new Map();
@@ -1,2 +1,2 @@
1
- import ModuleManager from './ModuleManager';
1
+ import ModuleManager from "./ModuleManager";
2
2
  export { ModuleManager };
@@ -1,6 +1,6 @@
1
- import { ModuleNames } from '../../core/constants';
2
- import { ModuleManager } from '../managers';
3
- import { configRegistry } from './config';
1
+ import { ModuleNames } from "../../core/constants";
2
+ import { ModuleManager } from "../managers";
3
+ import { configRegistry } from "./config";
4
4
  export default class IMSDK {
5
5
  constructor(_ref) {
6
6
  let {
@@ -32,7 +32,7 @@ export default class IMSDK {
32
32
  }
33
33
 
34
34
  hasModule(moduleName) {
35
- return this._modules.has(moduleName);
35
+ return this._moduleManager.hasModule(moduleName);
36
36
  }
37
37
 
38
38
  toJSON() {
@@ -1,4 +1,4 @@
1
- import { BotService } from '../../../domain/services';
1
+ import { BotService } from "../../../domain/services";
2
2
 
3
3
  class BotSDK extends BotService {
4
4
  constructor(_ref) {
@@ -1,2 +1,2 @@
1
- import BotSDK from './BotSDK';
1
+ import BotSDK from "./BotSDK";
2
2
  export { BotSDK };
@@ -1,4 +1,4 @@
1
- import { ChannelAgentService } from '../../../domain/services';
1
+ import { ChannelAgentService } from "../../../domain/services";
2
2
  export default class ChannelSDK {
3
3
  constructor(_ref) {
4
4
  let {
@@ -1,2 +1,2 @@
1
- import ChannelSDK from './ChannelSDK';
1
+ import ChannelSDK from "./ChannelSDK";
2
2
  export { ChannelSDK };
@@ -1,2 +1,2 @@
1
- import configRegistry from './configRegistry';
1
+ import configRegistry from "./configRegistry";
2
2
  export { configRegistry };
@@ -1,2 +1,2 @@
1
- import IMSDK from './IMSDK';
1
+ import IMSDK from "./IMSDK";
2
2
  export { IMSDK };
@@ -1,4 +1,4 @@
1
- import { SessionService } from '../../../domain/services';
1
+ import { SessionService } from "../../../domain/services";
2
2
 
3
3
  class SessionSDK extends SessionService {
4
4
  constructor(_ref) {
@@ -1,2 +1,2 @@
1
- import SessionSDK from './SessionSDK';
1
+ import SessionSDK from "./SessionSDK";
2
2
  export { SessionSDK };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc21",
3
+ "version": "1.0.0-poc23",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
@@ -1,14 +0,0 @@
1
- const params = {};
2
- const query = {
3
- from: 0,
4
- limit: 10,
5
- modifiedAfter: null,
6
- botServiceId: null,
7
- externalAccountId: null,
8
- searchStr: null
9
- };
10
- const GetBotsRequest = {
11
- params,
12
- query
13
- };
14
- export default GetBotsRequest;
@@ -1,13 +0,0 @@
1
- const params = {
2
- channelId: null
3
- };
4
- const query = {
5
- from: 0,
6
- limit: 10,
7
- searchStr: null
8
- };
9
- const GetChannelAgentsRequest = {
10
- params,
11
- query
12
- };
13
- export default GetChannelAgentsRequest;
@@ -1,12 +0,0 @@
1
- const params = {
2
- sessionId: null
3
- };
4
- const query = {
5
- agentId: null,
6
- botId: null
7
- };
8
- const UpdateSessionAssigneeRequest = {
9
- params,
10
- query
11
- };
12
- export default UpdateSessionAssigneeRequest;