@or-sdk/hitl 0.35.0-beta.2816.0 → 0.35.0

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 (219) hide show
  1. package/CHANGELOG.md +271 -0
  2. package/README.md +65 -0
  3. package/dist/cjs/AppError.js.map +1 -1
  4. package/dist/cjs/EKS.js.map +1 -1
  5. package/dist/cjs/HITL.js +1 -1
  6. package/dist/cjs/HITL.js.map +1 -1
  7. package/dist/cjs/api/Agents.js +108 -104
  8. package/dist/cjs/api/Agents.js.map +1 -1
  9. package/dist/cjs/api/CannedMessages.js +54 -40
  10. package/dist/cjs/api/CannedMessages.js.map +1 -1
  11. package/dist/cjs/api/Commands.js +31 -16
  12. package/dist/cjs/api/Commands.js.map +1 -1
  13. package/dist/cjs/api/Conferences.js +44 -31
  14. package/dist/cjs/api/Conferences.js.map +1 -1
  15. package/dist/cjs/api/ContactRuleGroups.js +56 -33
  16. package/dist/cjs/api/ContactRuleGroups.js.map +1 -1
  17. package/dist/cjs/api/Contacts.js +14 -7
  18. package/dist/cjs/api/Contacts.js.map +1 -1
  19. package/dist/cjs/api/ContactsMeta.js +19 -9
  20. package/dist/cjs/api/ContactsMeta.js.map +1 -1
  21. package/dist/cjs/api/EventTemplates.js +55 -37
  22. package/dist/cjs/api/EventTemplates.js.map +1 -1
  23. package/dist/cjs/api/Filters.js +48 -45
  24. package/dist/cjs/api/Filters.js.map +1 -1
  25. package/dist/cjs/api/HITLBase.js +4 -0
  26. package/dist/cjs/api/HITLBase.js.map +1 -1
  27. package/dist/cjs/api/Helpers.js +14 -6
  28. package/dist/cjs/api/Helpers.js.map +1 -1
  29. package/dist/cjs/api/Listeners.js +58 -44
  30. package/dist/cjs/api/Listeners.js.map +1 -1
  31. package/dist/cjs/api/Migrations.js +66 -57
  32. package/dist/cjs/api/Migrations.js.map +1 -1
  33. package/dist/cjs/api/RuleGroups.js +56 -33
  34. package/dist/cjs/api/RuleGroups.js.map +1 -1
  35. package/dist/cjs/api/SessionEvents.js +66 -40
  36. package/dist/cjs/api/SessionEvents.js.map +1 -1
  37. package/dist/cjs/api/SessionRelations.js +26 -21
  38. package/dist/cjs/api/SessionRelations.js.map +1 -1
  39. package/dist/cjs/api/Sessions.js +128 -126
  40. package/dist/cjs/api/Sessions.js.map +1 -1
  41. package/dist/cjs/api/Settings.js +76 -35
  42. package/dist/cjs/api/Settings.js.map +1 -1
  43. package/dist/cjs/api/Tasks.js +28 -16
  44. package/dist/cjs/api/Tasks.js.map +1 -1
  45. package/dist/cjs/api/Versions.js +15 -8
  46. package/dist/cjs/api/Versions.js.map +1 -1
  47. package/dist/cjs/constants.js +2 -1
  48. package/dist/cjs/constants.js.map +1 -1
  49. package/dist/cjs/index.js +21 -1
  50. package/dist/cjs/index.js.map +1 -1
  51. package/dist/cjs/types/agents.js.map +1 -1
  52. package/dist/cjs/types/commands.js.map +1 -1
  53. package/dist/cjs/types/common.js.map +1 -1
  54. package/dist/cjs/types/conferences.js.map +1 -1
  55. package/dist/cjs/types/listeners.js.map +1 -1
  56. package/dist/cjs/types/migrations.js.map +1 -1
  57. package/dist/cjs/types/tasks.js.map +1 -1
  58. package/dist/esm/EKS.js.map +1 -1
  59. package/dist/esm/HITL.js +1 -1
  60. package/dist/esm/HITL.js.map +1 -1
  61. package/dist/esm/api/Agents.js +61 -81
  62. package/dist/esm/api/Agents.js.map +1 -1
  63. package/dist/esm/api/CannedMessages.js +30 -31
  64. package/dist/esm/api/CannedMessages.js.map +1 -1
  65. package/dist/esm/api/Commands.js +17 -10
  66. package/dist/esm/api/Commands.js.map +1 -1
  67. package/dist/esm/api/Conferences.js +34 -29
  68. package/dist/esm/api/Conferences.js.map +1 -1
  69. package/dist/esm/api/ContactRuleGroups.js +34 -30
  70. package/dist/esm/api/ContactRuleGroups.js.map +1 -1
  71. package/dist/esm/api/Contacts.js +1 -5
  72. package/dist/esm/api/Contacts.js.map +1 -1
  73. package/dist/esm/api/ContactsMeta.js +4 -7
  74. package/dist/esm/api/ContactsMeta.js.map +1 -1
  75. package/dist/esm/api/EventTemplates.js +25 -28
  76. package/dist/esm/api/EventTemplates.js.map +1 -1
  77. package/dist/esm/api/Filters.js +39 -43
  78. package/dist/esm/api/Filters.js.map +1 -1
  79. package/dist/esm/api/HITLBase.js +3 -0
  80. package/dist/esm/api/HITLBase.js.map +1 -1
  81. package/dist/esm/api/Helpers.js +1 -4
  82. package/dist/esm/api/Helpers.js.map +1 -1
  83. package/dist/esm/api/Listeners.js +34 -37
  84. package/dist/esm/api/Listeners.js.map +1 -1
  85. package/dist/esm/api/Migrations.js +34 -49
  86. package/dist/esm/api/Migrations.js.map +1 -1
  87. package/dist/esm/api/RuleGroups.js +34 -30
  88. package/dist/esm/api/RuleGroups.js.map +1 -1
  89. package/dist/esm/api/SessionEvents.js +36 -34
  90. package/dist/esm/api/SessionEvents.js.map +1 -1
  91. package/dist/esm/api/SessionRelations.js +10 -19
  92. package/dist/esm/api/SessionRelations.js.map +1 -1
  93. package/dist/esm/api/Sessions.js +80 -102
  94. package/dist/esm/api/Sessions.js.map +1 -1
  95. package/dist/esm/api/Settings.js +38 -27
  96. package/dist/esm/api/Settings.js.map +1 -1
  97. package/dist/esm/api/Tasks.js +14 -10
  98. package/dist/esm/api/Tasks.js.map +1 -1
  99. package/dist/esm/api/Versions.js +2 -6
  100. package/dist/esm/api/Versions.js.map +1 -1
  101. package/dist/esm/constants.js +1 -0
  102. package/dist/esm/constants.js.map +1 -1
  103. package/dist/esm/index.js +1 -0
  104. package/dist/esm/index.js.map +1 -1
  105. package/dist/esm/types/agents.js.map +1 -1
  106. package/dist/esm/types/commands.js.map +1 -1
  107. package/dist/esm/types/common.js.map +1 -1
  108. package/dist/esm/types/conferences.js.map +1 -1
  109. package/dist/esm/types/listeners.js.map +1 -1
  110. package/dist/esm/types/migrations.js.map +1 -1
  111. package/dist/esm/types/tasks.js.map +1 -1
  112. package/dist/types/EKS.d.ts.map +1 -1
  113. package/dist/types/HITL.d.ts.map +1 -1
  114. package/dist/types/api/Agents.d.ts +7 -5
  115. package/dist/types/api/Agents.d.ts.map +1 -1
  116. package/dist/types/api/CannedMessages.d.ts +3 -3
  117. package/dist/types/api/CannedMessages.d.ts.map +1 -1
  118. package/dist/types/api/Commands.d.ts +1 -1
  119. package/dist/types/api/Commands.d.ts.map +1 -1
  120. package/dist/types/api/Conferences.d.ts +3 -3
  121. package/dist/types/api/Conferences.d.ts.map +1 -1
  122. package/dist/types/api/ContactRuleGroups.d.ts +4 -4
  123. package/dist/types/api/ContactRuleGroups.d.ts.map +1 -1
  124. package/dist/types/api/Contacts.d.ts.map +1 -1
  125. package/dist/types/api/ContactsMeta.d.ts.map +1 -1
  126. package/dist/types/api/EventTemplates.d.ts +2 -2
  127. package/dist/types/api/EventTemplates.d.ts.map +1 -1
  128. package/dist/types/api/Filters.d.ts +2 -2
  129. package/dist/types/api/Filters.d.ts.map +1 -1
  130. package/dist/types/api/HITLBase.d.ts +3 -0
  131. package/dist/types/api/HITLBase.d.ts.map +1 -1
  132. package/dist/types/api/Helpers.d.ts.map +1 -1
  133. package/dist/types/api/Listeners.d.ts +4 -4
  134. package/dist/types/api/Listeners.d.ts.map +1 -1
  135. package/dist/types/api/Migrations.d.ts +7 -6
  136. package/dist/types/api/Migrations.d.ts.map +1 -1
  137. package/dist/types/api/RuleGroups.d.ts +4 -4
  138. package/dist/types/api/RuleGroups.d.ts.map +1 -1
  139. package/dist/types/api/SessionEvents.d.ts +11 -5
  140. package/dist/types/api/SessionEvents.d.ts.map +1 -1
  141. package/dist/types/api/SessionRelations.d.ts +1 -1
  142. package/dist/types/api/SessionRelations.d.ts.map +1 -1
  143. package/dist/types/api/Sessions.d.ts +21 -19
  144. package/dist/types/api/Sessions.d.ts.map +1 -1
  145. package/dist/types/api/Settings.d.ts +5 -3
  146. package/dist/types/api/Settings.d.ts.map +1 -1
  147. package/dist/types/api/Tasks.d.ts +2 -2
  148. package/dist/types/api/Tasks.d.ts.map +1 -1
  149. package/dist/types/api/Versions.d.ts +1 -1
  150. package/dist/types/api/Versions.d.ts.map +1 -1
  151. package/dist/types/constants.d.ts +4 -3
  152. package/dist/types/constants.d.ts.map +1 -1
  153. package/dist/types/index.d.ts +1 -0
  154. package/dist/types/index.d.ts.map +1 -1
  155. package/dist/types/types/agents.d.ts.map +1 -1
  156. package/dist/types/types/canned-messages.d.ts.map +1 -1
  157. package/dist/types/types/commands.d.ts.map +1 -1
  158. package/dist/types/types/common.d.ts +2 -1
  159. package/dist/types/types/common.d.ts.map +1 -1
  160. package/dist/types/types/conferences.d.ts.map +1 -1
  161. package/dist/types/types/contacts-meta.d.ts.map +1 -1
  162. package/dist/types/types/contacts.d.ts.map +1 -1
  163. package/dist/types/types/event-templates.d.ts.map +1 -1
  164. package/dist/types/types/filters.d.ts.map +1 -1
  165. package/dist/types/types/listeners.d.ts.map +1 -1
  166. package/dist/types/types/migrations.d.ts.map +1 -1
  167. package/dist/types/types/read-events.d.ts.map +1 -1
  168. package/dist/types/types/rule-groups.d.ts.map +1 -1
  169. package/dist/types/types/session-events.d.ts +2 -0
  170. package/dist/types/types/session-events.d.ts.map +1 -1
  171. package/dist/types/types/session-relations.d.ts.map +1 -1
  172. package/dist/types/types/sessions.d.ts +1 -0
  173. package/dist/types/types/sessions.d.ts.map +1 -1
  174. package/dist/types/types/settings.d.ts +1 -0
  175. package/dist/types/types/settings.d.ts.map +1 -1
  176. package/dist/types/types/tasks.d.ts.map +1 -1
  177. package/package.json +8 -8
  178. package/src/EKS.ts +1 -2
  179. package/src/HITL.ts +15 -2
  180. package/src/api/Agents.ts +90 -27
  181. package/src/api/CannedMessages.ts +42 -12
  182. package/src/api/Commands.ts +12 -7
  183. package/src/api/Conferences.ts +45 -19
  184. package/src/api/ContactRuleGroups.ts +41 -15
  185. package/src/api/Contacts.ts +9 -0
  186. package/src/api/ContactsMeta.ts +12 -2
  187. package/src/api/EventTemplates.ts +32 -10
  188. package/src/api/Filters.ts +67 -28
  189. package/src/api/HITLBase.ts +4 -0
  190. package/src/api/Helpers.ts +6 -0
  191. package/src/api/Listeners.ts +49 -13
  192. package/src/api/Migrations.ts +62 -15
  193. package/src/api/RuleGroups.ts +41 -15
  194. package/src/api/SessionEvents.ts +70 -21
  195. package/src/api/SessionRelations.ts +31 -8
  196. package/src/api/Sessions.ts +158 -52
  197. package/src/api/Settings.ts +56 -13
  198. package/src/api/Tasks.ts +9 -8
  199. package/src/api/Versions.ts +12 -1
  200. package/src/constants.ts +3 -3
  201. package/src/index.ts +21 -0
  202. package/src/types/agents.ts +1 -0
  203. package/src/types/canned-messages.ts +1 -0
  204. package/src/types/commands.ts +1 -0
  205. package/src/types/common.ts +2 -1
  206. package/src/types/conferences.ts +1 -0
  207. package/src/types/contacts-meta.ts +1 -0
  208. package/src/types/contacts.ts +1 -0
  209. package/src/types/event-templates.ts +1 -0
  210. package/src/types/filters.ts +1 -0
  211. package/src/types/listeners.ts +1 -0
  212. package/src/types/migrations.ts +1 -0
  213. package/src/types/read-events.ts +1 -0
  214. package/src/types/rule-groups.ts +1 -0
  215. package/src/types/session-events.ts +6 -0
  216. package/src/types/session-relations.ts +1 -0
  217. package/src/types/sessions.ts +2 -0
  218. package/src/types/settings.ts +4 -0
  219. package/src/types/tasks.ts +1 -0
@@ -1,5 +1,4 @@
1
- import _ from 'lodash';
2
-
1
+ import { DEFAULT_OMIT_FIELDS } from '../constants';
3
2
  import {
4
3
  SearchRuleGroupsOptions,
5
4
  SearchRuleGroupsResponse,
@@ -8,61 +7,88 @@ import {
8
7
  UpdateRuleGroupOptions,
9
8
  DeleteRuleGroupOptions,
10
9
  } from '../types/rule-groups';
10
+
11
11
  import { HITLBase } from './HITLBase';
12
12
 
13
13
  export class ContactRuleGroups extends HITLBase {
14
14
  protected static MODULE_URL = 'contact-rule-groups';
15
15
 
16
+ /**
17
+ * @description Get/search Contact Rule Groups
18
+ * @param options
19
+ */
16
20
  public static searchContactRuleGroups(
17
- options: SearchRuleGroupsOptions = {}
21
+ { groupIdList, ...options }: SearchRuleGroupsOptions = {}
18
22
  ): Promise<SearchRuleGroupsResponse | RuleGroup> {
19
23
  const route = this.getBaseUrl(options);
20
- const params = _.omit(options, ['version', 'groupIdList', 'accountId']);
21
- const data = _.pick(options, 'groupIdList');
24
+ const params = Object.fromEntries(
25
+ Object.entries(options).filter(([key]) => ![...DEFAULT_OMIT_FIELDS, 'accountId'].includes(key))
26
+ );
22
27
 
23
28
  return this.request({
24
29
  route,
25
30
  params,
26
- data,
31
+ data: { groupIdList },
32
+ ...this.getBaseSettings(options),
27
33
  });
28
34
  }
29
35
 
36
+ /**
37
+ * @description Create Contact Rule Group
38
+ * @param options
39
+ */
30
40
  public static createContactRuleGroup(
31
- options: CreateRuleGroupOptions
41
+ { groupId, name, rules, ...options }: CreateRuleGroupOptions
32
42
  ): Promise<RuleGroup> {
33
43
  const route = this.getBaseUrl(options);
34
- const data = _.pick(options, ['name', 'rules']);
35
44
 
36
45
  return this.request({
37
46
  method: 'POST',
38
47
  route,
39
- data,
48
+ data: {
49
+ groupId,
50
+ name,
51
+ rules,
52
+ },
53
+ ...this.getBaseSettings(options),
40
54
  });
41
55
  }
42
56
 
57
+ /**
58
+ * @description Update Contact Rule Group
59
+ * @param options
60
+ */
43
61
  public static updateContactRuleGroup(
44
- options: UpdateRuleGroupOptions
62
+ { groupId, name, rules, ...options }: UpdateRuleGroupOptions
45
63
  ): Promise<RuleGroup> {
46
64
  const route = this.getBaseUrl(options);
47
- const data = _.pick(options, ['groupId', 'name', 'rules']);
48
65
 
49
66
  return this.request({
50
67
  method: 'PUT',
51
68
  route,
52
- data,
69
+ data: {
70
+ groupId,
71
+ name,
72
+ rules,
73
+ },
74
+ ...this.getBaseSettings(options),
53
75
  });
54
76
  }
55
77
 
78
+ /**
79
+ * @description Delete Contact Rule Group
80
+ * @param options
81
+ */
56
82
  public static deleteContactRuleGroup(
57
- options: DeleteRuleGroupOptions
83
+ { groupId, ...options }: DeleteRuleGroupOptions
58
84
  ): Promise<void> {
59
85
  const route = this.getBaseUrl(options);
60
- const params = _.pick(options, ['groupId']);
61
86
 
62
87
  return this.request({
63
88
  method: 'DELETE',
64
89
  route,
65
- params,
90
+ params: { groupId },
91
+ ...this.getBaseSettings(options),
66
92
  });
67
93
  }
68
94
  }
@@ -1,7 +1,15 @@
1
1
  import { SearchContactsOptions, SearchContactsResponse } from '../types/contacts';
2
+
2
3
  import { HITLBase } from './HITLBase';
3
4
  export class Contacts extends HITLBase {
4
5
  protected static MODULE_URL = 'contacts';
6
+
7
+ /**
8
+ * @description Search contacts limited by Agent's Contact Rule Groups
9
+ * (filters out Contact records not "visible" to a given Agent, according
10
+ * to the Contact Rule Groups the Agent is a member of)
11
+ * @param options
12
+ */
5
13
  public static async searchContacts(
6
14
  options: SearchContactsOptions
7
15
  ): Promise<SearchContactsResponse> {
@@ -11,6 +19,7 @@ export class Contacts extends HITLBase {
11
19
  method: 'POST',
12
20
  route,
13
21
  data: options,
22
+ ...this.getBaseSettings(options),
14
23
  });
15
24
  }
16
25
  }
@@ -1,27 +1,37 @@
1
- import _ from 'lodash';
2
1
  import URI from 'urijs';
3
2
 
3
+ import { DEFAULT_OMIT_FIELDS } from '../constants';
4
4
  import {
5
5
  SearchContactsMetaOptions,
6
6
  SearchContactsMetaResponse,
7
7
  } from '../types/contacts-meta';
8
+
8
9
  import { HITLBase } from './HITLBase';
9
10
 
10
11
  export class ContactsMeta extends HITLBase {
11
12
  protected static MODULE_URL = 'contacts-meta';
12
13
  protected static SEARCH_URL = 'search';
13
14
 
15
+ /**
16
+ * @description Get HitL specific Contacts parameters (meta info):
17
+ * a list of Contact record fields visible in CRM card,
18
+ * identifier to conversation trigger map, etc.
19
+ * @param options
20
+ */
14
21
  public static async searchContactsMeta(
15
22
  options: SearchContactsMetaOptions
16
23
  ): Promise<SearchContactsMetaResponse> {
17
24
  const baseUrl = this.getBaseUrl(options);
18
25
  const route = new URI(baseUrl).segment(this.SEARCH_URL).href();
19
- const data = _.omit(options, ['version']);
26
+ const data = Object.fromEntries(
27
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
28
+ );
20
29
 
21
30
  return this.request({
22
31
  method: 'POST',
23
32
  route,
24
33
  data,
34
+ ...this.getBaseSettings(options),
25
35
  });
26
36
  }
27
37
  }
@@ -1,5 +1,4 @@
1
- import _ from 'lodash';
2
-
1
+ import { DEFAULT_OMIT_FIELDS } from '../constants';
3
2
  import {
4
3
  GetEventTemplatesOptions,
5
4
  GetEventTemplatesResponse,
@@ -8,60 +7,83 @@ import {
8
7
  DeleteEventTemplateOptions,
9
8
  EventTemplate,
10
9
  } from '../types/event-templates';
10
+
11
11
  import { HITLBase } from './HITLBase';
12
12
 
13
13
  export class EventTemplates extends HITLBase {
14
14
  protected static readonly MODULE_URL = 'event-templates';
15
15
 
16
+ /**
17
+ * @description Get Event templates
18
+ * @param options
19
+ */
16
20
  public static async getEventTemplates(
17
- options: GetEventTemplatesOptions = {}
21
+ { templateId, ...options }: GetEventTemplatesOptions = {}
18
22
  ): Promise<GetEventTemplatesResponse | EventTemplate> {
19
23
  const route = this.getBaseUrl(options);
20
- const params = _.pick(options, ['templateId']);
21
24
 
22
25
  return this.request({
23
26
  method: 'GET',
24
27
  route,
25
- params,
28
+ params: { templateId },
29
+ ...this.getBaseSettings(options),
26
30
  });
27
31
  }
28
32
 
33
+ /**
34
+ * @description Create Event template
35
+ * @param options
36
+ */
29
37
  public static async createEventTemplate(
30
38
  options: CreateEventTemplateOptions
31
39
  ): Promise<EventTemplate> {
32
40
  const route = this.getBaseUrl(options);
33
- const data = _.omit(options, ['version']);
41
+ const data = Object.fromEntries(
42
+ Object.entries(options).filter(([key]) => ![...DEFAULT_OMIT_FIELDS, 'templateId'].includes(key))
43
+ );
34
44
 
35
45
  return this.request({
36
46
  method: 'POST',
37
47
  route,
38
48
  data,
49
+ ...this.getBaseSettings(options),
39
50
  });
40
51
  }
41
52
 
53
+ /**
54
+ * @description Update Event template
55
+ * @param options
56
+ */
42
57
  public static async updateEventTemplate(
43
58
  options: UpdateEventTemplateOptions
44
59
  ): Promise<EventTemplate> {
45
60
  const route = this.getBaseUrl(options);
46
- const data = _.omit(options, ['version']);
61
+ const data = Object.fromEntries(
62
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
63
+ );
47
64
 
48
65
  return this.request({
49
66
  method: 'PUT',
50
67
  route,
51
68
  data,
69
+ ...this.getBaseSettings(options),
52
70
  });
53
71
  }
54
72
 
73
+ /**
74
+ * @description Delete Event template
75
+ * @param options
76
+ */
55
77
  public static async deleteEventTemplate(
56
- options: DeleteEventTemplateOptions
78
+ { templateId, ...options }: DeleteEventTemplateOptions
57
79
  ): Promise<void> {
58
80
  const route = this.getBaseUrl(options);
59
- const params = _.pick(options, ['templateId']);
60
81
 
61
82
  return this.request({
62
83
  method: 'DELETE',
63
84
  route,
64
- params,
85
+ params: { templateId },
86
+ ...this.getBaseSettings(options),
65
87
  });
66
88
  }
67
89
  }
@@ -1,7 +1,5 @@
1
- import _ from 'lodash';
2
1
  import URI from 'urijs';
3
2
 
4
- import { HITLBase } from './HITLBase';
5
3
  import {
6
4
  FilterV1,
7
5
  Filter,
@@ -23,6 +21,8 @@ import {
23
21
  BulkUpdateFiltersResponse,
24
22
  } from '../types/filters';
25
23
 
24
+ import { HITLBase } from './HITLBase';
25
+
26
26
  export class Filters extends HITLBase {
27
27
  protected static MODULE_URL = 'filters';
28
28
  protected static BULK_URL = 'bulk';
@@ -35,106 +35,145 @@ export class Filters extends HITLBase {
35
35
  'ruleTags',
36
36
  'tags',
37
37
  ];
38
- protected static FILTER_VERSION_FIELD = 'filterVersion';
38
+ protected static FILTER_VERSION_FIELD = 'filterVersion' as const;
39
39
 
40
+ /**
41
+ * @description Get Conversation view filters list
42
+ * @param options
43
+ */
40
44
  public static getFilters(options: GetFiltersOptionsV1): Promise<GetFiltersResponseV1>;
41
45
  public static getFilters(options: GetFiltersOptions): Promise<GetFiltersResponse>;
42
46
  public static getFilters(
43
- options: GetFiltersOptions = {}
47
+ { id, agentId, ignoreRuleTags, ...options }: GetFiltersOptions = {}
44
48
  ) {
45
49
  const route = this.getBaseUrl(options);
46
- const params = _.pick(options, ['id', 'agentId', 'ignoreRuleTags']);
47
50
 
48
51
  return this.request({
49
52
  method: 'GET',
50
53
  route,
51
- params,
54
+ params: {
55
+ id,
56
+ agentId,
57
+ ignoreRuleTags,
58
+ },
59
+ ...this.getBaseSettings(options),
52
60
  });
53
61
  }
54
62
 
63
+
64
+ /**
65
+ * @description Bulk get Conversation view filters list ignoring userId for personal filters
66
+ * @param options
67
+ */
55
68
  public static bulkGetFilters(options: BulkGetFiltersOptionsV1): Promise<GetFiltersResponseV1>;
56
69
  public static bulkGetFilters(options: BulkGetFiltersOptions): Promise<GetFiltersResponse>;
57
70
  public static bulkGetFilters(
58
- options: BulkGetFiltersOptions = {}
71
+ { ignoreRuleTags, ...options }: BulkGetFiltersOptions = {}
59
72
  ) {
60
73
  const baseUrl = this.getBaseUrl(options);
61
74
  const route = new URI(baseUrl).segment(this.BULK_URL).href();
62
- const params = _.pick(options, ['ignoreRuleTags']);
63
75
 
64
76
  return this.request({
65
77
  method: 'GET',
66
78
  route,
67
- params,
79
+ params: { ignoreRuleTags },
80
+ ...this.getBaseSettings(options),
68
81
  });
69
82
  }
70
83
 
84
+ /**
85
+ * @description Create Conversation view filter
86
+ * @param options
87
+ */
71
88
  public static createFilter(options: CreateFilterOptionsV1): Promise<FilterV1>;
72
89
  public static createFilter(options: CreateFilterOptions): Promise<Filter>;
73
- public static createFilter(options: CreateFilterOptions) {
90
+ public static createFilter({ isCommon, agentId, ...options }: CreateFilterOptions) {
74
91
  const route = this.getBaseUrl(options);
75
- const params = _.pick(options, ['isCommon', 'agentId']);
76
92
  const data = {
77
- ..._.pick(options, this.DEFAULT_FIELDS),
78
- version: _.get(options, this.FILTER_VERSION_FIELD),
93
+ ...Object.fromEntries(
94
+ Object.entries(options).filter(([key]) => this.DEFAULT_FIELDS.includes(key))
95
+ ),
96
+ version: options[this.FILTER_VERSION_FIELD],
79
97
  };
80
98
 
81
99
  return this.request({
82
100
  method: 'POST',
83
101
  route,
84
- params,
102
+ params: {
103
+ isCommon,
104
+ agentId,
105
+ },
85
106
  data,
107
+ ...this.getBaseSettings(options),
86
108
  });
87
109
  }
88
110
 
111
+ /**
112
+ * @description Update Conversation view filter
113
+ * @param options
114
+ */
89
115
  public static updateFilter(options: UpdateFilterOptionsV1): Promise<FilterV1>;
90
116
  public static updateFilter(options: UpdateFilterOptions): Promise<Filter>;
91
117
  public static updateFilter(options: UpdateFilterOptions) {
92
118
  const route = this.getBaseUrl(options);
93
119
  const data = {
94
- ..._.pick(options, ['id', ...this.DEFAULT_FIELDS]),
95
- version: _.get(options, this.FILTER_VERSION_FIELD),
120
+ ...Object.fromEntries(
121
+ Object.entries(options).filter(([key]) => [...this.DEFAULT_FIELDS, 'id'].includes(key))
122
+ ),
123
+ version: options[this.FILTER_VERSION_FIELD],
96
124
  };
97
125
 
98
126
  return this.request({
99
127
  method: 'PUT',
100
128
  route,
101
129
  data,
130
+ ...this.getBaseSettings(options),
102
131
  });
103
132
  }
104
133
 
134
+ /**
135
+ * @description Bulk update Conversation view filters ignoring userId for personal filters
136
+ * @param options
137
+ */
105
138
  public static bulkUpdateFilters(options: BulkUpdateFiltersOptionsV1): Promise<BulkUpdateFiltersResponseV1>;
106
139
  public static bulkUpdateFilters(options: BulkUpdateFiltersOptions): Promise<BulkUpdateFiltersResponse>;
107
- public static bulkUpdateFilters(options: BulkUpdateFiltersOptionsV1) {
140
+ // TODO: added ` & { filterVersion?: string; }` hack to make it build
141
+ public static bulkUpdateFilters(options: BulkUpdateFiltersOptionsV1 & { filterVersion?: string; }) {
108
142
  const baseUrl = this.getBaseUrl(options);
109
143
  const route = new URI(baseUrl).segment(this.BULK_URL).href();
110
144
  const data = {
111
- filters: options?.filters.map(filter =>
112
- ({
113
- ..._.pick(filter, ['id', ...this.DEFAULT_FIELDS]),
114
- version: _.get(options, this.FILTER_VERSION_FIELD),
115
- })
116
- ),
145
+ filters: options?.filters.map(filter => {
146
+ return {
147
+ ...Object.fromEntries(
148
+ Object.entries(filter).filter(([key]) => [...this.DEFAULT_FIELDS, 'id'].includes(key))
149
+ ),
150
+ version: options[this.FILTER_VERSION_FIELD],
151
+ };
152
+ }),
117
153
  };
118
154
 
119
155
  return this.request({
120
156
  method: 'PUT',
121
157
  route,
122
158
  data,
159
+ ...this.getBaseSettings(options),
123
160
  });
124
161
  }
125
162
 
163
+ /**
164
+ * @description Delete Conversation view filter
165
+ * @param options
166
+ */
126
167
  public static deleteFilter(options: DeleteFilterOptionsV1): Promise<GetFiltersResponseV1 | FilterV1>;
127
168
  public static deleteFilter(options: DeleteFilterOptions): Promise<GetFiltersResponse | Filter>;
128
- public static deleteFilter(
129
- options: DeleteFilterOptions
130
- ) {
169
+ public static deleteFilter({ id, ...options }: DeleteFilterOptions) {
131
170
  const route = this.getBaseUrl(options);
132
- const params = _.pick(options, ['id']);
133
171
 
134
172
  return this.request({
135
173
  method: 'DELETE',
136
174
  route,
137
- params,
175
+ params: { id },
176
+ ...this.getBaseSettings(options),
138
177
  });
139
178
  }
140
179
  }
@@ -37,4 +37,8 @@ export class HITLBase {
37
37
  };
38
38
  return this.format(this.BASE_URL, content);
39
39
  }
40
+
41
+ protected static getBaseSettings({ timeout }: BaseUrlOptions = {}) {
42
+ return { timeout };
43
+ }
40
44
  }
@@ -2,12 +2,17 @@ import URI from 'urijs';
2
2
 
3
3
  import { ApiVersionOptions } from '../types';
4
4
  import { CleanUpDuplicatesResponse } from '../types/helpers';
5
+
5
6
  import { HITLBase } from './HITLBase';
6
7
 
7
8
  export class Helpers extends HITLBase {
8
9
  protected static MODULE_URL = 'helpers';
9
10
  protected static CLEAN_CONTACTS = 'clean-contact-duplicates';
10
11
 
12
+ /**
13
+ * @description Delete Contact duplicates (Tables-based contacts v1)
14
+ * @param options
15
+ */
11
16
  public static async deleteContactDuplicates(
12
17
  options: ApiVersionOptions
13
18
  ): Promise<CleanUpDuplicatesResponse> {
@@ -17,6 +22,7 @@ export class Helpers extends HITLBase {
17
22
  return this.request({
18
23
  method: 'DELETE',
19
24
  route,
25
+ ...this.getBaseSettings(options),
20
26
  });
21
27
  }
22
28
  }
@@ -1,7 +1,6 @@
1
- import _ from 'lodash';
2
1
  import URI from 'urijs';
3
2
 
4
- import { HITLBase } from './HITLBase';
3
+ import { DEFAULT_OMIT_FIELDS } from '../constants';
5
4
  import {
6
5
  Listener,
7
6
  GetListenersOptions,
@@ -12,72 +11,109 @@ import {
12
11
  DeleteListenersOptions,
13
12
  } from '../types/listeners';
14
13
 
14
+ import { HITLBase } from './HITLBase';
15
+
16
+ /**
17
+ * HitL events Listener is an object describing a real-time Evnets callback -
18
+ * either an active WebSocket in Agent UI, flow event subscription callback or a
19
+ * mobile application push notification "callbacks"
20
+ */
15
21
  export class Listeners extends HITLBase {
16
22
  protected static MODULE_URL = 'listeners';
17
23
 
24
+ /**
25
+ * @description Get a list of HitL event listeners
26
+ * @param options
27
+ */
18
28
  public static async getListeners(
19
29
  options: GetListenersOptions = {}
20
30
  ): Promise<GetListenersResponse> {
21
31
  const route = this.getBaseUrl(options);
22
- const params = _.omit(options, ['version']);
32
+ const params = Object.fromEntries(
33
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
34
+ );
23
35
 
24
36
  return this.request({
25
37
  method: 'GET',
26
38
  route,
27
39
  params,
40
+ ...this.getBaseSettings(options),
28
41
  });
29
42
  }
30
43
 
44
+ /**
45
+ * @description Get HitL event listeners by id
46
+ * @param options
47
+ */
31
48
  public static async getListenerById(
32
- options: GetListenerByIdOptions
49
+ { agentId, callbackId, ...options }: GetListenerByIdOptions
33
50
  ): Promise<GetListenersResponse> {
34
51
  const baseUrl = this.getBaseUrl(options);
35
- const route = new URI(baseUrl).segment(options.callbackId).href();
36
- const params = _.pick(options, ['agentId']);
52
+ const route = new URI(baseUrl).segment(callbackId).href();
37
53
 
38
54
  return this.request({
39
55
  method: 'GET',
40
56
  route,
41
- params,
57
+ params: { agentId },
58
+ ...this.getBaseSettings(options),
42
59
  });
43
60
  }
44
61
 
62
+ /**
63
+ * @description Create HitL event listener
64
+ * @param options
65
+ */
45
66
  public static async createListener(
46
67
  options: CreateListenersOptions
47
68
  ): Promise<Listener> {
48
69
  const route = this.getBaseUrl(options);
49
- const data = _.omit(options, ['version']);
70
+ const data = Object.fromEntries(
71
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
72
+ );
50
73
 
51
74
  return this.request({
52
75
  method: 'POST',
53
76
  route,
54
77
  data,
78
+ ...this.getBaseSettings(options),
55
79
  });
56
80
  }
57
81
 
82
+ /**
83
+ * @description Update HitL event listener
84
+ * @param options
85
+ */
58
86
  public static async updateListener(
59
- options: UpdateListenersOptions
87
+ { callbackId, ...options }: UpdateListenersOptions
60
88
  ): Promise<Listener> {
61
89
  const baseUrl = this.getBaseUrl(options);
62
- const route = new URI(baseUrl).segment(options.callbackId).href();
63
- const data = _.omit(options, ['callbackId', 'version']);
90
+ const route = new URI(baseUrl).segment(callbackId).href();
91
+ const data = Object.fromEntries(
92
+ Object.entries(options).filter(([key]) => !DEFAULT_OMIT_FIELDS.includes(key))
93
+ );
64
94
 
65
95
  return this.request({
66
96
  method: 'PUT',
67
97
  route,
68
98
  data,
99
+ ...this.getBaseSettings(options),
69
100
  });
70
101
  }
71
102
 
103
+ /**
104
+ * @description Delete HitL event listener
105
+ * @param options
106
+ */
72
107
  public static async deleteListener(
73
- options: DeleteListenersOptions
108
+ { callbackId, ...options }: DeleteListenersOptions
74
109
  ): Promise<void> {
75
110
  const baseUrl = this.getBaseUrl(options);
76
- const route = new URI(baseUrl).segment(options.callbackId).href();
111
+ const route = new URI(baseUrl).segment(callbackId).href();
77
112
 
78
113
  return this.request({
79
114
  method: 'DELETE',
80
115
  route,
116
+ ...this.getBaseSettings(options),
81
117
  });
82
118
  }
83
119
  }