@zohoim/client-sdk 1.0.0-poc77 → 1.0.0-poc79

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.
@@ -14,7 +14,6 @@ function initiateSessionRequest() {
14
14
  cannedMessageId: null,
15
15
  language: null,
16
16
  parameters: {},
17
- message: null,
18
17
  ...body
19
18
  }).build();
20
19
  }
@@ -7,6 +7,7 @@ function sendAttachmentRequest() {
7
7
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8
8
  return new RequestBuilder().withParams({
9
9
  sessionId: null,
10
+ messageId: null,
10
11
  ...params
11
12
  }).withBody({
12
13
  message: null,
@@ -10,8 +10,6 @@ function sendMessageRequest() {
10
10
  ...params
11
11
  }).withBody({
12
12
  message: null,
13
- replyToMessageId: null,
14
- meta: null,
15
13
  ...body
16
14
  }).build();
17
15
  }
@@ -2,15 +2,11 @@ import RequestBuilder from "../RequestBuilder";
2
2
 
3
3
  function markSessionAsReadRequest() {
4
4
  let {
5
- body = {},
6
- params = {}
5
+ body = {}
7
6
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8
7
  return new RequestBuilder().withBody({
9
8
  lastSeenMessageId: null,
10
9
  ...body
11
- }).withParams({
12
- sessionId: null,
13
- ...params
14
10
  }).build();
15
11
  }
16
12
 
@@ -58,6 +58,10 @@ export default class Message {
58
58
  return type === MessageTypes.ATTACHMENT;
59
59
  }
60
60
 
61
+ static isAutoSent(systemMsgType) {
62
+ return !!systemMsgType;
63
+ }
64
+
61
65
  toJSON() {
62
66
  return { ...this.data
63
67
  };
@@ -40,10 +40,6 @@ export default class Session {
40
40
  return replyStatus === SessionReplyStatus.CHANNEL_INACTIVE;
41
41
  }
42
42
 
43
- static isReplyAccepted(replyStatus) {
44
- return replyStatus === SessionReplyStatus.ACCEPTED;
45
- }
46
-
47
43
  static isAssignedToOtherService(replyStatus) {
48
44
  return replyStatus === SessionReplyStatus.ASSIGNED_TO_OTHER_SERVICE;
49
45
  }
@@ -1,7 +1,7 @@
1
1
  const ActorType = {
2
2
  AGENT: 'AGENT',
3
3
  BOT: 'BOT',
4
- ENDUSER: 'END_USER',
4
+ ENDUSER: 'ENDUSER',
5
5
  SYSTEM: 'SYSTEM'
6
6
  };
7
7
  export default ActorType;
@@ -1,6 +1,6 @@
1
1
  const MessageDirection = {
2
- OUT: 'out',
3
- IN: 'in'
2
+ OUT: 'OUT',
3
+ IN: 'IN'
4
4
  }; // For im api need to changes this as out and in
5
5
 
6
6
  export default MessageDirection;
@@ -6,9 +6,6 @@ const MessageTypes = {
6
6
  LAYOUT: 'LAYOUT',
7
7
  EXTERNAL_INFO: 'EXTERNAL_INFO',
8
8
  TEMPLATE: 'TEMPLATE',
9
- ACTION: 'ACTION',
10
- WELCOMEMSG: 'WELCOMEMSG',
11
- WORKFLOW_MESSAGE: 'WORKFLOW_MESSAGE',
12
- WORKFLOW_NOTIFICATION: 'WORKFLOW_NOTIFICATION'
9
+ ACTION: 'ACTION'
13
10
  };
14
11
  export default MessageTypes;
@@ -1,3 +1,4 @@
1
+ import { AttachmentStatus } from "../../enum";
1
2
  const AttachmentSchema = {
2
3
  id: {
3
4
  type: 'string',
@@ -25,7 +26,8 @@ const AttachmentSchema = {
25
26
  },
26
27
  status: {
27
28
  type: 'string',
28
- required: false
29
+ required: false,
30
+ enum: Object.values(AttachmentStatus)
29
31
  }
30
32
  };
31
33
  export default AttachmentSchema;
@@ -14,7 +14,8 @@ export default class AttachmentAdapter extends IAdapter {
14
14
  type: attachmentData.type,
15
15
  createdTime: attachmentData.createdTime,
16
16
  size: attachmentData.size,
17
- url: attachmentData.url
17
+ url: attachmentData.url,
18
+ status: attachmentData.status
18
19
  }).toJSON();
19
20
  } catch (error) {
20
21
  throw new AdapterError(`Failed to adapt attachment: ${error.message}`);
@@ -2,7 +2,6 @@ import { ResponseTypes } from "../../core/constants";
2
2
  import { ResponseUtils } from "../../core/utils";
3
3
  import configRegistry from "../config/configRegistry";
4
4
  import { getRegistryConfig } from "./registry";
5
- import UrlBuilder from "./UrlBuilder";
6
5
  export default class BaseAPI {
7
6
  constructor() {
8
7
  let {
@@ -10,30 +9,78 @@ export default class BaseAPI {
10
9
  configProvider = configRegistry,
11
10
  registryProvider = {
12
11
  getRegistryConfig
13
- },
14
- urlBuilder = new UrlBuilder()
12
+ }
15
13
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
14
  this.configProvider = configProvider;
17
15
  this.registryProvider = registryProvider;
18
16
  this.httpClient = this.configProvider.getHttpClient();
19
17
  this.baseURL = this.configProvider.getBaseURL();
20
18
  this.module = module;
21
- this.urlBuilder = urlBuilder;
22
19
  }
23
20
 
24
- async request(_ref) {
21
+ replacePathParams(url, params) {
22
+ let _url = url;
23
+ Object.entries(params).forEach(_ref => {
24
+ let [key, value] = _ref;
25
+ _url = url.replace(`:${key}`, value);
26
+ });
27
+ return _url;
28
+ }
29
+
30
+ buildUrl(_ref2) {
31
+ let {
32
+ url,
33
+ params,
34
+ query
35
+ } = _ref2;
36
+
37
+ const _params = params || {};
38
+
39
+ const _query = query || {};
40
+
41
+ let _url = this.replacePathParams(url, _params);
42
+
43
+ if (this.baseURL) {
44
+ _url = `${this.baseURL}${_url}`;
45
+ }
46
+
47
+ const queryString = this.buildQuery(_query);
48
+
49
+ if (queryString) {
50
+ return `${_url}?${queryString}`;
51
+ }
52
+
53
+ return _url;
54
+ }
55
+
56
+ buildQuery(query) {
57
+ const filteredQuery = Object.entries(query).filter(_ref3 => {
58
+ let [, value] = _ref3;
59
+ return value !== undefined && value !== null && value !== '';
60
+ }).reduce((acc, _ref4) => {
61
+ let [key, value] = _ref4;
62
+ acc[key] = value;
63
+ return acc;
64
+ }, {});
65
+ return Object.entries(filteredQuery).map(_ref5 => {
66
+ let [key, value] = _ref5;
67
+ return `${key}=${value}`;
68
+ }).join('&');
69
+ }
70
+
71
+ async request(_ref6) {
25
72
  let {
26
73
  request,
27
74
  operation,
28
75
  header
29
- } = _ref;
76
+ } = _ref6;
30
77
  const config = this.registryProvider.getRegistryConfig(this.module, operation);
31
78
 
32
79
  if (!config) {
33
80
  throw new Error(`Operation "${operation}" not found in registry for module "${this.module}"`);
34
81
  }
35
82
 
36
- const url = this.urlBuilder.buildUrl({
83
+ const url = this.buildUrl({
37
84
  url: config.endpoint,
38
85
  params: request.params || {},
39
86
  query: request.query || {}
@@ -74,7 +121,7 @@ export default class BaseAPI {
74
121
  Object.prototype.hasOwnProperty.call(customPrototype, methodName);
75
122
  }
76
123
 
77
- async executeAPICall(_ref2) {
124
+ async executeAPICall(_ref7) {
78
125
  let {
79
126
  operation,
80
127
  request,
@@ -82,7 +129,7 @@ export default class BaseAPI {
82
129
  customAPI,
83
130
  adapter,
84
131
  responseType = ResponseTypes.SINGLE
85
- } = _ref2;
132
+ } = _ref7;
86
133
  const response = await apiProxy[operation](request);
87
134
  const isOverridden = this.isMethodOverridden(customAPI, operation);
88
135
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc77",
3
+ "version": "1.0.0-poc79",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
@@ -1,53 +0,0 @@
1
- export default class UrlBuilder {
2
- constructor(baseURL) {
3
- this.baseURL = baseURL;
4
- }
5
-
6
- replacePathParams(url, params) {
7
- let processedUrl = url;
8
- Object.entries(params).forEach(_ref => {
9
- let [key, value] = _ref;
10
- processedUrl = processedUrl.replace(`:${key}`, value);
11
- });
12
- return processedUrl;
13
- }
14
-
15
- buildUrl(_ref2) {
16
- let {
17
- url,
18
- params,
19
- query
20
- } = _ref2;
21
- const paramsObj = params || {};
22
- const queryObj = query || {};
23
- let processedUrl = this.replacePathParams(url, paramsObj);
24
-
25
- if (this.baseURL) {
26
- processedUrl = `${this.baseURL}${processedUrl}`;
27
- }
28
-
29
- const queryString = this.buildQuery(queryObj);
30
-
31
- if (queryString) {
32
- return `${processedUrl}?${queryString}`;
33
- }
34
-
35
- return processedUrl;
36
- }
37
-
38
- buildQuery(query) {
39
- const filteredQuery = Object.entries(query).filter(_ref3 => {
40
- let [, value] = _ref3;
41
- return value !== undefined && value !== null && value !== '';
42
- }).reduce((acc, _ref4) => {
43
- let [key, value] = _ref4;
44
- acc[key] = value;
45
- return acc;
46
- }, {});
47
- return Object.entries(filteredQuery).map(_ref5 => {
48
- let [key, value] = _ref5;
49
- return `${key}=${value}`;
50
- }).join('&');
51
- }
52
-
53
- }