@docbrasil/api-systemmanager 1.0.106 → 1.0.108

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 (76) hide show
  1. package/.github/workflows/static.yml +43 -0
  2. package/api/external.js +41 -0
  3. package/api/user/process.js +44 -0
  4. package/api/user/task.js +1 -0
  5. package/api/user/task_available.js +1 -1
  6. package/dist/bundle.cjs +87 -1
  7. package/dist/bundle.mjs +1 -1
  8. package/doc/api.md +412 -1
  9. package/docs/Admin.html +336 -0
  10. package/docs/AdminDocuments.html +2235 -0
  11. package/docs/AdminForm.html +934 -0
  12. package/docs/AdminLists.html +895 -0
  13. package/docs/AdminMessage.html +1490 -0
  14. package/docs/AdminNotification.html +1636 -0
  15. package/docs/AdminPlugin.html +696 -0
  16. package/docs/AdminPolicy.html +451 -0
  17. package/docs/AdminProcesses.html +692 -0
  18. package/docs/AdminTask.html +740 -0
  19. package/docs/AdminUser.html +1203 -0
  20. package/docs/Datasource.html +660 -0
  21. package/docs/Dispatch.html +624 -0
  22. package/docs/Documents.html +4875 -0
  23. package/docs/External.html +1203 -0
  24. package/docs/GeoLocation.html +503 -0
  25. package/docs/Login.html +1839 -0
  26. package/docs/Notification.html +625 -0
  27. package/docs/Organization.html +2767 -0
  28. package/docs/Process.html +1598 -0
  29. package/docs/Register.html +1604 -0
  30. package/docs/Session.html +482 -0
  31. package/docs/Task.html +1394 -0
  32. package/docs/TaskAvailable.html +893 -0
  33. package/docs/User.html +2002 -0
  34. package/docs/Users.html +569 -0
  35. package/docs/admin_doctypes.js.html +193 -0
  36. package/docs/admin_document.js.html +449 -0
  37. package/docs/admin_form.js.html +268 -0
  38. package/docs/admin_index.js.html +163 -0
  39. package/docs/admin_list.js.html +250 -0
  40. package/docs/admin_message.js.html +311 -0
  41. package/docs/admin_notification.js.html +350 -0
  42. package/docs/admin_organization.js.html +241 -0
  43. package/docs/admin_plugin.js.html +233 -0
  44. package/docs/admin_policy.js.html +195 -0
  45. package/docs/admin_processes.js.html +487 -0
  46. package/docs/admin_task.js.html +242 -0
  47. package/docs/admin_user.js.html +302 -0
  48. package/docs/dispatch.js.html +218 -0
  49. package/docs/external.js.html +333 -0
  50. package/docs/general_geoLocation.js.html +205 -0
  51. package/docs/general_index.js.html +140 -0
  52. package/docs/index.html +129 -0
  53. package/docs/login.js.html +384 -0
  54. package/docs/scripts/app.min.js +1 -0
  55. package/docs/scripts/linenumber.js +26 -0
  56. package/docs/scripts/search.js +39 -0
  57. package/docs/session.js.html +202 -0
  58. package/docs/styles/app.min.css +1 -0
  59. package/docs/styles/iframe.css +13 -0
  60. package/docs/styles/prettify-jsdoc.css +111 -0
  61. package/docs/styles/prettify-tomorrow.css +132 -0
  62. package/docs/styles/reset.css +44 -0
  63. package/docs/user_datasource.js.html +261 -0
  64. package/docs/user_document.js.html +847 -0
  65. package/docs/user_index.js.html +156 -0
  66. package/docs/user_notification.js.html +218 -0
  67. package/docs/user_organization.js.html +347 -0
  68. package/docs/user_process.js.html +352 -0
  69. package/docs/user_register.js.html +322 -0
  70. package/docs/user_task.js.html +319 -0
  71. package/docs/user_task_available.js.html +252 -0
  72. package/docs/user_user.js.html +404 -0
  73. package/docs/utils_promises.js.html +235 -0
  74. package/package.json +7 -4
  75. package/readme.md +7 -8
  76. package/doc.md +0 -653
@@ -0,0 +1,242 @@
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> admin/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>admin/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
+
92
+ /**
93
+ * Admin Class for task, permission admin
94
+ * @class
95
+ */
96
+ class AdminTask {
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 Get filter to search tasks
140
+ * @param {string} filter Filter type
141
+ * @return {*}
142
+ * @private
143
+ */
144
+ _taskFilters(filter) {
145
+ const taskFilters = {
146
+ CLEAN: 1,
147
+ EXECUTED: 2,
148
+ PENDING: 3,
149
+ LATE: 4,
150
+ NOT_DONE: 5,
151
+ DONE: 6
152
+ };
153
+ return _.get(taskFilters, filter, 'NOT_DONE');
154
+ }
155
+
156
+ /**
157
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
158
+ * @description Get task by user Id
159
+ * @param {object} params Params to get task
160
+ * @param {string} params.userId User id (_id database)
161
+ * @param {string} [params.filter=NOT_DONE] Filter type CLEAN | EXECUTED | PENDING | LATE | NOT_DONE | DONE
162
+
163
+ * @param {object} params.project Project to return
164
+ * @param {boolean} params.project.returnProcessProperties Return process properties
165
+ * @param {boolean} params.project.returnInitParams Return init params
166
+
167
+ * @param {string} params.userId User id (_id database)
168
+ * @param {boolean} [params.includeOwner=false] Include owner true | false
169
+ * @param {string} session Session, token JWT
170
+ * @public
171
+ * @async
172
+ * @example
173
+ *
174
+ * const API = require('@docbrasil/api-systemmanager');
175
+ * const api = new API();
176
+ * const params = {
177
+ * userId: '55e4a3bd6be6b45210833fae',
178
+ * };
179
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
180
+ * await api.admin.task.find(params, session);
181
+ */
182
+ async find(params, session) {
183
+ const self = this;
184
+
185
+ try {
186
+ Joi.assert(params, Joi.object().required());
187
+ Joi.assert(params.userId, Joi.string().required());
188
+ Joi.assert(params.filter, Joi.string());
189
+ Joi.assert(params.project, Joi.object());
190
+ Joi.assert(params.includeOwner, Joi.boolean());
191
+ Joi.assert(session, Joi.string().required());
192
+
193
+ const filterType = _.get(params, 'filter', 'NOT_DONE') || 'NOT_DONE';
194
+ const includeOwner = _.get(params, 'includeOwner', false) || false;
195
+ const {userId} = params;
196
+ const filter = self._taskFilters(filterType);
197
+ const { returnProcessProperties, returnInitParams } = params?.project ?? {};
198
+
199
+ let queryString = `taskFilter=${filter}&amp;includeOwner=${includeOwner}`;
200
+
201
+ if (returnProcessProperties) queryString = `${queryString}&amp;returnProcessProperties=${returnProcessProperties}`;
202
+ if (returnInitParams) queryString = `${queryString}&amp;returnInitParams=${returnInitParams}`;
203
+
204
+ const apiCall = self._client.get(`/admin/users/${userId}/tasks?${queryString}`, self._setHeader(session));
205
+ return self._returnData(await apiCall);
206
+ } catch (ex) {
207
+ throw ex;
208
+ }
209
+ }
210
+ }
211
+
212
+ export default AdminTask;
213
+ </code></pre>
214
+ </article>
215
+ </section>
216
+
217
+
218
+
219
+
220
+ </div>
221
+
222
+ <footer class="footer">
223
+ <div class="content has-text-centered">
224
+ <p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
225
+ <p class="sidebar-created-by">
226
+ <a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
227
+ <a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
228
+ </p>
229
+ </div>
230
+ </footer>
231
+
232
+ </div>
233
+ <div id="side-nav" class="side-nav">
234
+ </div>
235
+ </div>
236
+ <script src="scripts/app.min.js"></script>
237
+ <script>PR.prettyPrint();</script>
238
+ <script src="scripts/linenumber.js"> </script>
239
+
240
+
241
+ </body>
242
+ </html>
@@ -0,0 +1,302 @@
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> admin/user.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>admin/user.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
+ * Admin Class for user, permission admin
94
+ * @class
95
+ */
96
+ class AdminUser {
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 CloudBrasil &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 Request profile by userId
140
+ * @param {string} userId User identifier (_id database)
141
+ * @param {string} session Is token JWT
142
+ * @return {Promise}
143
+ * @public
144
+ * @async
145
+ * @example
146
+ *
147
+ * const API = require('@docbrasil/api-systemmanager');
148
+ * const api = new API();
149
+ * const userId = '55e4a3bd6be6b45210833fae';
150
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
151
+ * await api.admin.user.findById(userId, session);
152
+ */
153
+ async findById(userId, session) {
154
+ const self = this;
155
+
156
+ try {
157
+
158
+ Joi.assert(userId, Joi.string().required());
159
+ Joi.assert(session, Joi.string().required());
160
+
161
+ const apiCall = self.client.get(`/admin/users/${userId}`, self._setHeader(session));
162
+ return self._returnData(await apiCall);
163
+ } catch (ex) {
164
+ throw ex;
165
+ }
166
+ }
167
+
168
+ /**
169
+ * @author CloudBrasil &lt;abernardo.br@gmail.com>
170
+ * @description Update password by userId
171
+ * @param {object} params Params to update password
172
+ * @param {string} params.userId Id of the user
173
+ * @param {string} params.oldPassword Old password
174
+ * @param {string} params.newPassword New password
175
+ * @param {string} session Is token JWT
176
+ * @return {Promise&lt;unknown>}
177
+ * @public
178
+ * @async
179
+ * @example
180
+ *
181
+ * const API = require('@docbrasil/api-systemmanager');
182
+ * const api = new API();
183
+ * const params = {
184
+ * userId: '55e4a3bd6be6b45210833fae',
185
+ * oldPassword: '123456',
186
+ * newPassword: '123456789'
187
+ * };
188
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
189
+ * await api.admin.user.findByIdAndUpdatePassword(params, session);
190
+ */
191
+ async findByIdAndUpdatePassword(params, session) {
192
+ const self = this;
193
+
194
+ try {
195
+ Joi.assert(params, Joi.object().required());
196
+ Joi.assert(params.userId, Joi.string().required());
197
+ Joi.assert(params.oldPassword, Joi.string().required());
198
+ Joi.assert(params.newPassword, Joi.string().required());
199
+ Joi.assert(session, Joi.string().required());
200
+
201
+ const {userId, ...payload} = params;
202
+ const apiCall = self.client.put(`/admin/users/${userId}/password`, payload, self._setHeader(session));
203
+ return self._returnData(await apiCall);
204
+ } catch (ex) {
205
+ throw ex;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * @author Thiago Anselmo &lt;thiagoo.anselmoo@gmail.com>
211
+ * @description Check if email is unique
212
+ * @param {string} email Check if email is unique
213
+ * @param {string} session Is token JWT
214
+ * @public
215
+ * @async
216
+ * @example
217
+ *
218
+ * const API = require('@docbrasil/api-systemmanager');
219
+ * const api = new API();
220
+ * const email = 'ana.silva@gmail.com';
221
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
222
+ * await api.admin.user.emailExist(email, session);
223
+ */
224
+ async emailExist(email, session) {
225
+ const self = this;
226
+
227
+ try {
228
+ Joi.assert(email, Joi.string().email().required());
229
+ Joi.assert(session, Joi.string().required());
230
+
231
+ const payload = {email};
232
+ const apiCall = self.client.post(`/admin/users/email/exist`, payload, self._setHeader(session));
233
+ return self._returnData(await apiCall);
234
+ } catch (ex) {
235
+ throw ex;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * @description update userData by userSMId
241
+ * @param {string} userId - User SM Id
242
+ * @param {object} payload - Payload to update
243
+ * @param {string} session - Is token JWT
244
+ * @returns {Promise&lt;*>}
245
+ * @async
246
+ * @public
247
+ * @example
248
+ *
249
+ * const userId = '55e4a3bd6be6b45210833fae';
250
+ * const payload = {
251
+ * name: 'Maria joaquina',
252
+ * email: 'maria@gmail.com'
253
+ * };
254
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
255
+ */
256
+ async findByIdAndUpdate(userId, payload, session) {
257
+ const self = this;
258
+
259
+ try {
260
+ Joi.assert(userId, Joi.string().required(), 'User id of SM');
261
+ Joi.assert(payload, Joi.object().required(), 'Payload to update');
262
+ Joi.assert(session, Joi.string().required(), 'Session user admin');
263
+
264
+ const apiCall = self.client.put(`/admin/users/${userId}`, payload, self._setHeader(session));
265
+ return self._returnData(await apiCall);
266
+ } catch (ex) {
267
+ throw ex;
268
+ }
269
+ }
270
+ }
271
+
272
+ export default AdminUser;
273
+ </code></pre>
274
+ </article>
275
+ </section>
276
+
277
+
278
+
279
+
280
+ </div>
281
+
282
+ <footer class="footer">
283
+ <div class="content has-text-centered">
284
+ <p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a></p>
285
+ <p class="sidebar-created-by">
286
+ <a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
287
+ <a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
288
+ </p>
289
+ </div>
290
+ </footer>
291
+
292
+ </div>
293
+ <div id="side-nav" class="side-nav">
294
+ </div>
295
+ </div>
296
+ <script src="scripts/app.min.js"></script>
297
+ <script>PR.prettyPrint();</script>
298
+ <script src="scripts/linenumber.js"> </script>
299
+
300
+
301
+ </body>
302
+ </html>