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

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,6 +14,7 @@ function initiateSessionRequest() {
14
14
  cannedMessageId: null,
15
15
  language: null,
16
16
  parameters: {},
17
+ message: null,
17
18
  ...body
18
19
  }).build();
19
20
  }
@@ -7,7 +7,6 @@ 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,
11
10
  ...params
12
11
  }).withBody({
13
12
  message: null,
@@ -10,6 +10,8 @@ function sendMessageRequest() {
10
10
  ...params
11
11
  }).withBody({
12
12
  message: null,
13
+ replyToMessageId: null,
14
+ meta: null,
13
15
  ...body
14
16
  }).build();
15
17
  }
@@ -2,11 +2,15 @@ import RequestBuilder from "../RequestBuilder";
2
2
 
3
3
  function markSessionAsReadRequest() {
4
4
  let {
5
- body = {}
5
+ body = {},
6
+ params = {}
6
7
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
8
  return new RequestBuilder().withBody({
8
9
  lastSeenMessageId: null,
9
10
  ...body
11
+ }).withParams({
12
+ sessionId: null,
13
+ ...params
10
14
  }).build();
11
15
  }
12
16
 
@@ -10,7 +10,8 @@ export default class Attachment {
10
10
  type: validatedData.type,
11
11
  createdTime: validatedData.createdTime,
12
12
  size: validatedData.size,
13
- url: validatedData.url
13
+ url: validatedData.url,
14
+ status: validatedData.status
14
15
  };
15
16
  }
16
17
 
@@ -40,6 +40,10 @@ 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
+
43
47
  static isAssignedToOtherService(replyStatus) {
44
48
  return replyStatus === SessionReplyStatus.ASSIGNED_TO_OTHER_SERVICE;
45
49
  }
@@ -1,7 +1,7 @@
1
1
  const ActorType = {
2
2
  AGENT: 'AGENT',
3
3
  BOT: 'BOT',
4
- ENDUSER: 'ENDUSER',
4
+ ENDUSER: 'END_USER',
5
5
  SYSTEM: 'SYSTEM'
6
6
  };
7
7
  export default ActorType;
@@ -0,0 +1,5 @@
1
+ const AttachmentStatus = {
2
+ VALID: 'VALID',
3
+ INVALID: 'INVALID'
4
+ };
5
+ export default AttachmentStatus;
@@ -0,0 +1,2 @@
1
+ import AttachmentStatus from "./AttachmentStatus";
2
+ export { AttachmentStatus };
@@ -2,4 +2,5 @@ export * from "./integrationServices";
2
2
  export * from "./session";
3
3
  export * from "./actor";
4
4
  export * from "./bot";
5
- export * from "./message";
5
+ export * from "./message";
6
+ export * from "./attachment";
@@ -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,6 +6,9 @@ const MessageTypes = {
6
6
  LAYOUT: 'LAYOUT',
7
7
  EXTERNAL_INFO: 'EXTERNAL_INFO',
8
8
  TEMPLATE: 'TEMPLATE',
9
- ACTION: 'ACTION'
9
+ ACTION: 'ACTION',
10
+ WELCOMEMSG: 'WELCOMEMSG',
11
+ WORKFLOW_MESSAGE: 'WORKFLOW_MESSAGE',
12
+ WORKFLOW_NOTIFICATION: 'WORKFLOW_NOTIFICATION'
10
13
  };
11
14
  export default MessageTypes;
@@ -22,6 +22,10 @@ const AttachmentSchema = {
22
22
  url: {
23
23
  type: 'string',
24
24
  required: false
25
+ },
26
+ status: {
27
+ type: 'string',
28
+ required: false
25
29
  }
26
30
  };
27
31
  export default AttachmentSchema;
@@ -2,6 +2,7 @@ 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";
5
6
  export default class BaseAPI {
6
7
  constructor() {
7
8
  let {
@@ -9,78 +10,30 @@ export default class BaseAPI {
9
10
  configProvider = configRegistry,
10
11
  registryProvider = {
11
12
  getRegistryConfig
12
- }
13
+ },
14
+ urlBuilder = new UrlBuilder()
13
15
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
16
  this.configProvider = configProvider;
15
17
  this.registryProvider = registryProvider;
16
18
  this.httpClient = this.configProvider.getHttpClient();
17
19
  this.baseURL = this.configProvider.getBaseURL();
18
20
  this.module = module;
21
+ this.urlBuilder = urlBuilder;
19
22
  }
20
23
 
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) {
24
+ async request(_ref) {
72
25
  let {
73
26
  request,
74
27
  operation,
75
28
  header
76
- } = _ref6;
29
+ } = _ref;
77
30
  const config = this.registryProvider.getRegistryConfig(this.module, operation);
78
31
 
79
32
  if (!config) {
80
33
  throw new Error(`Operation "${operation}" not found in registry for module "${this.module}"`);
81
34
  }
82
35
 
83
- const url = this.buildUrl({
36
+ const url = this.urlBuilder.buildUrl({
84
37
  url: config.endpoint,
85
38
  params: request.params || {},
86
39
  query: request.query || {}
@@ -121,7 +74,7 @@ export default class BaseAPI {
121
74
  Object.prototype.hasOwnProperty.call(customPrototype, methodName);
122
75
  }
123
76
 
124
- async executeAPICall(_ref7) {
77
+ async executeAPICall(_ref2) {
125
78
  let {
126
79
  operation,
127
80
  request,
@@ -129,7 +82,7 @@ export default class BaseAPI {
129
82
  customAPI,
130
83
  adapter,
131
84
  responseType = ResponseTypes.SINGLE
132
- } = _ref7;
85
+ } = _ref2;
133
86
  const response = await apiProxy[operation](request);
134
87
  const isOverridden = this.isMethodOverridden(customAPI, operation);
135
88
 
@@ -0,0 +1,53 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc75",
3
+ "version": "1.0.0-poc77",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",