@docbrasil/api-systemmanager 1.0.94 → 1.0.96

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 (58) hide show
  1. package/api/admin/doctypes.js +76 -76
  2. package/api/admin/document.js +332 -332
  3. package/api/admin/form.js +151 -151
  4. package/api/admin/index.js +46 -46
  5. package/api/admin/list.js +133 -133
  6. package/api/admin/message.js +194 -194
  7. package/api/admin/notification.js +233 -233
  8. package/api/admin/organization.js +124 -124
  9. package/api/admin/plugin.js +116 -116
  10. package/api/admin/policy.js +78 -78
  11. package/api/admin/processes.js +370 -370
  12. package/api/admin/task.js +125 -125
  13. package/api/admin/user.js +185 -185
  14. package/api/dispatch.js +101 -101
  15. package/api/general/geoLocation.js +88 -88
  16. package/api/general/index.js +23 -23
  17. package/api/login.js +267 -267
  18. package/api/session.js +85 -85
  19. package/api/user/datasource.js +144 -144
  20. package/api/user/document.js +730 -730
  21. package/api/user/index.js +39 -39
  22. package/api/user/notification.js +101 -101
  23. package/api/user/organization.js +230 -230
  24. package/api/user/process.js +191 -191
  25. package/api/user/register.js +205 -205
  26. package/api/user/task.js +201 -201
  27. package/api/user/task_available.js +135 -135
  28. package/api/user/user.js +287 -287
  29. package/api/utils/cypher.js +37 -37
  30. package/api/utils/promises.js +118 -118
  31. package/bundleRollup.js +158 -158
  32. package/dist/bundle.cjs +4875 -4875
  33. package/dist/bundle.mjs +1 -1
  34. package/doc/api.md +675 -337
  35. package/doc.md +653 -653
  36. package/helper/boom.js +487 -487
  37. package/helper/cryptojs.js +6067 -6067
  38. package/index.js +85 -85
  39. package/package-lock.json +4635 -4635
  40. package/package.json +68 -68
  41. package/readme.md +25 -25
  42. package/tests/admin/document.spec.js +45 -45
  43. package/tests/admin/form.spec.js +74 -74
  44. package/tests/admin/list.spec.js +86 -86
  45. package/tests/admin/message.js +92 -92
  46. package/tests/admin/notification.spec.js +174 -174
  47. package/tests/admin/pluginspec..js +71 -71
  48. package/tests/admin/policy.spec.js +71 -71
  49. package/tests/admin/processes.spec.js +119 -119
  50. package/tests/admin/users.spec.js +127 -127
  51. package/tests/documents.spec.js +164 -164
  52. package/tests/login.spec.js +91 -91
  53. package/tests/session.spec..js +58 -58
  54. package/tests/user/documents.js +164 -164
  55. package/tests/user/organization.js +122 -122
  56. package/tests/user/process.js +71 -71
  57. package/tests/user/task_available.js +75 -75
  58. package/tests/user/user.js +88 -88
package/api/admin/form.js CHANGED
@@ -1,151 +1,151 @@
1
- import _ from 'lodash';
2
- import Boom from '@hapi/boom';
3
- import Joi from 'joi';
4
-
5
- /**
6
- * Admin Class for forms, permission admin
7
- * @class
8
- */
9
- class AdminForm {
10
-
11
- constructor(options) {
12
- Joi.assert(options, Joi.object().required());
13
- Joi.assert(options.parent, Joi.object().required());
14
-
15
- const self = this;
16
- self.parent = options.parent;
17
- self._client = self.parent.dispatch.getClient();
18
- }
19
-
20
- /**
21
- * @author Augusto Pissarra <abernardo.br@gmail.com>
22
- * @description Get the return data and check for errors
23
- * @param {object} retData Response HTTP
24
- * @return {*}
25
- * @private
26
- */
27
- _returnData(retData, def = {}) {
28
- if (retData.status !== 200) {
29
- return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
30
- } else {
31
- return _.get(retData, 'data', def);
32
- }
33
- }
34
-
35
- /**
36
- * @author CloudBrasil <abernardo.br@gmail.com>
37
- * @description Set header with new session
38
- * @param {string} session Session, token JWT
39
- * @return {object} header with new session
40
- * @private
41
- */
42
- _setHeader(session) {
43
- return {
44
- headers: {
45
- authorization: session,
46
- }
47
- };
48
- }
49
-
50
- /**
51
- * @author CloudBrasil <abernardo.br@gmail.com>
52
- * @description Get advance form by ID
53
- * @param {object} params Params to find form by id
54
- * @param {string} params.id Formulary Id (_id database)
55
- * @param {string} params.orgId Organization Id (_id database)
56
- * @param {string} session Session, token JWT
57
- * @return {Promise}
58
- * @public
59
- * @async
60
- * @example
61
- *
62
- * const API = require('@docbrasil/api-systemmanager');
63
- * const api = new API();
64
- * const params = {
65
- * id: '55e4a3bd6be6b45210833fae',
66
- * orgId: '5edd11c46b6ce9729c2c297c',
67
- * };
68
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
69
- * await api.admin.form.findById(params, session);
70
- */
71
- async findById(params, session) {
72
- const self = this;
73
-
74
- try {
75
- Joi.assert(params, Joi.object().required());
76
- Joi.assert(params.id, Joi.string().required());
77
- Joi.assert(params.orgId, Joi.string().required());
78
- Joi.assert(session, Joi.string().required());
79
-
80
- const {id, orgId} = params;
81
- const apiCall = self._client.get(`/admin/organizations/${orgId}/orgforms/${id}/form`, self._setHeader(session));
82
- return self._returnData(await apiCall);
83
- } catch (ex) {
84
- throw ex;
85
- }
86
- }
87
-
88
- /**
89
- * @author CloudBrasil <abernardo.br@gmail.com>
90
- * @description Request signed url url to put or get
91
- * @param {object} params - Params to get form list
92
- * @param {string} params.orgId - Organization id (_id database)
93
- * @param {number} params.page=1 - Page of pagination
94
- * @param {number} params.perPage=200 - Items per page
95
- * @param {object} params.type=2 - Form type (1 to Business or 2 to Advanced)
96
- * @param {object} params.project={_id: 1, name: 1} - Fields to project
97
- * @param {object} params.sort={name: 1} - Sort fields
98
- * @param {string} session - Session, token JWT
99
- * @return {Promise}
100
- * @public
101
- * @async
102
- * @example
103
- *
104
- * const API = require('@docbrasil/api-systemmanager');
105
- * const api = new API();
106
- * const params - {
107
- * orgId: '5dadd01dc4af3941d42f8c5c',
108
- * };
109
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
110
- * await api.user.form.getFormList(params, session);
111
- */
112
- async getFormList(params, session) {
113
- const self = this;
114
-
115
- try {
116
- Joi.assert(params, Joi.object().required(), 'Params to get form list');
117
- Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
118
- Joi.assert(params.page, Joi.number(), 'Page of pagination');
119
- Joi.assert(params.perPage, Joi.number(), 'Items per page');
120
- Joi.assert(params.type, Joi.number(), 'Form type (1 to Business or 2 to Advanced)');
121
- Joi.assert(params.project, Joi.object(), 'Fields to project');
122
- Joi.assert(params.sort, Joi.object(), 'Sort fields for');
123
- Joi.assert(session, Joi.string().required(), 'Session, token JWT');
124
-
125
- const FORM_ADVANCED = 2;
126
- const PROJECTION_DEFAULT = {_id: 1, name: 1};
127
- const SORT_DEFAULT = {name: 1};
128
-
129
- const {
130
- orgId,
131
- page = 1,
132
- perPage = 200,
133
- type = FORM_ADVANCED,
134
- project = PROJECTION_DEFAULT,
135
- sort = SORT_DEFAULT
136
- } = params;
137
-
138
- const payloadToSend = { orgId, type, $project: project, sort };
139
-
140
- const apiCall = self._client
141
- .post(`/admin/organizations/${orgId}/orgforms?page=${page}&perPage=${perPage}`, payloadToSend, self._setHeader(session));
142
-
143
- return self._returnData(await apiCall);
144
-
145
- } catch (ex) {
146
- throw ex;
147
- }
148
- }
149
- }
150
-
151
- export default AdminForm;
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * Admin Class for forms, permission admin
7
+ * @class
8
+ */
9
+ class AdminForm {
10
+
11
+ constructor(options) {
12
+ Joi.assert(options, Joi.object().required());
13
+ Joi.assert(options.parent, Joi.object().required());
14
+
15
+ const self = this;
16
+ self.parent = options.parent;
17
+ self._client = self.parent.dispatch.getClient();
18
+ }
19
+
20
+ /**
21
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
22
+ * @description Get the return data and check for errors
23
+ * @param {object} retData Response HTTP
24
+ * @return {*}
25
+ * @private
26
+ */
27
+ _returnData(retData, def = {}) {
28
+ if (retData.status !== 200) {
29
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
30
+ } else {
31
+ return _.get(retData, 'data', def);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @author CloudBrasil <abernardo.br@gmail.com>
37
+ * @description Set header with new session
38
+ * @param {string} session Session, token JWT
39
+ * @return {object} header with new session
40
+ * @private
41
+ */
42
+ _setHeader(session) {
43
+ return {
44
+ headers: {
45
+ authorization: session,
46
+ }
47
+ };
48
+ }
49
+
50
+ /**
51
+ * @author CloudBrasil <abernardo.br@gmail.com>
52
+ * @description Get advance form by ID
53
+ * @param {object} params Params to find form by id
54
+ * @param {string} params.id Formulary Id (_id database)
55
+ * @param {string} params.orgId Organization Id (_id database)
56
+ * @param {string} session Session, token JWT
57
+ * @return {Promise}
58
+ * @public
59
+ * @async
60
+ * @example
61
+ *
62
+ * const API = require('@docbrasil/api-systemmanager');
63
+ * const api = new API();
64
+ * const params = {
65
+ * id: '55e4a3bd6be6b45210833fae',
66
+ * orgId: '5edd11c46b6ce9729c2c297c',
67
+ * };
68
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
69
+ * await api.admin.form.findById(params, session);
70
+ */
71
+ async findById(params, session) {
72
+ const self = this;
73
+
74
+ try {
75
+ Joi.assert(params, Joi.object().required());
76
+ Joi.assert(params.id, Joi.string().required());
77
+ Joi.assert(params.orgId, Joi.string().required());
78
+ Joi.assert(session, Joi.string().required());
79
+
80
+ const {id, orgId} = params;
81
+ const apiCall = self._client.get(`/admin/organizations/${orgId}/orgforms/${id}/form`, self._setHeader(session));
82
+ return self._returnData(await apiCall);
83
+ } catch (ex) {
84
+ throw ex;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @author CloudBrasil <abernardo.br@gmail.com>
90
+ * @description Request signed url url to put or get
91
+ * @param {object} params - Params to get form list
92
+ * @param {string} params.orgId - Organization id (_id database)
93
+ * @param {number} params.page=1 - Page of pagination
94
+ * @param {number} params.perPage=200 - Items per page
95
+ * @param {object} params.type=2 - Form type (1 to Business or 2 to Advanced)
96
+ * @param {object} params.project={_id: 1, name: 1} - Fields to project
97
+ * @param {object} params.sort={name: 1} - Sort fields
98
+ * @param {string} session - Session, token JWT
99
+ * @return {Promise}
100
+ * @public
101
+ * @async
102
+ * @example
103
+ *
104
+ * const API = require('@docbrasil/api-systemmanager');
105
+ * const api = new API();
106
+ * const params - {
107
+ * orgId: '5dadd01dc4af3941d42f8c5c',
108
+ * };
109
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
110
+ * await api.user.form.getFormList(params, session);
111
+ */
112
+ async getFormList(params, session) {
113
+ const self = this;
114
+
115
+ try {
116
+ Joi.assert(params, Joi.object().required(), 'Params to get form list');
117
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
118
+ Joi.assert(params.page, Joi.number(), 'Page of pagination');
119
+ Joi.assert(params.perPage, Joi.number(), 'Items per page');
120
+ Joi.assert(params.type, Joi.number(), 'Form type (1 to Business or 2 to Advanced)');
121
+ Joi.assert(params.project, Joi.object(), 'Fields to project');
122
+ Joi.assert(params.sort, Joi.object(), 'Sort fields for');
123
+ Joi.assert(session, Joi.string().required(), 'Session, token JWT');
124
+
125
+ const FORM_ADVANCED = 2;
126
+ const PROJECTION_DEFAULT = {_id: 1, name: 1};
127
+ const SORT_DEFAULT = {name: 1};
128
+
129
+ const {
130
+ orgId,
131
+ page = 1,
132
+ perPage = 200,
133
+ type = FORM_ADVANCED,
134
+ project = PROJECTION_DEFAULT,
135
+ sort = SORT_DEFAULT
136
+ } = params;
137
+
138
+ const payloadToSend = { orgId, type, $project: project, sort };
139
+
140
+ const apiCall = self._client
141
+ .post(`/admin/organizations/${orgId}/orgforms?page=${page}&perPage=${perPage}`, payloadToSend, self._setHeader(session));
142
+
143
+ return self._returnData(await apiCall);
144
+
145
+ } catch (ex) {
146
+ throw ex;
147
+ }
148
+ }
149
+ }
150
+
151
+ export default AdminForm;
@@ -1,46 +1,46 @@
1
- import Joi from 'joi';
2
-
3
- import AdminDocument from './document.js';
4
- import AdminForm from './form.js';
5
- import AdminNotification from './notification.js';
6
- import AdminList from './list.js';
7
- import AdminPlugin from './plugin.js';
8
- import AdminPolicy from './policy.js';
9
- import AdminTask from './task.js';
10
- import AdminUser from './user.js';
11
- import AdminProcesses from './processes.js';
12
- import AdminMessage from './message.js';
13
- import AdminDocTypes from './doctypes.js';
14
- import AdminOrganizations from './organization.js';
15
-
16
- /**
17
- * @class API request, admin permission level
18
- */
19
- class Admin {
20
- /**
21
- * @author CloudBrasil <abernardo.br@gmail.com>
22
- * @constructor
23
- * @param {object} options Params of the constructor
24
- * @param {object} options.parent This of the pararent
25
- */
26
- constructor(options) {
27
- Joi.assert(options, Joi.object().required());
28
- Joi.assert(options.parent, Joi.object().required());
29
-
30
- const self = this;
31
- self.doctypes = new AdminDocTypes(options);
32
- self.document = new AdminDocument(options);
33
- self.form = new AdminForm(options);
34
- self.list = new AdminList(options);
35
- self.message = new AdminMessage(options);
36
- self.organizations = new AdminOrganizations(options);
37
- self.notification = new AdminNotification(options);
38
- self.plugin = new AdminPlugin(options);
39
- self.policy = new AdminPolicy(options);
40
- self.processes = new AdminProcesses(options);
41
- self.task = new AdminTask(options);
42
- self.user = new AdminUser(options);
43
- }
44
- }
45
-
46
- export default Admin;
1
+ import Joi from 'joi';
2
+
3
+ import AdminDocument from './document.js';
4
+ import AdminForm from './form.js';
5
+ import AdminNotification from './notification.js';
6
+ import AdminList from './list.js';
7
+ import AdminPlugin from './plugin.js';
8
+ import AdminPolicy from './policy.js';
9
+ import AdminTask from './task.js';
10
+ import AdminUser from './user.js';
11
+ import AdminProcesses from './processes.js';
12
+ import AdminMessage from './message.js';
13
+ import AdminDocTypes from './doctypes.js';
14
+ import AdminOrganizations from './organization.js';
15
+
16
+ /**
17
+ * @class API request, admin permission level
18
+ */
19
+ class Admin {
20
+ /**
21
+ * @author CloudBrasil <abernardo.br@gmail.com>
22
+ * @constructor
23
+ * @param {object} options Params of the constructor
24
+ * @param {object} options.parent This of the pararent
25
+ */
26
+ constructor(options) {
27
+ Joi.assert(options, Joi.object().required());
28
+ Joi.assert(options.parent, Joi.object().required());
29
+
30
+ const self = this;
31
+ self.doctypes = new AdminDocTypes(options);
32
+ self.document = new AdminDocument(options);
33
+ self.form = new AdminForm(options);
34
+ self.list = new AdminList(options);
35
+ self.message = new AdminMessage(options);
36
+ self.organizations = new AdminOrganizations(options);
37
+ self.notification = new AdminNotification(options);
38
+ self.plugin = new AdminPlugin(options);
39
+ self.policy = new AdminPolicy(options);
40
+ self.processes = new AdminProcesses(options);
41
+ self.task = new AdminTask(options);
42
+ self.user = new AdminUser(options);
43
+ }
44
+ }
45
+
46
+ export default Admin;
package/api/admin/list.js CHANGED
@@ -1,133 +1,133 @@
1
- import _ from 'lodash';
2
- import Boom from '@hapi/boom';
3
- import Joi from 'joi';
4
-
5
- /**
6
- * Admin Class for lists, permission admin
7
- * @class
8
- */
9
- class AdminLists {
10
-
11
- constructor(options) {
12
- Joi.assert(options, Joi.object().required());
13
- Joi.assert(options.parent, Joi.object().required());
14
-
15
- const self = this;
16
- self.parent = options.parent;
17
- self._client = self.parent.dispatch.getClient();
18
- }
19
-
20
- /**
21
- * @author Augusto Pissarra <abernardo.br@gmail.com>
22
- * @description Get the return data and check for errors
23
- * @param {object} retData Response HTTP
24
- * @return {*}
25
- * @private
26
- */
27
- _returnData(retData, def = {}) {
28
- if (retData.status !== 200) {
29
- return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
30
- } else {
31
- return _.get(retData, 'data', def);
32
- }
33
- }
34
-
35
- /**
36
- * @author CloudBrasil <abernardo.br@gmail.com>
37
- * @description Set header with new session
38
- * @param {string} session Session, token JWT
39
- * @return {object} header with new session
40
- * @private
41
- */
42
- _setHeader(session) {
43
- return {
44
- headers: {
45
- authorization: session,
46
- }
47
- };
48
- }
49
-
50
- /**
51
- * @author CloudBrasil <abernardo.br@gmail.com>
52
- * @description Get list by ID
53
- * @param {object} params Params to find list by id
54
- * @param {string} params.id List Id (_id database)
55
- * @param {string} params.orgId Organization Id (_id database)
56
- * @param {string} session Session, token JWT
57
- * @return {Promise}
58
- * @public
59
- * @async
60
- * @example
61
- *
62
- * const API = require('@docbrasil/api-systemmanager');
63
- * const api = new API();
64
- * const params = {
65
- * id: '55e4a3bd6be6b45210833fae',
66
- * orgId: '5edd11c46b6ce9729c2c297c',
67
- * };
68
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
69
- * await api.admin.list.findById(params, session);
70
- */
71
- async findById(params, session) {
72
- const self = this;
73
-
74
- try {
75
- Joi.assert(params, Joi.object().required());
76
- Joi.assert(params.id, Joi.string().required());
77
- Joi.assert(params.orgId, Joi.string().required());
78
- Joi.assert(session, Joi.string().required());
79
-
80
- const {id, orgId} = params;
81
- const apiCall = self._client.get(`/admin/organizations/${orgId}/orgtags/${id}`, self._setHeader(session));
82
- return self._returnData(await apiCall);
83
- } catch (ex) {
84
- throw ex;
85
- }
86
- }
87
-
88
- /**
89
- * @author CloudBrasil <abernardo.br@gmail.com>
90
- * @description Get all lists
91
- * @param {object} params={} Params to pagination and orgId
92
- * @param {number} [params.page=0] Current page to pagination
93
- * @param {number} [params.perPage=200] Qnt itens per page
94
- * @param {string} params.orgId Organization Id (_id database)
95
- * @param {string} session Session, token JWT
96
- * @return {Promise}
97
- * @public
98
- * @async
99
- * @example
100
- *
101
- * const API = require('@docbrasil/api-systemmanager');
102
- * const api = new API();
103
- * const params = {
104
- * orgId: '55e4a3bd6be6b45210833fae'
105
- * };
106
- * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
107
- * await api.admin.list.find(params, session);
108
- */
109
- async find(params = {}, session) {
110
- const self = this;
111
-
112
- try {
113
-
114
- Joi.assert(params, Joi.object());
115
- Joi.assert(params.page, Joi.number());
116
- Joi.assert(params.perPage, Joi.number());
117
- Joi.assert(params.orgId, Joi.string().required());
118
- Joi.assert(session, Joi.string().required());
119
-
120
- const orgId = _.get(params, 'orgId');
121
- const page = _.get(params, 'page', 0);
122
- const perPage = _.get(params, 'perPage', 200);
123
- const apiCall = self._client
124
- .post(`/admin/organizations/${orgId}/orgtags?page=${page}&perPage=${perPage}`, {}, self._setHeader(session));
125
-
126
- return self._returnData(await apiCall);
127
- } catch (ex) {
128
- throw ex;
129
- }
130
- }
131
- }
132
-
133
- export default AdminLists;
1
+ import _ from 'lodash';
2
+ import Boom from '@hapi/boom';
3
+ import Joi from 'joi';
4
+
5
+ /**
6
+ * Admin Class for lists, permission admin
7
+ * @class
8
+ */
9
+ class AdminLists {
10
+
11
+ constructor(options) {
12
+ Joi.assert(options, Joi.object().required());
13
+ Joi.assert(options.parent, Joi.object().required());
14
+
15
+ const self = this;
16
+ self.parent = options.parent;
17
+ self._client = self.parent.dispatch.getClient();
18
+ }
19
+
20
+ /**
21
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
22
+ * @description Get the return data and check for errors
23
+ * @param {object} retData Response HTTP
24
+ * @return {*}
25
+ * @private
26
+ */
27
+ _returnData(retData, def = {}) {
28
+ if (retData.status !== 200) {
29
+ return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
30
+ } else {
31
+ return _.get(retData, 'data', def);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @author CloudBrasil <abernardo.br@gmail.com>
37
+ * @description Set header with new session
38
+ * @param {string} session Session, token JWT
39
+ * @return {object} header with new session
40
+ * @private
41
+ */
42
+ _setHeader(session) {
43
+ return {
44
+ headers: {
45
+ authorization: session,
46
+ }
47
+ };
48
+ }
49
+
50
+ /**
51
+ * @author CloudBrasil <abernardo.br@gmail.com>
52
+ * @description Get list by ID
53
+ * @param {object} params Params to find list by id
54
+ * @param {string} params.id List Id (_id database)
55
+ * @param {string} params.orgId Organization Id (_id database)
56
+ * @param {string} session Session, token JWT
57
+ * @return {Promise}
58
+ * @public
59
+ * @async
60
+ * @example
61
+ *
62
+ * const API = require('@docbrasil/api-systemmanager');
63
+ * const api = new API();
64
+ * const params = {
65
+ * id: '55e4a3bd6be6b45210833fae',
66
+ * orgId: '5edd11c46b6ce9729c2c297c',
67
+ * };
68
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
69
+ * await api.admin.list.findById(params, session);
70
+ */
71
+ async findById(params, session) {
72
+ const self = this;
73
+
74
+ try {
75
+ Joi.assert(params, Joi.object().required());
76
+ Joi.assert(params.id, Joi.string().required());
77
+ Joi.assert(params.orgId, Joi.string().required());
78
+ Joi.assert(session, Joi.string().required());
79
+
80
+ const {id, orgId} = params;
81
+ const apiCall = self._client.get(`/admin/organizations/${orgId}/orgtags/${id}`, self._setHeader(session));
82
+ return self._returnData(await apiCall);
83
+ } catch (ex) {
84
+ throw ex;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * @author CloudBrasil <abernardo.br@gmail.com>
90
+ * @description Get all lists
91
+ * @param {object} params={} Params to pagination and orgId
92
+ * @param {number} [params.page=0] Current page to pagination
93
+ * @param {number} [params.perPage=200] Qnt itens per page
94
+ * @param {string} params.orgId Organization Id (_id database)
95
+ * @param {string} session Session, token JWT
96
+ * @return {Promise}
97
+ * @public
98
+ * @async
99
+ * @example
100
+ *
101
+ * const API = require('@docbrasil/api-systemmanager');
102
+ * const api = new API();
103
+ * const params = {
104
+ * orgId: '55e4a3bd6be6b45210833fae'
105
+ * };
106
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
107
+ * await api.admin.list.find(params, session);
108
+ */
109
+ async find(params = {}, session) {
110
+ const self = this;
111
+
112
+ try {
113
+
114
+ Joi.assert(params, Joi.object());
115
+ Joi.assert(params.page, Joi.number());
116
+ Joi.assert(params.perPage, Joi.number());
117
+ Joi.assert(params.orgId, Joi.string().required());
118
+ Joi.assert(session, Joi.string().required());
119
+
120
+ const orgId = _.get(params, 'orgId');
121
+ const page = _.get(params, 'page', 0);
122
+ const perPage = _.get(params, 'perPage', 200);
123
+ const apiCall = self._client
124
+ .post(`/admin/organizations/${orgId}/orgtags?page=${page}&perPage=${perPage}`, {}, self._setHeader(session));
125
+
126
+ return self._returnData(await apiCall);
127
+ } catch (ex) {
128
+ throw ex;
129
+ }
130
+ }
131
+ }
132
+
133
+ export default AdminLists;