@docbrasil/api-systemmanager 1.0.107 → 1.0.109

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 (73) hide show
  1. package/.github/workflows/static.yml +43 -0
  2. package/api/external.js +41 -0
  3. package/dist/bundle.cjs +41 -0
  4. package/dist/bundle.mjs +1 -1
  5. package/doc/api.md +382 -0
  6. package/docs/Admin.html +336 -0
  7. package/docs/AdminDocuments.html +2235 -0
  8. package/docs/AdminForm.html +934 -0
  9. package/docs/AdminLists.html +895 -0
  10. package/docs/AdminMessage.html +1490 -0
  11. package/docs/AdminNotification.html +1636 -0
  12. package/docs/AdminPlugin.html +696 -0
  13. package/docs/AdminPolicy.html +451 -0
  14. package/docs/AdminProcesses.html +692 -0
  15. package/docs/AdminTask.html +740 -0
  16. package/docs/AdminUser.html +1203 -0
  17. package/docs/Datasource.html +660 -0
  18. package/docs/Dispatch.html +624 -0
  19. package/docs/Documents.html +4875 -0
  20. package/docs/External.html +1497 -0
  21. package/docs/GeoLocation.html +503 -0
  22. package/docs/Login.html +1839 -0
  23. package/docs/Notification.html +625 -0
  24. package/docs/Organization.html +2767 -0
  25. package/docs/Process.html +1598 -0
  26. package/docs/Register.html +1604 -0
  27. package/docs/Session.html +482 -0
  28. package/docs/Task.html +1394 -0
  29. package/docs/TaskAvailable.html +893 -0
  30. package/docs/User.html +2002 -0
  31. package/docs/Users.html +569 -0
  32. package/docs/admin_doctypes.js.html +193 -0
  33. package/docs/admin_document.js.html +449 -0
  34. package/docs/admin_form.js.html +268 -0
  35. package/docs/admin_index.js.html +163 -0
  36. package/docs/admin_list.js.html +250 -0
  37. package/docs/admin_message.js.html +311 -0
  38. package/docs/admin_notification.js.html +350 -0
  39. package/docs/admin_organization.js.html +241 -0
  40. package/docs/admin_plugin.js.html +233 -0
  41. package/docs/admin_policy.js.html +195 -0
  42. package/docs/admin_processes.js.html +487 -0
  43. package/docs/admin_task.js.html +242 -0
  44. package/docs/admin_user.js.html +302 -0
  45. package/docs/dispatch.js.html +218 -0
  46. package/docs/external.js.html +333 -0
  47. package/docs/general_geoLocation.js.html +205 -0
  48. package/docs/general_index.js.html +140 -0
  49. package/docs/index.html +129 -0
  50. package/docs/login.js.html +384 -0
  51. package/docs/scripts/app.min.js +1 -0
  52. package/docs/scripts/linenumber.js +26 -0
  53. package/docs/scripts/search.js +39 -0
  54. package/docs/session.js.html +202 -0
  55. package/docs/styles/app.min.css +1 -0
  56. package/docs/styles/iframe.css +13 -0
  57. package/docs/styles/prettify-jsdoc.css +111 -0
  58. package/docs/styles/prettify-tomorrow.css +132 -0
  59. package/docs/styles/reset.css +44 -0
  60. package/docs/user_datasource.js.html +261 -0
  61. package/docs/user_document.js.html +847 -0
  62. package/docs/user_index.js.html +156 -0
  63. package/docs/user_notification.js.html +218 -0
  64. package/docs/user_organization.js.html +347 -0
  65. package/docs/user_process.js.html +352 -0
  66. package/docs/user_register.js.html +322 -0
  67. package/docs/user_task.js.html +319 -0
  68. package/docs/user_task_available.js.html +252 -0
  69. package/docs/user_user.js.html +404 -0
  70. package/docs/utils_promises.js.html +235 -0
  71. package/package.json +7 -4
  72. package/readme.md +7 -8
  73. package/doc.md +0 -653
@@ -0,0 +1,319 @@
1
+
2
+
3
+ <!DOCTYPE html>
4
+ <html lang="en">
5
+
6
+ <head>
7
+
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+ <title> user/task.js</title>
11
+
12
+ <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
13
+ <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
14
+ <script src="./build/entry.js"></script>
15
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
16
+ <!--[if lt IE 9]>
17
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
18
+ <![endif]-->
19
+ <link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
20
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
21
+ <link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
22
+ <link type="text/css" rel="stylesheet" href="styles/app.min.css">
23
+ <link type="text/css" rel="stylesheet" href="styles/iframe.css">
24
+ <link type="text/css" rel="stylesheet" href="">
25
+ <script async defer src="https://buttons.github.io/buttons.js"></script>
26
+
27
+
28
+ </head>
29
+
30
+
31
+
32
+ <body class="layout small-header">
33
+ <div id="stickyNavbarOverlay"></div>
34
+
35
+
36
+ <div class="top-nav">
37
+ <div class="inner">
38
+ <a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
39
+ <span aria-hidden="true"></span>
40
+ <span aria-hidden="true"></span>
41
+ <span aria-hidden="true"></span>
42
+ </a>
43
+ <div class="logo">
44
+
45
+
46
+ </div>
47
+ <div class="menu">
48
+
49
+ <div class="navigation">
50
+ <a
51
+ href="index.html"
52
+ class="link"
53
+ >
54
+ Documentation
55
+ </a>
56
+
57
+
58
+
59
+ </div>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ <div id="main">
64
+ <div
65
+ class="sidebar "
66
+ id="sidebarNav"
67
+ >
68
+
69
+ <nav>
70
+
71
+ <h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="Admin.html">Admin</a></li><li><a href="AdminDocuments.html">AdminDocuments</a></li><li><a href="AdminForm.html">AdminForm</a></li><li><a href="AdminLists.html">AdminLists</a></li><li><a href="AdminMessage.html">AdminMessage</a></li><li><a href="AdminNotification.html">AdminNotification</a></li><li><a href="AdminPlugin.html">AdminPlugin</a></li><li><a href="AdminPolicy.html">AdminPolicy</a></li><li><a href="AdminProcesses.html">AdminProcesses</a></li><li><a href="AdminTask.html">AdminTask</a></li><li><a href="AdminUser.html">AdminUser</a></li><li><a href="Datasource.html">Datasource</a></li><li><a href="Dispatch.html">Dispatch</a></li><li><a href="Documents.html">Documents</a></li><li><a href="External.html">External</a></li><li><a href="GeoLocation.html">GeoLocation</a></li><li><a href="Login.html">Login</a></li><li><a href="Notification.html">Notification</a></li><li><a href="Organization.html">Organization</a></li><li><a href="Process.html">Process</a></li><li><a href="Register.html">Register</a></li><li><a href="Session.html">Session</a></li><li><a href="Task.html">Task</a></li><li><a href="TaskAvailable.html">TaskAvailable</a></li><li><a href="User.html">User</a></li><li><a href="Users.html">Users</a></li></ul></div>
72
+
73
+ </nav>
74
+ </div>
75
+ <div class="core" id="main-content-wrapper">
76
+ <div class="content">
77
+ <header class="page-title">
78
+ <p>Source</p>
79
+ <h1>user/task.js</h1>
80
+ </header>
81
+
82
+
83
+
84
+
85
+
86
+ <section>
87
+ <article>
88
+ <pre class="prettyprint source linenums"><code>import _ from 'lodash';
89
+ import Boom from '@hapi/boom';
90
+ import Joi from 'joi';
91
+ import TaskAvailable from './task_available.js';
92
+
93
+ /**
94
+ * Class for task, permission user
95
+ * @class
96
+ */
97
+ class Task {
98
+
99
+ constructor(options) {
100
+ Joi.assert(options, Joi.object().required());
101
+ Joi.assert(options.parent, Joi.object().required());
102
+
103
+ const self = this;
104
+ self.parent = options.parent;
105
+ self._client = self.parent.dispatch.getClient();
106
+ self.available = new TaskAvailable(options);
107
+ }
108
+
109
+ /**
110
+ * @author Augusto Pissarra &lt;abernardo.br@gmail.com>
111
+ * @description Get the return data and check for errors
112
+ * @param {object} retData Response HTTP
113
+ * @return {*}
114
+ * @private
115
+ */
116
+ _returnData(retData, def = {}) {
117
+ if (retData.status !== 200) {
118
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
119
+ } else {
120
+ return _.get(retData, 'data', def);
121
+ }
122
+ }
123
+
124
+ /**
125
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
126
+ * @description Set header with new session
127
+ * @param {string} session Session, token JWT
128
+ * @return {object} header with new session
129
+ * @private
130
+ */
131
+ _setHeader(session) {
132
+ return {
133
+ headers: {
134
+ authorization: session,
135
+ }
136
+ };
137
+ }
138
+
139
+ /**
140
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
141
+ * @description Method to find task by id
142
+ * @param {object} params Params to get task
143
+ * @param {object} params.processId Proccess id (_id database)
144
+ * @param {object} params.taskId Task id (_id database)
145
+ * @param {object} params.orgId Organization id (_id database)
146
+ * @param {string} session Session, token JWT
147
+ * @returns {promise}
148
+ * @public
149
+ * @example
150
+ *
151
+ * const API = require('@docbrasil/api-systemmanager');
152
+ * const api = new API();
153
+ * const params = {
154
+ * processId: '5dadd01dc4af3941d42f8c5c',
155
+ * taskId: '5df7f19618430c89a41a19d2',
156
+ * orgId: '55e4a3bd6be6b45210833fae',
157
+ * };
158
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
159
+ * await api.user.task.findById(params, session);
160
+ */
161
+ async findById(params, session) {
162
+ const self = this;
163
+
164
+ try {
165
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
166
+ Joi.assert(params.processId, Joi.string().required(), ' Proccess id (_id database)');
167
+ Joi.assert(params.taskId, Joi.string().required(), ' Task id (_id database)');
168
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
169
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
170
+
171
+ const {processId, taskId, orgId} = params;
172
+ const apiCall = self._client
173
+ .get(`/organizations/${orgId}/process/${processId}/execute/${taskId}`, self._setHeader(session));
174
+
175
+ return self._returnData(await apiCall);
176
+ } catch (ex) {
177
+ throw ex;
178
+ }
179
+ }
180
+
181
+ /**
182
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
183
+ * @description Find task by id and update
184
+ * @param {object} params Params to update task
185
+ * @param {object} params.userId User id (_id database)
186
+ * @param {string} params.processId Proccess id (_id database)
187
+ * @param {string} params.taskId Task id (_id database)
188
+ * @param {string} params.flowName Flow name
189
+ * @param {string} params.action Button action
190
+ * @param {object} params.formData Data to update task
191
+ * @param {string=} params.actionGuid GUID of the action
192
+ * @param {string} params.orgId Organization id (_id database)
193
+ * @param {string} session Session, token JWT
194
+ * @return {Promise}
195
+ * @public
196
+ * @async
197
+ * @example
198
+ *
199
+ * const API = require('@docbrasil/api-systemmanager');
200
+ * const api = new API();
201
+ * const params = {
202
+ * userId: '5739d4c6ccb0ebc61f2a9557',
203
+ * processId: '5dadd01dc4af3941d42f8c5c',
204
+ * taskId: '5df7f19618430c89a41a19d2',
205
+ * action: 1,
206
+ * formData: {name: 'CloudBrasil'},
207
+ * };
208
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
209
+ * await api.user.task.findByIdAndUpdate(params, session);
210
+ */
211
+ async findByIdAndUpdate(params, session) {
212
+ const self = this;
213
+
214
+
215
+ try {
216
+ Joi.assert(params, Joi.object().required());
217
+ Joi.assert(params.userId, Joi.string().required(), 'User id (_id database)');
218
+ Joi.assert(params.processId, Joi.string().required(), 'Proccess id (_id database)');
219
+ Joi.assert(params.taskId, Joi.string().required(), 'Task id (_id database)');
220
+ Joi.assert(params.flowName, Joi.string().required(), 'Flow name');
221
+ Joi.assert(params.action, Joi.number().required(), 'Button action');
222
+ Joi.assert(params.formData, Joi.object().required(), 'Data to update task');
223
+ Joi.assert(params.actionGuid, Joi.string(), 'GUID of the action');
224
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
225
+ Joi.assert(params.contextToBody, Joi.string(), 'Context to body');
226
+
227
+ const {processId, taskId, flowName, action, actionGuid, formData, orgId, contextToBody} = params;
228
+ const body = contextToBody ? {[contextToBody]: formData} : {...formData};
229
+
230
+ const getUrl = {
231
+ 0: () => `organizations/${orgId}/users/tasks/${taskId}/action/${actionGuid}`,
232
+ 1: () => `organizations/${orgId}/adhoc/${processId}/save/${taskId}/${flowName}`,
233
+ 2: () => `organizations/${orgId}/adhoc/${processId}/endprocess/${taskId}/${flowName}`
234
+ };
235
+ const url = getUrl[action]();
236
+ const apiCall = self._client.put(url, body, self._setHeader(session));
237
+ return self._returnData(await apiCall);
238
+ } catch (ex) {
239
+ throw ex;
240
+ }
241
+ }
242
+
243
+ /**
244
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
245
+ * @description Find task by id and update
246
+ * @param {!object} params Params - to update task
247
+ * @param {!string} params.taskId - Task id (_id database)
248
+ * @param {!string} params.actionGuid - GUID of the action
249
+ * @param {!string} params.orgId - Organization id (_id database)
250
+ * @param {any} params.payload={} - Payload to send in action
251
+ * @param {string} session Session, token JWT
252
+ * @return {Promise}
253
+ * @public
254
+ * @async
255
+ * @example
256
+ *
257
+ * const API = require('@docbrasil/api-systemmanager');
258
+ * const api = new API();
259
+ * const params = {
260
+ * taskId: '5df7f19618430c89a41a19d2',
261
+ * actionGuid: 'b3823a2ae52c7a05bfb9590fe427038d'
262
+ * orgId: '5df7f19618430c89a41a1bc3',
263
+ * payload: {}',
264
+ * };
265
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
266
+ * await api.user.task.executeActionFinalize(params, session);
267
+ */
268
+ async executeActionFinalize(params, session) {
269
+ const self = this;
270
+
271
+ try {
272
+ Joi.assert(params, Joi.object().required());
273
+ Joi.assert(params.taskId, Joi.string().required(), 'Task id (_id database)');
274
+ Joi.assert(params.actionGuid, Joi.string(), 'GUID of the action');
275
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
276
+ Joi.assert(params.payload, Joi.any(), 'Payload to send in action');
277
+
278
+ const {taskId, actionGuid, orgId, payload = {}} = params;
279
+ const url = `organizations/${orgId}/users/tasks/${taskId}/action/${actionGuid}`;
280
+ const apiCall = self._client.put(url, payload, self._setHeader(session));
281
+
282
+ return self._returnData(await apiCall);
283
+ } catch (ex) {
284
+ throw ex;
285
+ }
286
+ }
287
+ }
288
+
289
+ export default Task;
290
+ </code></pre>
291
+ </article>
292
+ </section>
293
+
294
+
295
+
296
+
297
+ </div>
298
+
299
+ <footer class="footer">
300
+ <div class="content has-text-centered">
301
+ <p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
302
+ <p class="sidebar-created-by">
303
+ <a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
304
+ <a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
305
+ </p>
306
+ </div>
307
+ </footer>
308
+
309
+ </div>
310
+ <div id="side-nav" class="side-nav">
311
+ </div>
312
+ </div>
313
+ <script src="scripts/app.min.js"></script>
314
+ <script>PR.prettyPrint();</script>
315
+ <script src="scripts/linenumber.js"> </script>
316
+
317
+
318
+ </body>
319
+ </html>
@@ -0,0 +1,252 @@
1
+
2
+
3
+ <!DOCTYPE html>
4
+ <html lang="en">
5
+
6
+ <head>
7
+
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+ <title> user/task_available.js</title>
11
+
12
+ <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
13
+ <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
14
+ <script src="./build/entry.js"></script>
15
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
16
+ <!--[if lt IE 9]>
17
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
18
+ <![endif]-->
19
+ <link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
20
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
21
+ <link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
22
+ <link type="text/css" rel="stylesheet" href="styles/app.min.css">
23
+ <link type="text/css" rel="stylesheet" href="styles/iframe.css">
24
+ <link type="text/css" rel="stylesheet" href="">
25
+ <script async defer src="https://buttons.github.io/buttons.js"></script>
26
+
27
+
28
+ </head>
29
+
30
+
31
+
32
+ <body class="layout small-header">
33
+ <div id="stickyNavbarOverlay"></div>
34
+
35
+
36
+ <div class="top-nav">
37
+ <div class="inner">
38
+ <a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
39
+ <span aria-hidden="true"></span>
40
+ <span aria-hidden="true"></span>
41
+ <span aria-hidden="true"></span>
42
+ </a>
43
+ <div class="logo">
44
+
45
+
46
+ </div>
47
+ <div class="menu">
48
+
49
+ <div class="navigation">
50
+ <a
51
+ href="index.html"
52
+ class="link"
53
+ >
54
+ Documentation
55
+ </a>
56
+
57
+
58
+
59
+ </div>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ <div id="main">
64
+ <div
65
+ class="sidebar "
66
+ id="sidebarNav"
67
+ >
68
+
69
+ <nav>
70
+
71
+ <h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="Admin.html">Admin</a></li><li><a href="AdminDocuments.html">AdminDocuments</a></li><li><a href="AdminForm.html">AdminForm</a></li><li><a href="AdminLists.html">AdminLists</a></li><li><a href="AdminMessage.html">AdminMessage</a></li><li><a href="AdminNotification.html">AdminNotification</a></li><li><a href="AdminPlugin.html">AdminPlugin</a></li><li><a href="AdminPolicy.html">AdminPolicy</a></li><li><a href="AdminProcesses.html">AdminProcesses</a></li><li><a href="AdminTask.html">AdminTask</a></li><li><a href="AdminUser.html">AdminUser</a></li><li><a href="Datasource.html">Datasource</a></li><li><a href="Dispatch.html">Dispatch</a></li><li><a href="Documents.html">Documents</a></li><li><a href="External.html">External</a></li><li><a href="GeoLocation.html">GeoLocation</a></li><li><a href="Login.html">Login</a></li><li><a href="Notification.html">Notification</a></li><li><a href="Organization.html">Organization</a></li><li><a href="Process.html">Process</a></li><li><a href="Register.html">Register</a></li><li><a href="Session.html">Session</a></li><li><a href="Task.html">Task</a></li><li><a href="TaskAvailable.html">TaskAvailable</a></li><li><a href="User.html">User</a></li><li><a href="Users.html">Users</a></li></ul></div>
72
+
73
+ </nav>
74
+ </div>
75
+ <div class="core" id="main-content-wrapper">
76
+ <div class="content">
77
+ <header class="page-title">
78
+ <p>Source</p>
79
+ <h1>user/task_available.js</h1>
80
+ </header>
81
+
82
+
83
+
84
+
85
+
86
+ <section>
87
+ <article>
88
+ <pre class="prettyprint source linenums"><code>import _ from 'lodash';
89
+ import Boom from '@hapi/boom';
90
+ import Joi from 'joi';
91
+
92
+ /**
93
+ * Class for available tasks, permission user
94
+ * @class
95
+ */
96
+ class TaskAvailable {
97
+
98
+ constructor(options) {
99
+ Joi.assert(options, Joi.object().required());
100
+ Joi.assert(options.parent, Joi.object().required());
101
+
102
+ const self = this;
103
+ self.parent = options.parent;
104
+ self._client = self.parent.dispatch.getClient();
105
+ }
106
+
107
+ /**
108
+ * @author Augusto Pissarra &lt;abernardo.br@gmail.com>
109
+ * @description Get the return data and check for errors
110
+ * @param {object} retData Response HTTP
111
+ * @return {*}
112
+ * @private
113
+ */
114
+ _returnData(retData, def = {}) {
115
+ if (retData.status !== 200) {
116
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
117
+ } else {
118
+ return _.get(retData, 'data', def);
119
+ }
120
+ }
121
+
122
+ /**
123
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
124
+ * @description Set header with new session
125
+ * @param {string} session Session, token JWT
126
+ * @return {object} header with new session
127
+ * @private
128
+ */
129
+ _setHeader(session) {
130
+ return {
131
+ headers: {
132
+ authorization: session,
133
+ }
134
+ };
135
+ }
136
+
137
+ /**
138
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
139
+ * @description Method to find available tasks for a user
140
+ * @param {object} params Params to get task
141
+ * @param {object} params.query Search available tasks query
142
+ * @param {object} params.orgId Organization id (_id database)
143
+ * @param {string} session Session, token JWT
144
+ * @returns {promise} returned data from the search
145
+ * @returns {number} count the count of items searched
146
+ * @returns {array&lt;object>} items the items returned from search
147
+ * @returns {number} page the page of the search (on pagination), zero indexed
148
+ * @returns {number} perPage how many items per page
149
+ * @public
150
+ * @example
151
+ *
152
+ * const API = require('@docbrasil/api-systemmanager');
153
+ * const api = new API();
154
+ * const params = {
155
+ * query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
156
+ * orgId: '55e4a3bd6be6b45210833fae',
157
+ * };
158
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
159
+ * const retSearch = await api.user.task.available.find(params, session);
160
+ */
161
+ async find(params, session) {
162
+ const self = this;
163
+
164
+ try {
165
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
166
+ Joi.assert(params.query, Joi.object().required(), 'The query for the search');
167
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
168
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
169
+
170
+ const {query, orgId} = params;
171
+ const queryString = JSON.stringify(query);
172
+ const apiCall = self._client
173
+ .post(`/organizations/${orgId}/users/tasks/groups/advsearch?query=${queryString}`, {}, self._setHeader(session));
174
+
175
+ return self._returnData(await apiCall);
176
+ } catch (ex) {
177
+ throw ex;
178
+ }
179
+ }
180
+
181
+ /**
182
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
183
+ * @description Method for a user to claim an available task
184
+ * @param {object} params Params to get task
185
+ * @param {object} params.taskId the task id to claim
186
+ * @param {object} params.orgname Organization slug (short name of the orgnization)
187
+ * @param {string} session Session, token JWT
188
+ * @returns {promise} returned data from the method call
189
+ * @returns {boolean} success true|false if the method was successful
190
+ * @public
191
+ * @example
192
+ *
193
+ * const API = require('@docbrasil/api-systemmanager');
194
+ * const api = new API();
195
+ * const params = {
196
+ * taskId: '55e4a3bd6be6b45210833f67',
197
+ * orgname: 'acme',
198
+ * };
199
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
200
+ * const success = await api.user.task.available.claim(params, session);
201
+ */
202
+ async claim(params, session) {
203
+ const self = this;
204
+
205
+ try {
206
+ Joi.assert(params, Joi.object().required(), 'Params to claim the task');
207
+ Joi.assert(params.taskId, Joi.string().required(), 'The task id to claim');
208
+ Joi.assert(params.orgname, Joi.string().required(), 'The slug of the organization');
209
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
210
+
211
+ const {taskId, orgname} = params;
212
+ const apiCall = self._client
213
+ .put(`/organizations/${orgname}/users/tasks/${taskId}/claim`, {}, self._setHeader(session));
214
+
215
+ return self._returnData(await apiCall);
216
+ } catch (ex) {
217
+ throw ex;
218
+ }
219
+ }
220
+ }
221
+
222
+ export default TaskAvailable;
223
+ </code></pre>
224
+ </article>
225
+ </section>
226
+
227
+
228
+
229
+
230
+ </div>
231
+
232
+ <footer class="footer">
233
+ <div class="content has-text-centered">
234
+ <p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
235
+ <p class="sidebar-created-by">
236
+ <a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
237
+ <a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
238
+ </p>
239
+ </div>
240
+ </footer>
241
+
242
+ </div>
243
+ <div id="side-nav" class="side-nav">
244
+ </div>
245
+ </div>
246
+ <script src="scripts/app.min.js"></script>
247
+ <script>PR.prettyPrint();</script>
248
+ <script src="scripts/linenumber.js"> </script>
249
+
250
+
251
+ </body>
252
+ </html>