@docbrasil/api-systemmanager 1.0.89 → 1.0.91

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 (57) 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 +22 -22
  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 +674 -336
  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/user.js +88 -88
package/doc/api.md CHANGED
@@ -37,21 +37,12 @@
37
37
  <dt><a href="#AdminUser">AdminUser</a></dt>
38
38
  <dd><p>Admin Class for user, permission admin</p>
39
39
  </dd>
40
- <dt><a href="#Dispatch">Dispatch</a></dt>
41
- <dd><p>Api dispatch manager</p>
42
- </dd>
43
40
  <dt><a href="#GeoLocation">GeoLocation</a></dt>
44
41
  <dd><p>General Class for user, permission organization</p>
45
42
  </dd>
46
43
  <dt><a href="#Users">Users</a></dt>
47
44
  <dd><p>API request, user permission level</p>
48
45
  </dd>
49
- <dt><a href="#Login">Login</a></dt>
50
- <dd><p>Login manager</p>
51
- </dd>
52
- <dt><a href="#Session">Session</a></dt>
53
- <dd><p>Session manager of the API</p>
54
- </dd>
55
46
  <dt><a href="#Datasource">Datasource</a></dt>
56
47
  <dd><p>Class for user datasource access, to be used with when creating new documents</p>
57
48
  </dd>
@@ -73,12 +64,12 @@
73
64
  <dt><a href="#Register">Register</a></dt>
74
65
  <dd><p>Class for user registration in a user</p>
75
66
  </dd>
76
- <dt><a href="#TaskAvailable">TaskAvailable</a></dt>
77
- <dd><p>Class for available tasks, permission user</p>
78
- </dd>
79
67
  <dt><a href="#Task">Task</a></dt>
80
68
  <dd><p>Class for task, permission user</p>
81
69
  </dd>
70
+ <dt><a href="#TaskAvailable">TaskAvailable</a></dt>
71
+ <dd><p>Class for available tasks, permission user</p>
72
+ </dd>
82
73
  <dt><a href="#User">User</a></dt>
83
74
  <dd><p>Class for user, permission user</p>
84
75
  </dd>
@@ -117,7 +108,33 @@ Advanced search of document in elastic search ussing system manager
117
108
 
118
109
  **Example**
119
110
  ```js
120
- const API = require('@docbrasil/api-systemmanager');
121
111
  docId: '5edd11c46b6ce9729c2c297c',
122
112
  query: {
123
113
  "query": {
124
114
  "bool": {
125
115
  "minimum_should_match": 1,
126
116
  "should": [
127
117
  {
128
118
  "match": {
129
119
  "locationText.keyword": {
130
120
  "query": "sao pau"
131
121
  }
132
122
  }
133
123
  },
134
124
  {
135
125
  "wildcard": {
136
126
  "locationText.normalized": "*sao pau*"
137
127
  }
138
128
  }
139
129
  ]
140
130
  }
141
131
  }
142
132
  }
133
+ const API = require('@docbrasil/api-systemmanager');
134
+ const api = new API();
135
+ const params = {
136
+ docId: '5edd11c46b6ce9729c2c297c',
137
+ query: {
138
+ "query": {
139
+ "bool": {
140
+ "minimum_should_match": 1,
141
+ "should": [
142
+ {
143
+ "match": {
144
+ "locationText.keyword": {
145
+ "query": "sao pau"
146
+ }
147
+ }
148
+ },
149
+ {
150
+ "wildcard": {
151
+ "locationText.normalized": "*sao pau*"
152
+ }
153
+ }
154
+ ]
155
+ }
156
+ }
157
+ }
158
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
159
+ await api.admin.document.advancedSearch(params, session);
143
160
  ```
144
161
  <a name="AdminDocuments+findById"></a>
145
162
 
@@ -137,7 +154,14 @@ Get document by id
137
154
 
138
155
  **Example**
139
156
  ```js
140
- const API = require('@docbrasil/api-systemmanager');
141
157
  docId: '5edd11c46b6ce9729c2c297c',
142
158
  orgId: '55e4a3bd6be6b45210833fae'
159
+ const API = require('@docbrasil/api-systemmanager');
160
+ const api = new API();
161
+ const params = {
162
+ docId: '5edd11c46b6ce9729c2c297c',
163
+ orgId: '55e4a3bd6be6b45210833fae'
164
+ };
165
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
166
+ await api.admin.document.findById(params, session);
143
167
  ```
144
168
  <a name="AdminDocuments+signedUrl"></a>
145
169
 
@@ -158,11 +182,25 @@ Request signed url url to put or get
158
182
 
159
183
  **Example**
160
184
  ```js
161
- const API = require('@docbrasil/api-systemmanager');
162
185
  methodType: 'put',
163
186
  docId: '5dadd01dc4af3941d42f8c5c'
187
+ const API = require('@docbrasil/api-systemmanager');
188
+ const api = new API();
189
+ const params - {
190
+ methodType: 'put',
191
+ docId: '5dadd01dc4af3941d42f8c5c'
192
+ };
193
+ const apiKey: '...';
194
+ const { docId, name, areaId, type, signedUrl } = await api.admin.document.signedUrl(params, apiKey);
164
195
  ```
165
196
  **Example**
166
197
  ```js
167
- const API = require('@docbrasil/api-systemmanager');
168
198
  methodType: 'get',
169
199
  docId: '5dadd01dc4af3941d42f8c5c'
200
+ const API = require('@docbrasil/api-systemmanager');
201
+ const api = new API();
202
+ const params - {
203
+ methodType: 'get',
204
+ docId: '5dadd01dc4af3941d42f8c5c'
205
+ };
206
+ const apiKey: '...';
207
+ const { signedUrl, imageType } = await api.admin.document.signedUrl(params, apiKey);
170
208
  ```
171
209
  <a name="AdminDocuments+updateContent"></a>
172
210
 
@@ -183,7 +221,14 @@ Update a document content
183
221
 
184
222
  **Example**
185
223
  ```js
186
- const API = require('@docbrasil/api-systemmanager');
187
224
  content: 'some text...',
188
225
  docId: '5dadd01dc4af3941d42f8c5c'
226
+ const API = require('@docbrasil/api-systemmanager');
227
+ const api = new API();
228
+ const params - {
229
+ content: 'some text...',
230
+ docId: '5dadd01dc4af3941d42f8c5c'
231
+ };
232
+ const apiKey: '...';
233
+ await api.admin.document.updateContent(params, apiKey);
189
234
  ```
190
235
  <a name="AdminDocuments+updateAI"></a>
191
236
 
@@ -210,7 +255,14 @@ Update a document content
210
255
 
211
256
  **Example**
212
257
  ```js
213
- const API = require('@docbrasil/api-systemmanager');
214
258
  content: 'some text...',
215
259
  docId: '5dadd01dc4af3941d42f8c5c'
260
+ const API = require('@docbrasil/api-systemmanager');
261
+ const api = new API();
262
+ const params - {
263
+ content: 'some text...',
264
+ docId: '5dadd01dc4af3941d42f8c5c'
265
+ };
266
+ const apiKey: '...';
267
+ await api.admin.document.updateContent(params, apiKey);
216
268
  ```
217
269
  <a name="AdminDocuments+getContent"></a>
218
270
 
@@ -231,7 +283,14 @@ Get the content of a document
231
283
 
232
284
  **Example**
233
285
  ```js
234
- const API = require('@docbrasil/api-systemmanager');
235
286
  page: '0',
236
287
  docId: '5dadd01dc4af3941d42f8c5c'
288
+ const API = require('@docbrasil/api-systemmanager');
289
+ const api = new API();
290
+ const params - {
291
+ page: '0',
292
+ docId: '5dadd01dc4af3941d42f8c5c'
293
+ };
294
+ const apiKey: '...';
295
+ await api.admin.document.getContent(params, apiKey);
237
296
  ```
238
297
  <a name="AdminForm"></a>
239
298
 
@@ -262,7 +321,14 @@ Get advance form by ID
262
321
 
263
322
  **Example**
264
323
  ```js
265
- const API = require('@docbrasil/api-systemmanager');
266
324
  id: '55e4a3bd6be6b45210833fae',
267
325
  orgId: '5edd11c46b6ce9729c2c297c',
326
+ const API = require('@docbrasil/api-systemmanager');
327
+ const api = new API();
328
+ const params = {
329
+ id: '55e4a3bd6be6b45210833fae',
330
+ orgId: '5edd11c46b6ce9729c2c297c',
331
+ };
332
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
333
+ await api.admin.form.findById(params, session);
268
334
  ```
269
335
  <a name="AdminForm+getFormList"></a>
270
336
 
@@ -286,7 +352,13 @@ Request signed url url to put or get
286
352
 
287
353
  **Example**
288
354
  ```js
289
- const API = require('@docbrasil/api-systemmanager');
290
355
  orgId: '5dadd01dc4af3941d42f8c5c',
356
+ const API = require('@docbrasil/api-systemmanager');
357
+ const api = new API();
358
+ const params - {
359
+ orgId: '5dadd01dc4af3941d42f8c5c',
360
+ };
361
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
362
+ await api.user.form.getFormList(params, session);
291
363
  ```
292
364
  <a name="Admin"></a>
293
365
 
@@ -333,7 +405,14 @@ Get list by ID
333
405
 
334
406
  **Example**
335
407
  ```js
336
- const API = require('@docbrasil/api-systemmanager');
337
408
  id: '55e4a3bd6be6b45210833fae',
338
409
  orgId: '5edd11c46b6ce9729c2c297c',
410
+ const API = require('@docbrasil/api-systemmanager');
411
+ const api = new API();
412
+ const params = {
413
+ id: '55e4a3bd6be6b45210833fae',
414
+ orgId: '5edd11c46b6ce9729c2c297c',
415
+ };
416
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
417
+ await api.admin.list.findById(params, session);
339
418
  ```
340
419
  <a name="AdminLists+find"></a>
341
420
 
@@ -354,7 +433,13 @@ Get all lists
354
433
 
355
434
  **Example**
356
435
  ```js
357
- const API = require('@docbrasil/api-systemmanager');
358
436
  orgId: '55e4a3bd6be6b45210833fae'
437
+ const API = require('@docbrasil/api-systemmanager');
438
+ const api = new API();
439
+ const params = {
440
+ orgId: '55e4a3bd6be6b45210833fae'
441
+ };
442
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
443
+ await api.admin.list.find(params, session);
359
444
  ```
360
445
  <a name="AdminMessage"></a>
361
446
 
@@ -432,7 +517,15 @@ Send email, array with email list or send one email
432
517
 
433
518
  **Example**
434
519
  ```js
435
- const API = require('@docbrasil/api-systemmanager');
436
520
  subject: 'Test email',
437
521
  message: '<h1>Hi!</h1>',
438
522
  to: 'destination@gmail.com'
523
+ const API = require('@docbrasil/api-systemmanager');
524
+ const api = new API();
525
+ const params = {
526
+ subject: 'Test email',
527
+ message: '<h1>Hi!</h1>',
528
+ to: 'destination@gmail.com'
529
+ };
530
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
531
+ await api.admin.message.sendEmail(params, session);
439
532
  ```
440
533
  <a name="AdminNotification"></a>
441
534
 
@@ -481,7 +574,15 @@ Create notification
481
574
 
482
575
  **Example**
483
576
  ```js
484
- const API = require('@docbrasil/api-systemmanager');
485
577
  orgId: '5edd11c46b6ce9729c2c297c',
486
578
  userId: '55e4a3bd6be6b45210833fae',
487
579
  message: 'Olá como vai tudo bem?'
580
+ const API = require('@docbrasil/api-systemmanager');
581
+ const api = new API();
582
+ const params = {
583
+ orgId: '5edd11c46b6ce9729c2c297c',
584
+ userId: '55e4a3bd6be6b45210833fae',
585
+ message: 'Olá como vai tudo bem?'
586
+ };
587
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
588
+ await api.admin.notifications.add(params, session);
488
589
  ```
489
590
  <a name="AdminNotification+findById"></a>
490
591
 
@@ -501,7 +602,14 @@ Search notification using (notificationId or userId)
501
602
 
502
603
  **Example**
503
604
  ```js
504
- const API = require('@docbrasil/api-systemmanager');
505
605
  orgId: '5edd11c46b6ce9729c2c297c',
506
606
  id: '55e4a3bd6be6b45210833fae',
607
+ const API = require('@docbrasil/api-systemmanager');
608
+ const api = new API();
609
+ const params = {
610
+ orgId: '5edd11c46b6ce9729c2c297c',
611
+ id: '55e4a3bd6be6b45210833fae',
612
+ };
613
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
614
+ await api.admin.notifications.findById(params, session);
507
615
  ```
508
616
  <a name="AdminNotification+findByIdAndUpdate"></a>
509
617
 
@@ -522,7 +630,15 @@ Update notification using (notificationId or userId)
522
630
 
523
631
  **Example**
524
632
  ```js
525
- const API = require('@docbrasil/api-systemmanager');
526
633
  orgId: '5edd11c46b6ce9729c2c297c',
527
634
  id: '55e4a3bd6be6b45210833fae',
528
635
  read: true
636
+ const API = require('@docbrasil/api-systemmanager');
637
+ const api = new API();
638
+ const params = {
639
+ orgId: '5edd11c46b6ce9729c2c297c',
640
+ id: '55e4a3bd6be6b45210833fae',
641
+ read: true
642
+ };
643
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
644
+ await api.admin.notifications.findByIdAndUpdate(params, session);
529
645
  ```
530
646
  <a name="AdminNotification+findByIdAndRemove"></a>
531
647
 
@@ -542,7 +658,14 @@ Delete notification using (notificationId or userId)
542
658
 
543
659
  **Example**
544
660
  ```js
545
- const API = require('@docbrasil/api-systemmanager');
546
661
  orgId: '5edd11c46b6ce9729c2c297c',
547
662
  id: '55e4a3bd6be6b45210833fae',
663
+ const API = require('@docbrasil/api-systemmanager');
664
+ const api = new API();
665
+ const params = {
666
+ orgId: '5edd11c46b6ce9729c2c297c',
667
+ id: '55e4a3bd6be6b45210833fae',
668
+ };
669
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
670
+ await api.admin.notifications.findByIdAndDelete(params, session);
548
671
  ```
549
672
  <a name="Organization"></a>
550
673
 
@@ -579,7 +702,15 @@ Update avatar of organization by session of user not allow session user SU
579
702
 
580
703
  **Example**
581
704
  ```js
582
- const API = require('@docbrasil/api-systemmanager');
583
705
  orgId: '5dadd01dc4af3941d42f8c5c',
584
706
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
585
707
  type: 'image/png',
708
+ const API = require('@docbrasil/api-systemmanager');
709
+ const api = new API();
710
+ const params = {
711
+ orgId: '5dadd01dc4af3941d42f8c5c',
712
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
713
+ type: 'image/png',
714
+ };
715
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
716
+ await api.admin.organizations.upsertAvatar(params, session);
586
717
  ```
587
718
  <a name="Organization+removeAvatar"></a>
588
719
 
@@ -597,7 +728,11 @@ Remove avatar of user by session of user not allow session user SU
597
728
 
598
729
  **Example**
599
730
  ```js
600
- const API = require('@docbrasil/api-systemmanager');
731
+ const API = require('@docbrasil/api-systemmanager');
732
+ const api = new API();
733
+ const orgId = '5dadd01dc4af3941d42f8c5c';
734
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
735
+ await api.admin.organizations.removeAvatar(orgId, session);
601
736
  ```
602
737
  <a name="Organization+findById"></a>
603
738
 
@@ -615,7 +750,11 @@ Find organization by id
615
750
 
616
751
  **Example**
617
752
  ```js
618
- const API = require('@docbrasil/api-systemmanager');
753
+ const API = require('@docbrasil/api-systemmanager');
754
+ const api = new API();
755
+ const orgId = '80443245000122';
756
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
757
+ await api.user.organization.findById(idCard, session);
619
758
  ```
620
759
  <a name="Organization+idCardExist"></a>
621
760
 
@@ -633,7 +772,11 @@ Check if id card exist
633
772
 
634
773
  **Example**
635
774
  ```js
636
- const API = require('@docbrasil/api-systemmanager');
775
+ const API = require('@docbrasil/api-systemmanager');
776
+ const api = new API();
777
+ const idCard = '80443245000122';
778
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
779
+ await api.user.organization.idCardExist(idCard, session);
637
780
  ```
638
781
  <a name="Organization+upsertAvatar"></a>
639
782
 
@@ -653,7 +796,14 @@ Update avatar of organization by session of user not allow session user SU
653
796
 
654
797
  **Example**
655
798
  ```js
656
- const API = require('@docbrasil/api-systemmanager');
657
799
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
658
800
  type: 'image/png',
801
+ const API = require('@docbrasil/api-systemmanager');
802
+ const api = new API();
803
+ const params = {
804
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
805
+ type: 'image/png',
806
+ };
807
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
808
+ await api.user.profile.updateAvatar(params, session);
659
809
  ```
660
810
  <a name="Organization+removeAvatar"></a>
661
811
 
@@ -670,7 +820,10 @@ Remove avatar of user by session of user not allow session user SU
670
820
 
671
821
  **Example**
672
822
  ```js
673
- const API = require('@docbrasil/api-systemmanager');
823
+ const API = require('@docbrasil/api-systemmanager');
824
+ const api = new API();
825
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
826
+ await api.user.profile.removeAvatar(session);
674
827
  ```
675
828
  <a name="Organization+callFetch"></a>
676
829
 
@@ -690,7 +843,14 @@ Call URL internal, need auth JWT (session)
690
843
 
691
844
  **Example**
692
845
  ```js
693
- const API = require('@docbrasil/api-systemmanager');
694
846
  url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
695
847
  method: 'POST'
848
+ const API = require('@docbrasil/api-systemmanager');
849
+ const api = new API();
850
+
851
+ const params = {
852
+ url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
853
+ method: 'POST'
854
+ }
855
+ await api.user.organization.callFetchs(params, session);
696
856
  ```
697
857
  <a name="AdminPlugin"></a>
698
858
 
@@ -720,7 +880,11 @@ Find plugins
720
880
 
721
881
  **Example**
722
882
  ```js
723
- const API = require('@docbrasil/api-systemmanager');
883
+ const API = require('@docbrasil/api-systemmanager');
884
+ const api = new API();
885
+ const params = {page: 1, perPage: 200};
886
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
887
+ await api.user.organization.findById(params, session);
724
888
  ```
725
889
  <a name="AdminPlugin+findById"></a>
726
890
 
@@ -738,7 +902,11 @@ Get plugin by ID
738
902
 
739
903
  **Example**
740
904
  ```js
741
- const API = require('@docbrasil/api-systemmanager');
905
+ const API = require('@docbrasil/api-systemmanager');
906
+ const api = new API();
907
+ const id ='55e4a3bd6be6b45210833fae',
908
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
909
+ await api.admin.plugin.findById(id, session);
742
910
  ```
743
911
  <a name="AdminPolicy"></a>
744
912
 
@@ -761,7 +929,10 @@ Find all policies
761
929
 
762
930
  **Example**
763
931
  ```js
764
- const API = require('@docbrasil/api-systemmanager');
932
+ const API = require('@docbrasil/api-systemmanager');
933
+ const api = new API();
934
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
935
+ await api.admin.policy.find(session);
765
936
  ```
766
937
  <a name="AdminProcesses"></a>
767
938
 
@@ -785,7 +956,16 @@ Advanced search of processes, check documentation, to verify all params, pass to
785
956
  **Author**: CloudBrasil <abernardo.br@gmail.com>
786
957
  **Example**
787
958
  ```js
788
- const API = require('@docbrasil/api-systemmanager');
789
959
  orgId: '5edd11c46b6ce9729c2c297c',
790
960
  ...
791
961
  ...
792
962
  ...
963
+ const API = require('@docbrasil/api-systemmanager');
964
+ const api = new API();
965
+ const params = {
966
+ orgId: '5edd11c46b6ce9729c2c297c',
967
+ ...
968
+ ...
969
+ ...
970
+ };
971
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
972
+ await api.admin.processes.search(params, session);
793
973
  ```
794
974
  <a name="AdminProcesses+advancedSearch"></a>
795
975
 
@@ -805,7 +985,23 @@ Advanced search of process in elastic search ussing system manager
805
985
 
806
986
  **Example**
807
987
  ```js
808
- const API = require('@docbrasil/api-systemmanager');
809
988
  orgProcessId: '5edd11c46b6ce9729c2c297c',
810
989
  query: {
811
990
  "_source": "processData.properties.processProperties",
812
991
  "query": {
813
992
  "term": {
814
993
  "initParams.email.keyword": {
815
994
  "value": "clintes001@gmail.com"
816
995
  }
817
996
  }
818
997
  }
819
998
  }
999
+ const API = require('@docbrasil/api-systemmanager');
1000
+ const api = new API();
1001
+ const params = {
1002
+ orgProcessId: '5edd11c46b6ce9729c2c297c',
1003
+ query: {
1004
+ "_source": "processData.properties.processProperties",
1005
+ "query": {
1006
+ "term": {
1007
+ "initParams.email.keyword": {
1008
+ "value": "clintes001@gmail.com"
1009
+ }
1010
+ }
1011
+ }
1012
+ }
1013
+ }
1014
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1015
+ await api.admin.processes.advancedSearch(params, session);
820
1016
  ```
821
1017
  <a name="AdminTask"></a>
822
1018
 
@@ -836,7 +1032,13 @@ Get task by user Id
836
1032
 
837
1033
  **Example**
838
1034
  ```js
839
- const API = require('@docbrasil/api-systemmanager');
840
1035
  userId: '55e4a3bd6be6b45210833fae',
1036
+ const API = require('@docbrasil/api-systemmanager');
1037
+ const api = new API();
1038
+ const params = {
1039
+ userId: '55e4a3bd6be6b45210833fae',
1040
+ };
1041
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1042
+ await api.admin.task.find(params, session);
841
1043
  ```
842
1044
  <a name="AdminUser"></a>
843
1045
 
@@ -867,7 +1069,11 @@ Request profile by userId
867
1069
 
868
1070
  **Example**
869
1071
  ```js
870
- const API = require('@docbrasil/api-systemmanager');
1072
+ const API = require('@docbrasil/api-systemmanager');
1073
+ const api = new API();
1074
+ const userId = '55e4a3bd6be6b45210833fae';
1075
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1076
+ await api.admin.user.findById(userId, session);
871
1077
  ```
872
1078
  <a name="AdminUser+findByIdAndUpdatePassword"></a>
873
1079
 
@@ -888,7 +1094,15 @@ Update password by userId
888
1094
 
889
1095
  **Example**
890
1096
  ```js
891
- const API = require('@docbrasil/api-systemmanager');
892
1097
  userId: '55e4a3bd6be6b45210833fae',
893
1098
  oldPassword: '123456',
894
1099
  newPassword: '123456789'
1100
+ const API = require('@docbrasil/api-systemmanager');
1101
+ const api = new API();
1102
+ const params = {
1103
+ userId: '55e4a3bd6be6b45210833fae',
1104
+ oldPassword: '123456',
1105
+ newPassword: '123456789'
1106
+ };
1107
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1108
+ await api.admin.user.findByIdAndUpdatePassword(params, session);
895
1109
  ```
896
1110
  <a name="AdminUser+emailExist"></a>
897
1111
 
@@ -906,7 +1120,11 @@ Check if email is unique
906
1120
 
907
1121
  **Example**
908
1122
  ```js
909
- const API = require('@docbrasil/api-systemmanager');
1123
+ const API = require('@docbrasil/api-systemmanager');
1124
+ const api = new API();
1125
+ const email = 'ana.silva@gmail.com';
1126
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1127
+ await api.admin.user.emailExist(email, session);
910
1128
  ```
911
1129
  <a name="AdminUser+findByIdAndUpdate"></a>
912
1130
 
@@ -924,49 +1142,12 @@ update userData by userSMId
924
1142
 
925
1143
  **Example**
926
1144
  ```js
927
- const userId = '55e4a3bd6be6b45210833fae';
928
1145
  name: 'Maria joaquina',
929
1146
  email: 'maria@gmail.com'
930
- ```
931
- <a name="Dispatch"></a>
932
-
933
- ## Dispatch
934
- Api dispatch manager
935
-
936
- **Kind**: global class
937
-
938
- * [Dispatch](#Dispatch)
939
- * [.getContext(url, session)](#Dispatch+getContext) ⇒ <code>Promise.&lt;object&gt;</code>
940
- * [.getClient()](#Dispatch+getClient) ⇒ <code>promise</code>
941
-
942
- <a name="Dispatch+getContext"></a>
943
-
944
- ### dispatch.getContext(url, session) ⇒ <code>Promise.&lt;object&gt;</code>
945
- Get the URL context
946
-
947
- **Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
948
- **Returns**: <code>Promise.&lt;object&gt;</code> - The full data context of the URL
949
- **Access**: public
950
-
951
- | Param | Type | Default | Description |
952
- | --- | --- | --- | --- |
953
- | url | <code>string</code> | | Full url |
954
- | session | <code>session</code> | <code></code> | Session, token JWT |
955
-
956
- **Example**
957
- ```js
958
- const API = require('@docbrasil/api-systemmanager');
959
- ```
960
- <a name="Dispatch+getClient"></a>
961
-
962
- ### dispatch.getClient() ⇒ <code>promise</code>
963
- Get client Axios
964
-
965
- **Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
966
- **Returns**: <code>promise</code> - return client axios
967
- **Access**: public
968
- **Author**: CloudBrasil <abernardo.br@gmail.com>
969
- **Example**
970
- ```js
971
- const API = require('@docbrasil/api-systemmanager');
1147
+ const userId = '55e4a3bd6be6b45210833fae';
1148
+ const payload = {
1149
+ name: 'Maria joaquina',
1150
+ email: 'maria@gmail.com'
1151
+ };
1152
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
972
1153
  ```
973
1154
  <a name="GeoLocation"></a>
974
1155
 
@@ -991,7 +1172,13 @@ Get geo location of the address
991
1172
 
992
1173
  **Example**
993
1174
  ```js
994
- const API = require('@docbrasil/api-systemmanager');
995
1175
  address: 'Rua Sud Menucci, 615 - Vila Camilopolis, Santo André - SP',
996
1176
  apiKey: 'AIzaSyC7gJFOkuT-Mel3WZbX5uKuJ1USqLVkGnY',
1177
+ const API = require('@docbrasil/api-systemmanager');
1178
+ const api = new API();
1179
+ const params = {
1180
+ address: 'Rua Sud Menucci, 615 - Vila Camilopolis, Santo André - SP',
1181
+ apiKey: 'AIzaSyC7gJFOkuT-Mel3WZbX5uKuJ1USqLVkGnY',
1182
+ };
1183
+ await api.general.geo.location(params);
997
1184
  ```
998
1185
  <a name="Users"></a>
999
1186
 
@@ -1023,161 +1210,6 @@ API request, user permission level
1023
1210
  | options | <code>object</code> | Params of the constructor |
1024
1211
  | options.parent | <code>object</code> | This of the pararent |
1025
1212
 
1026
- <a name="Login"></a>
1027
-
1028
- ## Login
1029
- Login manager
1030
-
1031
- **Kind**: global class
1032
-
1033
- * [Login](#Login)
1034
- * [.facebook(params)](#Login+facebook) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1035
- * [.google(params)](#Login+google) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1036
- * [.apiKey(apikey)](#Login+apiKey) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1037
- * [.userPass(params)](#Login+userPass) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1038
- * [.logout(session)](#Login+logout) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1039
- * [.recover(username)](#Login+recover) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1040
-
1041
- <a name="Login+facebook"></a>
1042
-
1043
- ### login.facebook(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1044
- Login with social login Facebook
1045
-
1046
- **Kind**: instance method of [<code>Login</code>](#Login)
1047
- **Returns**: <code>promise.&lt;object&gt;</code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
1048
- **Access**: public
1049
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1050
-
1051
- | Param | Type | Description |
1052
- | --- | --- | --- |
1053
- | params | <code>object</code> | Params to login Facebook |
1054
- | params.accessToken | <code>string</code> | Access token of the system manager |
1055
- | params.initialUserData | <code>object</code> | Object with roles default if sigin |
1056
- | params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
1057
-
1058
- **Example**
1059
- ```js
1060
- const API = require('@docbrasil/api-systemmanager');
1061
- ```
1062
- <a name="Login+google"></a>
1063
-
1064
- ### login.google(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1065
- Login with social login Google
1066
-
1067
- **Kind**: instance method of [<code>Login</code>](#Login)
1068
- **Returns**: <code>promise.&lt;object&gt;</code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
1069
- **Access**: public
1070
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1071
-
1072
- | Param | Type | Description |
1073
- | --- | --- | --- |
1074
- | params | <code>object</code> | Params to login Google |
1075
- | params.accessToken | <code>string</code> | Access token of the system manager |
1076
- | params.initialUserData | <code>object</code> | Object with roles default if sigin |
1077
- | params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
1078
-
1079
- **Example**
1080
- ```js
1081
- const API = require('@docbrasil/api-systemmanager');
1082
- ```
1083
- <a name="Login+apiKey"></a>
1084
-
1085
- ### login.apiKey(apikey) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1086
- Login with apikey
1087
-
1088
- **Kind**: instance method of [<code>Login</code>](#Login)
1089
- **Returns**: <code>promise.&lt;object&gt;</code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
1090
- **Access**: public
1091
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1092
-
1093
- | Param | Type | Description |
1094
- | --- | --- | --- |
1095
- | apikey | <code>string</code> | Access key |
1096
-
1097
- **Example**
1098
- ```js
1099
- const API = require('@docbrasil/api-systemmanager');
1100
- ```
1101
- <a name="Login+userPass"></a>
1102
-
1103
- ### login.userPass(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1104
- Login with user and password
1105
-
1106
- **Kind**: instance method of [<code>Login</code>](#Login)
1107
- **Returns**: <code>promise.&lt;object&gt;</code> - data<code>object</code> - data.auth true or false if we have the user authenticaited correctly<code>object</code> - data.user the logged user
1108
- **Access**: public
1109
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1110
-
1111
- | Param | Type | Description |
1112
- | --- | --- | --- |
1113
- | params | <code>object</code> | Object with user and password |
1114
- | params.username | <code>string</code> | Username or email of the user |
1115
- | params.password | <code>string</code> | Password of the user |
1116
- | params.orgname | <code>string</code> | The organame of the user |
1117
-
1118
- **Example**
1119
- ```js
1120
- const API = require('@docbrasil/api-systemmanager');
1121
1213
  username: 'ana.silva@gmail.com',
1122
1214
  password: '123456'
1123
- ```
1124
- <a name="Login+logout"></a>
1125
-
1126
- ### login.logout(session) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1127
- Logout user system manager
1128
-
1129
- **Kind**: instance method of [<code>Login</code>](#Login)
1130
- **Returns**: <code>promise.&lt;object&gt;</code> - } data<code>boolean</code> - data.success true|false
1131
- **Access**: public
1132
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1133
-
1134
- | Param | Type | Description |
1135
- | --- | --- | --- |
1136
- | session | <code>string</code> | Session, token JWT |
1137
-
1138
- **Example**
1139
- ```js
1140
- const API = require('@docbrasil/api-systemmanager');
1141
- ```
1142
- <a name="Login+recover"></a>
1143
-
1144
- ### login.recover(username) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1145
- Recover the password
1146
-
1147
- **Kind**: instance method of [<code>Login</code>](#Login)
1148
- **Returns**: <code>promise.&lt;object&gt;</code> - } data<code>boolean</code> - data.success true|false
1149
- **Access**: public
1150
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1151
-
1152
- | Param | Type | Description |
1153
- | --- | --- | --- |
1154
- | username | <code>string</code> | The username or email |
1155
-
1156
- **Example**
1157
- ```js
1158
- const API = require('@docbrasil/api-systemmanager');
1159
- ```
1160
- <a name="Session"></a>
1161
-
1162
- ## Session
1163
- Session manager of the API
1164
-
1165
- **Kind**: global class
1166
- <a name="Session+information"></a>
1167
-
1168
- ### session.information(sessionId, suSessionId) ⇒ <code>Promise</code>
1169
- Show information for session, thus validating the session (Valid token JWT)
1170
-
1171
- **Kind**: instance method of [<code>Session</code>](#Session)
1172
- **Access**: public
1173
-
1174
- | Param | Type | Default | Description |
1175
- | --- | --- | --- | --- |
1176
- | sessionId | <code>string</code> | | The user session (JWT Token) |
1177
- | suSessionId | <code>string</code> | <code>&quot;sessionId&quot;</code> | Given a JWT Token of a SU (SuperAdmin), allow to check session for another user. |
1178
-
1179
- **Example**
1180
- ```js
1181
- const API = require('@docbrasil/api-systemmanager');
1182
- ```
1183
1215
  <a name="Datasource"></a>
1184
1216
 
1185
1217
  ## Datasource
@@ -1207,7 +1239,15 @@ Method to get autocomplete data from a datasource
1207
1239
 
1208
1240
  **Example**
1209
1241
  ```js
1210
- const API = require('@docbrasil/api-systemmanager');
1211
1242
  orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
1212
1243
  dataSources: [{}],
1213
1244
  documents: [{}]
1245
+ const API = require('@docbrasil/api-systemmanager');
1246
+ const api = new API();
1247
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1248
+ const params = {
1249
+ orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
1250
+ dataSources: [{}],
1251
+ documents: [{}]
1252
+ };
1253
+ const retData = await api.user.datasource.autocomplete(params, session);
1214
1254
  ```
1215
1255
  <a name="Documents"></a>
1216
1256
 
@@ -1267,7 +1307,23 @@ Create new document
1267
1307
 
1268
1308
  **Example**
1269
1309
  ```js
1270
- const API = require('@docbrasil/api-systemmanager');
1271
1310
  orgname: 'cloundbrasil',
1272
1311
  areaId: '5edf9f8ee896b817e45b8dac',
1273
1312
  docId: '5edf86fbe896b817e45b8da6',
1274
1313
  fileName: 'foto',
1275
1314
  type: 'image/png',
1276
1315
  name: 'Fotografia',
1277
1316
  docTypeId = '5edf9f8ee896b817e45b8dac',
1278
1317
  bytes: 12345,
1279
1318
  signedUrl: 'https://s3.amazonaws.com...'
1280
1319
  docTypeFieldsData: {extraUser: '12349f8ee896b817e45b8dac'},
1281
1320
  orgId: '5df7f19618430c89a41a19d2',
1321
+ const API = require('@docbrasil/api-systemmanager');
1322
+ const api = new API();
1323
+ const params = {
1324
+ orgname: 'cloundbrasil',
1325
+ areaId: '5edf9f8ee896b817e45b8dac',
1326
+ docId: '5edf86fbe896b817e45b8da6',
1327
+ fileName: 'foto',
1328
+ type: 'image/png',
1329
+ name: 'Fotografia',
1330
+ docTypeId = '5edf9f8ee896b817e45b8dac',
1331
+ bytes: 12345,
1332
+ signedUrl: 'https://s3.amazonaws.com...'
1333
+ docTypeFieldsData: {extraUser: '12349f8ee896b817e45b8dac'},
1334
+ orgId: '5df7f19618430c89a41a19d2',
1335
+ };
1336
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1337
+ await api.user.document.add(params, session);
1282
1338
  ```
1283
1339
  <a name="Documents+find"></a>
1284
1340
 
@@ -1295,7 +1351,18 @@ const API = require('@docbrasil/api-systemmanager');
1295
1351
 
1296
1352
  **Example**
1297
1353
  ```js
1298
- const API = require('@docbrasil/api-systemmanager');
1299
1354
  index: 'extraCity',
1300
1355
  txtToSearch: 'São',
1301
1356
  docId: '5df7f19618430c89a41a19d2',
1302
1357
  docAreaId: '5edd11c46b6ce9729c2c297c',
1303
1358
  tag: 'Nome da cidade',
1304
1359
  orgId: '1234d01dc4af3941d42f8c5c'
1360
+ const API = require('@docbrasil/api-systemmanager');
1361
+ const api = new API();
1362
+ const params - {
1363
+ index: 'extraCity',
1364
+ txtToSearch: 'São',
1365
+ docId: '5df7f19618430c89a41a19d2',
1366
+ docAreaId: '5edd11c46b6ce9729c2c297c',
1367
+ tag: 'Nome da cidade',
1368
+ orgId: '1234d01dc4af3941d42f8c5c'
1369
+ };
1370
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1371
+ await api.user.document.findByIdAndRemove(params, session);
1305
1372
  ```
1306
1373
  <a name="Documents+findByIdAndRemove"></a>
1307
1374
 
@@ -1316,7 +1383,14 @@ Remove document by id
1316
1383
 
1317
1384
  **Example**
1318
1385
  ```js
1319
- const API = require('@docbrasil/api-systemmanager');
1320
1386
  docId: '5dadd01dc4af3941d42f8c5c',
1321
1387
  orgIdId: '5df7f19618430c89a41a19d2',
1388
+ const API = require('@docbrasil/api-systemmanager');
1389
+ const api = new API();
1390
+ const params - {
1391
+ docId: '5dadd01dc4af3941d42f8c5c',
1392
+ orgIdId: '5df7f19618430c89a41a19d2',
1393
+ };
1394
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1395
+ await api.user.document.findByIdAndRemove(params, session);
1322
1396
  ```
1323
1397
  <a name="Documents+findByIdsAndRemove"></a>
1324
1398
 
@@ -1338,7 +1412,14 @@ Remove documents
1338
1412
 
1339
1413
  **Example**
1340
1414
  ```js
1341
- const API = require('@docbrasil/api-systemmanager');
1342
1415
  documents: [{ _id: '5dadd01dc4af3941d42f8c5c' }],
1343
1416
  orgId: '5df7f19618430c89a41a19d2',
1417
+ const API = require('@docbrasil/api-systemmanager');
1418
+ const api = new API();
1419
+ const params - {
1420
+ documents: [{ _id: '5dadd01dc4af3941d42f8c5c' }],
1421
+ orgId: '5df7f19618430c89a41a19d2',
1422
+ };
1423
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1424
+ await api.user.document.findByIdsAndRemove(params, session);
1344
1425
  ```
1345
1426
  <a name="Documents+signedUrl"></a>
1346
1427
 
@@ -1364,11 +1445,30 @@ Request signed url url to put or get
1364
1445
 
1365
1446
  **Example**
1366
1447
  ```js
1367
- const API = require('@docbrasil/api-systemmanager');
1368
1448
  methodType: 'put',
1369
1449
  docId: '5dadd01dc4af3941d42f8c5c',
1370
1450
  docAreaId: '5df7f19618430c89a41a19d2',
1371
1451
  fileName: 'Foto',
1372
1452
  type: 'image/png'
1373
1453
  orgId: '5df7f19618430c89a41a19f8'
1454
+ const API = require('@docbrasil/api-systemmanager');
1455
+ const api = new API();
1456
+ const params - {
1457
+ methodType: 'put',
1458
+ docId: '5dadd01dc4af3941d42f8c5c',
1459
+ docAreaId: '5df7f19618430c89a41a19d2',
1460
+ fileName: 'Foto',
1461
+ type: 'image/png'
1462
+ orgId: '5df7f19618430c89a41a19f8'
1463
+ };
1464
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1465
+ // each doc: { docId, name, areaId, type, signedUrl }
1466
+ const { docs } = await api.user.document.signedUrl(params, session);
1374
1467
  ```
1375
1468
  **Example**
1376
1469
  ```js
1377
- const API = require('@docbrasil/api-systemmanager');
1378
1470
  methodType: 'get',
1379
1471
  document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf',
1472
+ const API = require('@docbrasil/api-systemmanager');
1473
+ const api = new API();
1474
+ const params - {
1475
+ methodType: 'get',
1476
+ document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf',
1477
+ };
1478
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1479
+ const base64Data = await api.user.document.signedUrl(params, session);
1380
1480
  ```
1381
1481
  <a name="Documents+signedUrls"></a>
1382
1482
 
@@ -1395,11 +1495,36 @@ Request signed url url to put or get
1395
1495
 
1396
1496
  **Example**
1397
1497
  ```js
1398
- const API = require('@docbrasil/api-systemmanager');
1399
1498
  methodType: 'put',
1400
1499
  orgId: '5df7f19618430c89a41a19f8'
1401
1500
  docs: [
1402
1501
  {
1403
1502
  docId: '5dadd01dc4af3941d42f8c5c',
1404
1503
  areaId: '5df7f19618430c89a41a19d2',
1405
1504
  name: 'Foto.png',
1406
1505
  type: 'image/png'
1407
1506
  }
1408
1507
  ]
1409
- ```
1410
- **Example**
1411
- ```js
1412
- const API = require('@docbrasil/api-systemmanager');
1413
1508
  methodType: 'get',
1414
1509
  docs: [
1415
1510
  { document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf' }
1416
1511
  ],
1512
+ const API = require('@docbrasil/api-systemmanager');
1513
+ const api = new API();
1514
+ const params - {
1515
+ methodType: 'put',
1516
+ orgId: '5df7f19618430c89a41a19f8'
1517
+ docs: [
1518
+ {
1519
+ docId: '5dadd01dc4af3941d42f8c5c',
1520
+ areaId: '5df7f19618430c89a41a19d2',
1521
+ name: 'Foto.png',
1522
+ type: 'image/png'
1523
+ }
1524
+ ]
1525
+ };
1526
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1527
+ // each doc: { docId, name, areaId, type, signedUrl }
1528
+ const { docs } = await api.user.document.signedUrls(params, session);
1529
+ ```
1530
+ **Example**
1531
+ ```js
1532
+ const API = require('@docbrasil/api-systemmanager');
1533
+ const api = new API();
1534
+ const params - {
1535
+ methodType: 'get',
1536
+ docs: [
1537
+ { document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf' }
1538
+ ],
1539
+ };
1540
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1541
+ const base64Data = await api.user.document.signedUrls(params, session);
1417
1542
  ```
1418
1543
  <a name="Documents+uploadSignedDocument"></a>
1419
1544
 
@@ -1420,7 +1545,21 @@ Uploads the file
1420
1545
 
1421
1546
  **Example**
1422
1547
  ```js
1423
- const FS = require('fs');
1424
1548
  content: FS.readFileSync(Path.join(__dirname, '.mypdf.pdf')),
1425
1549
  signedUrl: 'https://signedurl.com/token...',
1426
1550
  type: 'application/pdf'
1427
1551
  - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
1428
1552
  - loaded: The number of bytes of the file that have been uploaded.
1429
1553
  - total: The total number of bytes in the file.
1554
+ const FS = require('fs');
1555
+ const Path = require('path');
1556
+ const API = require('@docbrasil/api-systemmanager');
1557
+ const api = new API();
1558
+ const params - {
1559
+ content: FS.readFileSync(Path.join(__dirname, '.mypdf.pdf')),
1560
+ signedUrl: 'https://signedurl.com/token...',
1561
+ type: 'application/pdf'
1562
+ };
1563
+ const retData = await api.user.document.uploadSignedDocument(params);
1564
+
1565
+ onUploadProgress return the progressEvent
1566
+ - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
1567
+ - loaded: The number of bytes of the file that have been uploaded.
1568
+ - total: The total number of bytes in the file.
1430
1569
  ```
1431
1570
  <a name="Documents+checkPrimaryKeys"></a>
1432
1571
 
@@ -1428,7 +1567,8 @@ const FS = require('fs');
1428
1567
  **Kind**: instance method of [<code>Documents</code>](#Documents)
1429
1568
  **Returns**: <code>Promise.&lt;array&gt;</code> - Return the array of the documents that are repeated. If not document is repeaded, then if returns an empty array.<code>array.&lt;string&gt;</code> - id the id of the repeated document
1430
1569
  **Access**: public
1431
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1570
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
1571
+ Checks if a document can be added and it does not repeat its primary key
1432
1572
 
1433
1573
  | Param | Type | Description |
1434
1574
  | --- | --- | --- |
@@ -1443,7 +1583,17 @@ const FS = require('fs');
1443
1583
 
1444
1584
  **Example**
1445
1585
  ```js
1446
- const API = require('@docbrasil/api-systemmanager');
1447
1586
  docs: [{ id: '5dadd01dc4af3941d42f8c5c', docTypeFields, docTypeFieldsData }],
1448
1587
  orgId: '5df7f19618430c89a41a19d2',
1449
1588
  docTypeId: '5df7f19618430c89a41a19d5',
1589
+ const API = require('@docbrasil/api-systemmanager');
1590
+ const api = new API();
1591
+ const docTypeFields = [...]; // the doc type fields array
1592
+ const docTypeFieldsData = {...}; // the data of this fields
1593
+ const params - {
1594
+ docs: [{ id: '5dadd01dc4af3941d42f8c5c', docTypeFields, docTypeFieldsData }],
1595
+ orgId: '5df7f19618430c89a41a19d2',
1596
+ docTypeId: '5df7f19618430c89a41a19d5',
1597
+ };
1598
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1599
+ const retDocs = await api.user.document.checkPrimaryKeys(params, session);
1450
1600
  ```
1451
1601
  <a name="Documents+searchDocuments"></a>
1452
1602
 
@@ -1464,7 +1614,14 @@ Method to search documents for
1464
1614
 
1465
1615
  **Example**
1466
1616
  ```js
1467
- const API = require('@docbrasil/api-systemmanager');
1468
1617
  query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1469
1618
  orgId: '55e4a3bd6be6b45210833fae',
1619
+ const API = require('@docbrasil/api-systemmanager');
1620
+ const api = new API();
1621
+ const params = {
1622
+ query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1623
+ orgId: '55e4a3bd6be6b45210833fae',
1624
+ };
1625
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1626
+ const retSearch = await api.user.document.searchDocuments(params, session);
1470
1627
  ```
1471
1628
  <a name="Users"></a>
1472
1629
 
@@ -1532,7 +1689,14 @@ Method to add a notification token
1532
1689
 
1533
1690
  **Example**
1534
1691
  ```js
1535
- const API = require('@docbrasil/api-systemmanager');
1536
1692
  token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
1537
1693
  type: 'FCM_WEB'
1694
+ const API = require('@docbrasil/api-systemmanager');
1695
+ const api = new API();
1696
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1697
+ const params = {
1698
+ token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
1699
+ type: 'FCM_WEB'
1700
+ };
1701
+ const retData = await api.user.notification.addToken(params, session);
1538
1702
  ```
1539
1703
  <a name="Organization"></a>
1540
1704
 
@@ -1569,7 +1733,15 @@ Update avatar of organization by session of user not allow session user SU
1569
1733
 
1570
1734
  **Example**
1571
1735
  ```js
1572
- const API = require('@docbrasil/api-systemmanager');
1573
1736
  orgId: '5dadd01dc4af3941d42f8c5c',
1574
1737
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
1575
1738
  type: 'image/png',
1739
+ const API = require('@docbrasil/api-systemmanager');
1740
+ const api = new API();
1741
+ const params = {
1742
+ orgId: '5dadd01dc4af3941d42f8c5c',
1743
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
1744
+ type: 'image/png',
1745
+ };
1746
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1747
+ await api.admin.organizations.upsertAvatar(params, session);
1576
1748
  ```
1577
1749
  <a name="Organization+removeAvatar"></a>
1578
1750
 
@@ -1587,7 +1759,11 @@ Remove avatar of user by session of user not allow session user SU
1587
1759
 
1588
1760
  **Example**
1589
1761
  ```js
1590
- const API = require('@docbrasil/api-systemmanager');
1762
+ const API = require('@docbrasil/api-systemmanager');
1763
+ const api = new API();
1764
+ const orgId = '5dadd01dc4af3941d42f8c5c';
1765
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1766
+ await api.admin.organizations.removeAvatar(orgId, session);
1591
1767
  ```
1592
1768
  <a name="Organization+findById"></a>
1593
1769
 
@@ -1605,7 +1781,11 @@ Find organization by id
1605
1781
 
1606
1782
  **Example**
1607
1783
  ```js
1608
- const API = require('@docbrasil/api-systemmanager');
1784
+ const API = require('@docbrasil/api-systemmanager');
1785
+ const api = new API();
1786
+ const orgId = '80443245000122';
1787
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1788
+ await api.user.organization.findById(idCard, session);
1609
1789
  ```
1610
1790
  <a name="Organization+idCardExist"></a>
1611
1791
 
@@ -1623,7 +1803,11 @@ Check if id card exist
1623
1803
 
1624
1804
  **Example**
1625
1805
  ```js
1626
- const API = require('@docbrasil/api-systemmanager');
1806
+ const API = require('@docbrasil/api-systemmanager');
1807
+ const api = new API();
1808
+ const idCard = '80443245000122';
1809
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1810
+ await api.user.organization.idCardExist(idCard, session);
1627
1811
  ```
1628
1812
  <a name="Organization+upsertAvatar"></a>
1629
1813
 
@@ -1643,7 +1827,14 @@ Update avatar of organization by session of user not allow session user SU
1643
1827
 
1644
1828
  **Example**
1645
1829
  ```js
1646
- const API = require('@docbrasil/api-systemmanager');
1647
1830
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
1648
1831
  type: 'image/png',
1832
+ const API = require('@docbrasil/api-systemmanager');
1833
+ const api = new API();
1834
+ const params = {
1835
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
1836
+ type: 'image/png',
1837
+ };
1838
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1839
+ await api.user.profile.updateAvatar(params, session);
1649
1840
  ```
1650
1841
  <a name="Organization+removeAvatar"></a>
1651
1842
 
@@ -1660,7 +1851,10 @@ Remove avatar of user by session of user not allow session user SU
1660
1851
 
1661
1852
  **Example**
1662
1853
  ```js
1663
- const API = require('@docbrasil/api-systemmanager');
1854
+ const API = require('@docbrasil/api-systemmanager');
1855
+ const api = new API();
1856
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1857
+ await api.user.profile.removeAvatar(session);
1664
1858
  ```
1665
1859
  <a name="Organization+callFetch"></a>
1666
1860
 
@@ -1680,7 +1874,14 @@ Call URL internal, need auth JWT (session)
1680
1874
 
1681
1875
  **Example**
1682
1876
  ```js
1683
- const API = require('@docbrasil/api-systemmanager');
1684
1877
  url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
1685
1878
  method: 'POST'
1879
+ const API = require('@docbrasil/api-systemmanager');
1880
+ const api = new API();
1881
+
1882
+ const params = {
1883
+ url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
1884
+ method: 'POST'
1885
+ }
1886
+ await api.user.organization.callFetchs(params, session);
1686
1887
  ```
1687
1888
  <a name="Process"></a>
1688
1889
 
@@ -1713,7 +1914,15 @@ Start process
1713
1914
 
1714
1915
  **Example**
1715
1916
  ```js
1716
- const API = require('@docbrasil/api-systemmanager');
1717
1917
  processId: '5dadd01dc4af3941d42f8c5c',
1718
1918
  orgId: '5edd11c46b6ce9729c2c297c',
1719
1919
  payload: {}
1920
+ const API = require('@docbrasil/api-systemmanager');
1921
+ const api = new API();
1922
+ const params = {
1923
+ processId: '5dadd01dc4af3941d42f8c5c',
1924
+ orgId: '5edd11c46b6ce9729c2c297c',
1925
+ payload: {}
1926
+ }
1927
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1928
+ await api.user.process.start(params, session);
1720
1929
  ```
1721
1930
  <a name="Process+getProcessProperties"></a>
1722
1931
 
@@ -1733,7 +1942,14 @@ Get process properties of process
1733
1942
 
1734
1943
  **Example**
1735
1944
  ```js
1736
- const API = require('@docbrasil/api-systemmanager');
1737
1945
  processId: '5dadd01dc4af3941d42f8c5c',
1738
1946
  orgId: '5edd11c46b6ce9729c2c297c',
1947
+ const API = require('@docbrasil/api-systemmanager');
1948
+ const api = new API();
1949
+ const params = {
1950
+ processId: '5dadd01dc4af3941d42f8c5c',
1951
+ orgId: '5edd11c46b6ce9729c2c297c',
1952
+ }
1953
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1954
+ await api.user.process.getProcessProperties(params, session);
1739
1955
  ```
1740
1956
  <a name="Process+getOrgProcessSearchInfo"></a>
1741
1957
 
@@ -1741,7 +1957,8 @@ const API = require('@docbrasil/api-systemmanager');
1741
1957
  Get the search info of a organization process
1742
1958
 
1743
1959
  **Kind**: instance method of [<code>Process</code>](#Process)
1744
- **Returns**: <code>Promise</code> - the search info result<code>string</code> - name the name of the organization process<code>object</code> - processIndexFields the list of fields to index<code>object</code> - processParticipantsGroup the permissions in this organization process<code>object</code> - stepsProperties the organization process steps properties<code>string</code> - _id the same organization id
1960
+ **Returns**: <code>Promise</code> - the search info result<code>string</code> - name the name of the organization process<code>object</code> - processIndexFields the list of fields to index<code>object</code> - processParticipantsGroup the permissions in this organization process<code>object</code> - stepsProperties the organization process steps properties<code>string</code> - _id the same organization id
1961
+ @
1745
1962
  **Access**: public
1746
1963
  **Author**: CloudBrasil <abernardo.br@gmail.com>
1747
1964
 
@@ -1754,7 +1971,14 @@ Get the search info of a organization process
1754
1971
 
1755
1972
  **Example**
1756
1973
  ```js
1757
- const API = require('@docbrasil/api-systemmanager');
1758
1974
  orgProcessId: '5dadd01dc4af3941d42f8c67',
1759
1975
  orgId: '5edd11c46b6ce9729c2c297c',
1976
+ const API = require('@docbrasil/api-systemmanager');
1977
+ const api = new API();
1978
+ const params = {
1979
+ orgProcessId: '5dadd01dc4af3941d42f8c67',
1980
+ orgId: '5edd11c46b6ce9729c2c297c',
1981
+ }
1982
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1983
+ const retSearchInfo = await api.user.process.getOrgProcessSearchInfo(params, session);
1760
1984
  ```
1761
1985
  <a name="Register"></a>
1762
1986
 
@@ -1782,7 +2006,12 @@ Class for user registration in a user
1782
2006
 
1783
2007
  **Example**
1784
2008
  ```js
1785
- const API = require('@docbrasil/api-systemmanager');
1786
2009
  registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...'
2010
+ const API = require('@docbrasil/api-systemmanager');
2011
+ const api = new API();
2012
+ const params = {
2013
+ registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...'
2014
+ };
2015
+ const orgname = await api.user.register.getOrgname(params);
1787
2016
  ```
1788
2017
  <a name="Register+validateEmail"></a>
1789
2018
 
@@ -1802,7 +2031,13 @@ Method to find task by id
1802
2031
 
1803
2032
  **Example**
1804
2033
  ```js
1805
- const API = require('@docbrasil/api-systemmanager');
1806
2034
  registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
1807
2035
  email: 'myemail@company.com'
2036
+ const API = require('@docbrasil/api-systemmanager');
2037
+ const api = new API();
2038
+ const params = {
2039
+ registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
2040
+ email: 'myemail@company.com'
2041
+ };
2042
+ const retData = await api.user.register.validateEmail(params);
1808
2043
  ```
1809
2044
  <a name="Register+execute"></a>
1810
2045
 
@@ -1836,60 +2071,30 @@ Method to register a user
1836
2071
 
1837
2072
  **Example**
1838
2073
  ```js
1839
- const API = require('@docbrasil/api-systemmanager');
1840
2074
  "registerId": 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
1841
2075
  "type": 'sign',
1842
2076
  "login": false,
1843
2077
  "emailInfo": {
1844
2078
  "code": "5974",
1845
2079
  "email": "cbtoto_1@mailinator.com"
1846
2080
  },
1847
2081
  "registerData": {
1848
2082
  "name": "Augusto Totlo",
1849
2083
  "registerEmail": "cbtoto_1@mailinator.com",
1850
2084
  "phone": "",
1851
2085
  "idcard": "",
1852
2086
  "dob": "1978-01-12T03:00:00.000Z",
1853
2087
  "registerPassword": "123456",
1854
2088
  "emailValidationCode": "5974",
1855
2089
  "phoneValidationCode": "",
1856
2090
  "language": "en-US",
1857
2091
  "timezone": "Europe/Dublin"
1858
2092
  }
1859
2093
  };
1860
- ```
1861
- <a name="TaskAvailable"></a>
1862
-
1863
- ## TaskAvailable
1864
- Class for available tasks, permission user
1865
-
1866
- **Kind**: global class
1867
-
1868
- * [TaskAvailable](#TaskAvailable)
1869
- * [.find(params, session)](#TaskAvailable+find) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
1870
- * [.claim(params, session)](#TaskAvailable+claim) ⇒ <code>promise</code> \| <code>boolean</code>
1871
-
1872
- <a name="TaskAvailable+find"></a>
1873
-
1874
- ### taskAvailable.find(params, session) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
1875
- Method to find available tasks for a user
1876
-
1877
- **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
1878
- **Returns**: <code>promise</code> - returned data from the search<code>number</code> - count the count of items searched<code>array.&lt;object&gt;</code> - items the items returned from search<code>number</code> - page the page of the search (on pagination), zero indexed<code>number</code> - perPage how many items per page
1879
- **Access**: public
1880
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1881
-
1882
- | Param | Type | Description |
1883
- | --- | --- | --- |
1884
- | params | <code>object</code> | Params to get task |
1885
- | params.query | <code>object</code> | Search process query |
1886
- | params.orgId | <code>object</code> | Organization id (_id database) |
1887
- | session | <code>string</code> | Session, token JWT |
1888
-
1889
- **Example**
1890
- ```js
1891
- const API = require('@docbrasil/api-systemmanager');
1892
2094
  query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
1893
2095
  orgId: '55e4a3bd6be6b45210833fae',
1894
- ```
1895
- <a name="TaskAvailable+claim"></a>
1896
-
1897
- ### taskAvailable.claim(params, session) ⇒ <code>promise</code> \| <code>boolean</code>
1898
- Method for a user to claim an available task
1899
-
1900
- **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
1901
- **Returns**: <code>promise</code> - returned data from the method call<code>boolean</code> - success true|false if the method was successful
1902
- **Access**: public
1903
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1904
-
1905
- | Param | Type | Description |
1906
- | --- | --- | --- |
1907
- | params | <code>object</code> | Params to get task |
1908
- | params.taskId | <code>object</code> | the task id to claim |
1909
- | params.orgname | <code>object</code> | Organization slug (short name of the orgnization) |
1910
- | session | <code>string</code> | Session, token JWT |
1911
-
1912
- **Example**
1913
- ```js
1914
- const API = require('@docbrasil/api-systemmanager');
1915
2096
  taskId: '55e4a3bd6be6b45210833f67',
1916
2097
  orgname: 'acme',
2098
+ const API = require('@docbrasil/api-systemmanager');
2099
+ const api = new API();
2100
+ const params ={
2101
+ "registerId": 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
2102
+ "type": 'sign',
2103
+ "login": false,
2104
+ "emailInfo": {
2105
+ "code": "5974",
2106
+ "email": "cbtoto_1@mailinator.com"
2107
+ },
2108
+ "registerData": {
2109
+ "name": "Augusto Totlo",
2110
+ "registerEmail": "cbtoto_1@mailinator.com",
2111
+ "phone": "",
2112
+ "idcard": "",
2113
+ "dob": "1978-01-12T03:00:00.000Z",
2114
+ "registerPassword": "123456",
2115
+ "emailValidationCode": "5974",
2116
+ "phoneValidationCode": "",
2117
+ "language": "en-US",
2118
+ "timezone": "Europe/Dublin"
2119
+ }
2120
+ };
2121
+ const retData = await api.user.register.execute(params);
1917
2122
  ```
1918
2123
  <a name="Task"></a>
1919
2124
 
@@ -1922,7 +2127,15 @@ Method to find task by id
1922
2127
 
1923
2128
  **Example**
1924
2129
  ```js
1925
- const API = require('@docbrasil/api-systemmanager');
1926
2130
  processId: '5dadd01dc4af3941d42f8c5c',
1927
2131
  taskId: '5df7f19618430c89a41a19d2',
1928
2132
  orgId: '55e4a3bd6be6b45210833fae',
2133
+ const API = require('@docbrasil/api-systemmanager');
2134
+ const api = new API();
2135
+ const params = {
2136
+ processId: '5dadd01dc4af3941d42f8c5c',
2137
+ taskId: '5df7f19618430c89a41a19d2',
2138
+ orgId: '55e4a3bd6be6b45210833fae',
2139
+ };
2140
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2141
+ await api.user.task.findById(params, session);
1929
2142
  ```
1930
2143
  <a name="Task+findByIdAndUpdate"></a>
1931
2144
 
@@ -1948,7 +2161,17 @@ Find task by id and update
1948
2161
 
1949
2162
  **Example**
1950
2163
  ```js
1951
- const API = require('@docbrasil/api-systemmanager');
1952
2164
  userId: '5739d4c6ccb0ebc61f2a9557',
1953
2165
  processId: '5dadd01dc4af3941d42f8c5c',
1954
2166
  taskId: '5df7f19618430c89a41a19d2',
1955
2167
  action: 1,
1956
2168
  formData: {name: 'CloudBrasil'},
2169
+ const API = require('@docbrasil/api-systemmanager');
2170
+ const api = new API();
2171
+ const params = {
2172
+ userId: '5739d4c6ccb0ebc61f2a9557',
2173
+ processId: '5dadd01dc4af3941d42f8c5c',
2174
+ taskId: '5df7f19618430c89a41a19d2',
2175
+ action: 1,
2176
+ formData: {name: 'CloudBrasil'},
2177
+ };
2178
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2179
+ await api.user.task.findByIdAndUpdate(params, session);
1957
2180
  ```
1958
2181
  <a name="Task+executeActionFinalize"></a>
1959
2182
 
@@ -1970,7 +2193,83 @@ Find task by id and update
1970
2193
 
1971
2194
  **Example**
1972
2195
  ```js
1973
- const API = require('@docbrasil/api-systemmanager');
1974
2196
  taskId: '5df7f19618430c89a41a19d2',
1975
2197
  actionGuid: 'b3823a2ae52c7a05bfb9590fe427038d'
1976
2198
  orgId: '5df7f19618430c89a41a1bc3',
1977
2199
  body: {}',
2200
+ const API = require('@docbrasil/api-systemmanager');
2201
+ const api = new API();
2202
+ const params = {
2203
+ taskId: '5df7f19618430c89a41a19d2',
2204
+ actionGuid: 'b3823a2ae52c7a05bfb9590fe427038d'
2205
+ orgId: '5df7f19618430c89a41a1bc3',
2206
+ body: {}',
2207
+ };
2208
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2209
+ await api.user.task.executeActionFinalize(params, session);
2210
+ ```
2211
+ <a name="TaskAvailable"></a>
2212
+
2213
+ ## TaskAvailable
2214
+ Class for available tasks, permission user
2215
+
2216
+ **Kind**: global class
2217
+
2218
+ * [TaskAvailable](#TaskAvailable)
2219
+ * [.find(params, session)](#TaskAvailable+find) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
2220
+ * [.claim(params, session)](#TaskAvailable+claim) ⇒ <code>promise</code> \| <code>boolean</code>
2221
+
2222
+ <a name="TaskAvailable+find"></a>
2223
+
2224
+ ### taskAvailable.find(params, session) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
2225
+ Method to find available tasks for a user
2226
+
2227
+ **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
2228
+ **Returns**: <code>promise</code> - returned data from the search<code>number</code> - count the count of items searched<code>array.&lt;object&gt;</code> - items the items returned from search<code>number</code> - page the page of the search (on pagination), zero indexed<code>number</code> - perPage how many items per page
2229
+ **Access**: public
2230
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
2231
+
2232
+ | Param | Type | Description |
2233
+ | --- | --- | --- |
2234
+ | params | <code>object</code> | Params to get task |
2235
+ | params.query | <code>object</code> | Search process query |
2236
+ | params.orgId | <code>object</code> | Organization id (_id database) |
2237
+ | session | <code>string</code> | Session, token JWT |
2238
+
2239
+ **Example**
2240
+ ```js
2241
+ const API = require('@docbrasil/api-systemmanager');
2242
+ const api = new API();
2243
+ const params = {
2244
+ query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2245
+ orgId: '55e4a3bd6be6b45210833fae',
2246
+ };
2247
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2248
+ const retSearch = await api.user.task.available.find(params, session);
2249
+ ```
2250
+ <a name="TaskAvailable+claim"></a>
2251
+
2252
+ ### taskAvailable.claim(params, session) ⇒ <code>promise</code> \| <code>boolean</code>
2253
+ Method for a user to claim an available task
2254
+
2255
+ **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
2256
+ **Returns**: <code>promise</code> - returned data from the method call<code>boolean</code> - success true|false if the method was successful
2257
+ **Access**: public
2258
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
2259
+
2260
+ | Param | Type | Description |
2261
+ | --- | --- | --- |
2262
+ | params | <code>object</code> | Params to get task |
2263
+ | params.taskId | <code>object</code> | the task id to claim |
2264
+ | params.orgname | <code>object</code> | Organization slug (short name of the orgnization) |
2265
+ | session | <code>string</code> | Session, token JWT |
2266
+
2267
+ **Example**
2268
+ ```js
2269
+ const API = require('@docbrasil/api-systemmanager');
2270
+ const api = new API();
2271
+ const params = {
2272
+ taskId: '55e4a3bd6be6b45210833f67',
2273
+ orgname: 'acme',
2274
+ };
2275
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2276
+ const success = await api.user.task.available.claim(params, session);
1978
2277
  ```
1979
2278
  <a name="User"></a>
1980
2279
 
@@ -2005,7 +2304,14 @@ Update avatar of user by session of user not allow session user SU
2005
2304
 
2006
2305
  **Example**
2007
2306
  ```js
2008
- const API = require('@docbrasil/api-systemmanager');
2009
2307
  avatar: '55e4a3bd6be6b45210833fae',
2010
2308
  type: '123456',
2309
+ const API = require('@docbrasil/api-systemmanager');
2310
+ const api = new API();
2311
+ const params = {
2312
+ avatar: '55e4a3bd6be6b45210833fae',
2313
+ type: '123456',
2314
+ };
2315
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2316
+ await api.user.profile.updateAvatar(params, session);
2011
2317
  ```
2012
2318
  <a name="User+removeAvatar"></a>
2013
2319
 
@@ -2022,7 +2328,10 @@ Remove avatar of user by session of user not allow session user SU
2022
2328
 
2023
2329
  **Example**
2024
2330
  ```js
2025
- const API = require('@docbrasil/api-systemmanager');
2331
+ const API = require('@docbrasil/api-systemmanager');
2332
+ const api = new API();
2333
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2334
+ await api.user.profile.removeAvatar(session);
2026
2335
  ```
2027
2336
  <a name="User+removeSignature"></a>
2028
2337
 
@@ -2039,7 +2348,10 @@ Remove the signature of user by session
2039
2348
 
2040
2349
  **Example**
2041
2350
  ```js
2042
- const API = require('@docbrasil/api-systemmanager');
2351
+ const API = require('@docbrasil/api-systemmanager');
2352
+ const api = new API();
2353
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2354
+ await api.user.profile.removeSignature(session);
2043
2355
  ```
2044
2356
  <a name="User+saveSignature"></a>
2045
2357
 
@@ -2059,7 +2371,23 @@ Sava a new signature of user by session
2059
2371
 
2060
2372
  **Example**
2061
2373
  ```js
2062
- const API = require('@docbrasil/api-systemmanager');
2063
2374
  type: 'CURSIVE',
2064
2375
  file: 'allura:Mary John Heart'
2065
2376
  type: 'HANDWRITE',
2066
2377
  file: 'iVBORw0KGgoAAAANSUhEUgAAAj...'
2378
+ const API = require('@docbrasil/api-systemmanager');
2379
+ const api = new API();
2380
+ const data = {
2381
+ type: 'CURSIVE',
2382
+ file: 'allura:Mary John Heart'
2383
+ };
2384
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2385
+ await api.user.profile.saveSignature(data, session);
2386
+
2387
+ const API = require('@docbrasil/api-systemmanager');
2388
+ const api = new API();
2389
+ const data = {
2390
+ type: 'HANDWRITE',
2391
+ file: 'iVBORw0KGgoAAAANSUhEUgAAAj...'
2392
+ };
2393
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2394
+ await api.user.profile.saveSignature(session);
2067
2395
  ```
2068
2396
  <a name="User+findByIdAndUpdate"></a>
2069
2397
 
@@ -2093,7 +2421,13 @@ Update a user profile by id
2093
2421
 
2094
2422
  **Example**
2095
2423
  ```js
2096
- const API = require('@docbrasil/api-systemmanager');
2097
2424
  name: 'New Name'
2425
+ const API = require('@docbrasil/api-systemmanager');
2426
+ const api = new API();
2427
+ const params = {
2428
+ name: 'New Name'
2429
+ };
2430
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2431
+ await api.user.profile.findByIdAndUpdate(params, session);
2098
2432
  ```
2099
2433
  <a name="User+changeOrganization"></a>
2100
2434
 
@@ -2111,5 +2445,9 @@ Change a user's organization
2111
2445
 
2112
2446
  **Example**
2113
2447
  ```js
2114
- const API = require('@docbrasil/api-systemmanager');
2448
+ const API = require('@docbrasil/api-systemmanager');
2449
+ const api = new API();
2450
+ const id = '616eccaaa9360a05293b10fe';
2451
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2452
+ await api.user.changeOrganization.updateAvatar(id, session);
2115
2453
  ```