@docbrasil/api-systemmanager 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/api/user/document.js +65 -1
  2. package/dist/bundle.cjs +73 -11
  3. package/dist/bundle.mjs +1 -1
  4. package/doc/api.md +1286 -509
  5. package/docs/Admin.html +1 -1
  6. package/docs/AdminDocuments.html +1 -1
  7. package/docs/AdminForm.html +1 -1
  8. package/docs/AdminLists.html +1 -1
  9. package/docs/AdminMessage.html +1 -1
  10. package/docs/AdminNotification.html +1 -1
  11. package/docs/AdminPlugin.html +1 -1
  12. package/docs/AdminPolicy.html +1 -1
  13. package/docs/AdminProcesses.html +1 -1
  14. package/docs/AdminTask.html +1 -1
  15. package/docs/AdminUser.html +1 -1
  16. package/docs/Application.html +1 -1
  17. package/docs/Datasource.html +1 -1
  18. package/docs/Dispatch.html +1 -1
  19. package/docs/Documents.html +470 -9
  20. package/docs/External.html +1 -1
  21. package/docs/GeoLocation.html +1 -1
  22. package/docs/Help.html +1 -1
  23. package/docs/Login.html +1 -1
  24. package/docs/MyTasks.html +603 -0
  25. package/docs/Notification.html +1 -1
  26. package/docs/Organization.html +1 -1
  27. package/docs/Page.html +1 -1
  28. package/docs/Process.html +1 -1
  29. package/docs/Register.html +1 -1
  30. package/docs/Session.html +1 -1
  31. package/docs/Task.html +5 -5
  32. package/docs/TaskAvailable.html +1 -1
  33. package/docs/Updates.html +1 -1
  34. package/docs/User.html +1 -1
  35. package/docs/Users.html +1 -1
  36. package/docs/admin_doctypes.js.html +1 -1
  37. package/docs/admin_document.js.html +1 -1
  38. package/docs/admin_form.js.html +1 -1
  39. package/docs/admin_index.js.html +1 -1
  40. package/docs/admin_list.js.html +1 -1
  41. package/docs/admin_message.js.html +1 -1
  42. package/docs/admin_notification.js.html +1 -1
  43. package/docs/admin_organization.js.html +1 -1
  44. package/docs/admin_plugin.js.html +1 -1
  45. package/docs/admin_policy.js.html +1 -1
  46. package/docs/admin_processes.js.html +1 -1
  47. package/docs/admin_task.js.html +1 -1
  48. package/docs/admin_user.js.html +1 -1
  49. package/docs/dispatch.js.html +1 -1
  50. package/docs/external.js.html +1 -1
  51. package/docs/general_geoLocation.js.html +1 -1
  52. package/docs/general_index.js.html +1 -1
  53. package/docs/index.html +1 -1
  54. package/docs/login.js.html +1 -1
  55. package/docs/session.js.html +1 -1
  56. package/docs/user_application.js.html +1 -1
  57. package/docs/user_datasource.js.html +1 -1
  58. package/docs/user_document.js.html +66 -2
  59. package/docs/user_help.js.html +1 -1
  60. package/docs/user_index.js.html +1 -1
  61. package/docs/user_my_tasks.js.html +212 -0
  62. package/docs/user_notification.js.html +1 -1
  63. package/docs/user_organization.js.html +1 -1
  64. package/docs/user_page.js.html +1 -1
  65. package/docs/user_process.js.html +1 -1
  66. package/docs/user_register.js.html +1 -1
  67. package/docs/user_task.js.html +3 -1
  68. package/docs/user_task_available.js.html +1 -1
  69. package/docs/user_updates.js.html +1 -1
  70. package/docs/user_user.js.html +1 -1
  71. package/docs/utils_promises.js.html +1 -1
  72. package/package.json +1 -1
  73. package/tests/documents_002.spec.js +107 -0
package/doc/api.md CHANGED
@@ -37,24 +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
- <dt><a href="#External">External</a></dt>
44
- <dd><p>Class for documents, permission user</p>
45
- </dd>
46
40
  <dt><a href="#GeoLocation">GeoLocation</a></dt>
47
41
  <dd><p>General Class for user, permission organization</p>
48
42
  </dd>
49
43
  <dt><a href="#Users">Users</a></dt>
50
44
  <dd><p>API request, user permission level</p>
51
45
  </dd>
52
- <dt><a href="#Login">Login</a></dt>
53
- <dd><p>Login manager</p>
54
- </dd>
55
- <dt><a href="#Session">Session</a></dt>
56
- <dd><p>Session manager of the API</p>
57
- </dd>
58
46
  <dt><a href="#Application">Application</a></dt>
59
47
  <dd><p>Class for Applications, permission user</p>
60
48
  </dd>
@@ -88,18 +76,30 @@
88
76
  <dt><a href="#Register">Register</a></dt>
89
77
  <dd><p>Class for user registration in a user</p>
90
78
  </dd>
91
- <dt><a href="#TaskAvailable">TaskAvailable</a></dt>
92
- <dd><p>Class for available tasks, permission user</p>
93
- </dd>
94
79
  <dt><a href="#Task">Task</a></dt>
95
80
  <dd><p>Class for task, permission user</p>
96
81
  </dd>
82
+ <dt><a href="#TaskAvailable">TaskAvailable</a></dt>
83
+ <dd><p>Class for available tasks, permission user</p>
84
+ </dd>
97
85
  <dt><a href="#Updates">Updates</a></dt>
98
86
  <dd><p>Class for user registration in a user</p>
99
87
  </dd>
100
88
  <dt><a href="#User">User</a></dt>
101
89
  <dd><p>Class for user, permission user</p>
102
90
  </dd>
91
+ <dt><a href="#Dispatch">Dispatch</a></dt>
92
+ <dd><p>Api dispatch manager</p>
93
+ </dd>
94
+ <dt><a href="#External">External</a></dt>
95
+ <dd><p>Class for documents, permission user</p>
96
+ </dd>
97
+ <dt><a href="#Login">Login</a></dt>
98
+ <dd><p>Login manager</p>
99
+ </dd>
100
+ <dt><a href="#Session">Session</a></dt>
101
+ <dd><p>Session manager of the API</p>
102
+ </dd>
103
103
  </dl>
104
104
 
105
105
  <a name="AdminDocuments"></a>
@@ -135,7 +135,33 @@ Advanced search of document in elastic search ussing system manager
135
135
 
136
136
  **Example**
137
137
  ```js
138
- const API = require('@docbrasil/api-systemmanager');
139
138
  docId: '5edd11c46b6ce9729c2c297c',
140
139
  query: {
141
140
  "query": {
142
141
  "bool": {
143
142
  "minimum_should_match": 1,
144
143
  "should": [
145
144
  {
146
145
  "match": {
147
146
  "locationText.keyword": {
148
147
  "query": "sao pau"
149
148
  }
150
149
  }
151
150
  },
152
151
  {
153
152
  "wildcard": {
154
153
  "locationText.normalized": "*sao pau*"
155
154
  }
156
155
  }
157
156
  ]
158
157
  }
159
158
  }
160
159
  }
160
+ const API = require('@docbrasil/api-systemmanager');
161
+ const api = new API();
162
+ const params = {
163
+ docId: '5edd11c46b6ce9729c2c297c',
164
+ query: {
165
+ "query": {
166
+ "bool": {
167
+ "minimum_should_match": 1,
168
+ "should": [
169
+ {
170
+ "match": {
171
+ "locationText.keyword": {
172
+ "query": "sao pau"
173
+ }
174
+ }
175
+ },
176
+ {
177
+ "wildcard": {
178
+ "locationText.normalized": "*sao pau*"
179
+ }
180
+ }
181
+ ]
182
+ }
183
+ }
184
+ }
185
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
186
+ await api.admin.document.advancedSearch(params, session);
161
187
  ```
162
188
  <a name="AdminDocuments+findById"></a>
163
189
 
@@ -155,7 +181,14 @@ Get document by id
155
181
 
156
182
  **Example**
157
183
  ```js
158
- const API = require('@docbrasil/api-systemmanager');
159
184
  docId: '5edd11c46b6ce9729c2c297c',
160
185
  orgId: '55e4a3bd6be6b45210833fae'
186
+ const API = require('@docbrasil/api-systemmanager');
187
+ const api = new API();
188
+ const params = {
189
+ docId: '5edd11c46b6ce9729c2c297c',
190
+ orgId: '55e4a3bd6be6b45210833fae'
191
+ };
192
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
193
+ await api.admin.document.findById(params, session);
161
194
  ```
162
195
  <a name="AdminDocuments+signedUrl"></a>
163
196
 
@@ -176,11 +209,25 @@ Request signed url url to put or get
176
209
 
177
210
  **Example**
178
211
  ```js
179
- const API = require('@docbrasil/api-systemmanager');
180
212
  methodType: 'put',
181
213
  docId: '5dadd01dc4af3941d42f8c5c'
214
+ const API = require('@docbrasil/api-systemmanager');
215
+ const api = new API();
216
+ const params - {
217
+ methodType: 'put',
218
+ docId: '5dadd01dc4af3941d42f8c5c'
219
+ };
220
+ const apiKey: '...';
221
+ const { docId, name, areaId, type, signedUrl } = await api.admin.document.signedUrl(params, apiKey);
182
222
  ```
183
223
  **Example**
184
224
  ```js
185
- const API = require('@docbrasil/api-systemmanager');
186
225
  methodType: 'get',
187
226
  docId: '5dadd01dc4af3941d42f8c5c'
227
+ const API = require('@docbrasil/api-systemmanager');
228
+ const api = new API();
229
+ const params - {
230
+ methodType: 'get',
231
+ docId: '5dadd01dc4af3941d42f8c5c'
232
+ };
233
+ const apiKey: '...';
234
+ const { signedUrl, imageType } = await api.admin.document.signedUrl(params, apiKey);
188
235
  ```
189
236
  <a name="AdminDocuments+updateContent"></a>
190
237
 
@@ -201,7 +248,14 @@ Update a document content
201
248
 
202
249
  **Example**
203
250
  ```js
204
- const API = require('@docbrasil/api-systemmanager');
205
251
  content: 'some text...',
206
252
  docId: '5dadd01dc4af3941d42f8c5c'
253
+ const API = require('@docbrasil/api-systemmanager');
254
+ const api = new API();
255
+ const params - {
256
+ content: 'some text...',
257
+ docId: '5dadd01dc4af3941d42f8c5c'
258
+ };
259
+ const apiKey: '...';
260
+ await api.admin.document.updateContent(params, apiKey);
207
261
  ```
208
262
  <a name="AdminDocuments+updateAI"></a>
209
263
 
@@ -228,7 +282,14 @@ Update a document content
228
282
 
229
283
  **Example**
230
284
  ```js
231
- const API = require('@docbrasil/api-systemmanager');
232
285
  content: 'some text...',
233
286
  docId: '5dadd01dc4af3941d42f8c5c'
287
+ const API = require('@docbrasil/api-systemmanager');
288
+ const api = new API();
289
+ const params - {
290
+ content: 'some text...',
291
+ docId: '5dadd01dc4af3941d42f8c5c'
292
+ };
293
+ const apiKey: '...';
294
+ await api.admin.document.updateContent(params, apiKey);
234
295
  ```
235
296
  <a name="AdminDocuments+getContent"></a>
236
297
 
@@ -249,7 +310,14 @@ Get the content of a document
249
310
 
250
311
  **Example**
251
312
  ```js
252
- const API = require('@docbrasil/api-systemmanager');
253
313
  page: '0',
254
314
  docId: '5dadd01dc4af3941d42f8c5c'
315
+ const API = require('@docbrasil/api-systemmanager');
316
+ const api = new API();
317
+ const params - {
318
+ page: '0',
319
+ docId: '5dadd01dc4af3941d42f8c5c'
320
+ };
321
+ const apiKey: '...';
322
+ await api.admin.document.getContent(params, apiKey);
255
323
  ```
256
324
  <a name="AdminForm"></a>
257
325
 
@@ -280,7 +348,14 @@ Get advance form by ID
280
348
 
281
349
  **Example**
282
350
  ```js
283
- const API = require('@docbrasil/api-systemmanager');
284
351
  id: '55e4a3bd6be6b45210833fae',
285
352
  orgId: '5edd11c46b6ce9729c2c297c',
353
+ const API = require('@docbrasil/api-systemmanager');
354
+ const api = new API();
355
+ const params = {
356
+ id: '55e4a3bd6be6b45210833fae',
357
+ orgId: '5edd11c46b6ce9729c2c297c',
358
+ };
359
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
360
+ await api.admin.form.findById(params, session);
286
361
  ```
287
362
  <a name="AdminForm+getFormList"></a>
288
363
 
@@ -304,7 +379,13 @@ Request signed url url to put or get
304
379
 
305
380
  **Example**
306
381
  ```js
307
- const API = require('@docbrasil/api-systemmanager');
308
382
  orgId: '5dadd01dc4af3941d42f8c5c',
383
+ const API = require('@docbrasil/api-systemmanager');
384
+ const api = new API();
385
+ const params - {
386
+ orgId: '5dadd01dc4af3941d42f8c5c',
387
+ };
388
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
389
+ await api.user.form.getFormList(params, session);
309
390
  ```
310
391
  <a name="Admin"></a>
311
392
 
@@ -351,7 +432,14 @@ Get list by ID
351
432
 
352
433
  **Example**
353
434
  ```js
354
- const API = require('@docbrasil/api-systemmanager');
355
435
  id: '55e4a3bd6be6b45210833fae',
356
436
  orgId: '5edd11c46b6ce9729c2c297c',
437
+ const API = require('@docbrasil/api-systemmanager');
438
+ const api = new API();
439
+ const params = {
440
+ id: '55e4a3bd6be6b45210833fae',
441
+ orgId: '5edd11c46b6ce9729c2c297c',
442
+ };
443
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
444
+ await api.admin.list.findById(params, session);
357
445
  ```
358
446
  <a name="AdminLists+find"></a>
359
447
 
@@ -372,7 +460,13 @@ Get all lists
372
460
 
373
461
  **Example**
374
462
  ```js
375
- const API = require('@docbrasil/api-systemmanager');
376
463
  orgId: '55e4a3bd6be6b45210833fae'
464
+ const API = require('@docbrasil/api-systemmanager');
465
+ const api = new API();
466
+ const params = {
467
+ orgId: '55e4a3bd6be6b45210833fae'
468
+ };
469
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
470
+ await api.admin.list.find(params, session);
377
471
  ```
378
472
  <a name="AdminMessage"></a>
379
473
 
@@ -450,7 +544,15 @@ Send email, array with email list or send one email
450
544
 
451
545
  **Example**
452
546
  ```js
453
- const API = require('@docbrasil/api-systemmanager');
454
547
  subject: 'Test email',
455
548
  message: '<h1>Hi!</h1>',
456
549
  to: 'destination@gmail.com'
550
+ const API = require('@docbrasil/api-systemmanager');
551
+ const api = new API();
552
+ const params = {
553
+ subject: 'Test email',
554
+ message: '<h1>Hi!</h1>',
555
+ to: 'destination@gmail.com'
556
+ };
557
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
558
+ await api.admin.message.sendEmail(params, session);
457
559
  ```
458
560
  <a name="AdminNotification"></a>
459
561
 
@@ -499,7 +601,15 @@ Create notification
499
601
 
500
602
  **Example**
501
603
  ```js
502
- const API = require('@docbrasil/api-systemmanager');
503
604
  orgId: '5edd11c46b6ce9729c2c297c',
504
605
  userId: '55e4a3bd6be6b45210833fae',
505
606
  message: 'Olá como vai tudo bem?'
607
+ const API = require('@docbrasil/api-systemmanager');
608
+ const api = new API();
609
+ const params = {
610
+ orgId: '5edd11c46b6ce9729c2c297c',
611
+ userId: '55e4a3bd6be6b45210833fae',
612
+ message: 'Olá como vai tudo bem?'
613
+ };
614
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
615
+ await api.admin.notifications.add(params, session);
506
616
  ```
507
617
  <a name="AdminNotification+findById"></a>
508
618
 
@@ -519,7 +629,14 @@ Search notification using (notificationId or userId)
519
629
 
520
630
  **Example**
521
631
  ```js
522
- const API = require('@docbrasil/api-systemmanager');
523
632
  orgId: '5edd11c46b6ce9729c2c297c',
524
633
  id: '55e4a3bd6be6b45210833fae',
634
+ const API = require('@docbrasil/api-systemmanager');
635
+ const api = new API();
636
+ const params = {
637
+ orgId: '5edd11c46b6ce9729c2c297c',
638
+ id: '55e4a3bd6be6b45210833fae',
639
+ };
640
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
641
+ await api.admin.notifications.findById(params, session);
525
642
  ```
526
643
  <a name="AdminNotification+findByIdAndUpdate"></a>
527
644
 
@@ -540,7 +657,15 @@ Update notification using (notificationId or userId)
540
657
 
541
658
  **Example**
542
659
  ```js
543
- const API = require('@docbrasil/api-systemmanager');
544
660
  orgId: '5edd11c46b6ce9729c2c297c',
545
661
  id: '55e4a3bd6be6b45210833fae',
546
662
  read: true
663
+ const API = require('@docbrasil/api-systemmanager');
664
+ const api = new API();
665
+ const params = {
666
+ orgId: '5edd11c46b6ce9729c2c297c',
667
+ id: '55e4a3bd6be6b45210833fae',
668
+ read: true
669
+ };
670
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
671
+ await api.admin.notifications.findByIdAndUpdate(params, session);
547
672
  ```
548
673
  <a name="AdminNotification+findByIdAndRemove"></a>
549
674
 
@@ -560,7 +685,14 @@ Delete notification using (notificationId or userId)
560
685
 
561
686
  **Example**
562
687
  ```js
563
- const API = require('@docbrasil/api-systemmanager');
564
688
  orgId: '5edd11c46b6ce9729c2c297c',
565
689
  id: '55e4a3bd6be6b45210833fae',
690
+ const API = require('@docbrasil/api-systemmanager');
691
+ const api = new API();
692
+ const params = {
693
+ orgId: '5edd11c46b6ce9729c2c297c',
694
+ id: '55e4a3bd6be6b45210833fae',
695
+ };
696
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
697
+ await api.admin.notifications.findByIdAndDelete(params, session);
566
698
  ```
567
699
  <a name="Organization"></a>
568
700
 
@@ -597,7 +729,15 @@ Update avatar of organization by session of user not allow session user SU
597
729
 
598
730
  **Example**
599
731
  ```js
600
- const API = require('@docbrasil/api-systemmanager');
601
732
  orgId: '5dadd01dc4af3941d42f8c5c',
602
733
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
603
734
  type: 'image/png',
735
+ const API = require('@docbrasil/api-systemmanager');
736
+ const api = new API();
737
+ const params = {
738
+ orgId: '5dadd01dc4af3941d42f8c5c',
739
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
740
+ type: 'image/png',
741
+ };
742
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
743
+ await api.admin.organizations.upsertAvatar(params, session);
604
744
  ```
605
745
  <a name="Organization+removeAvatar"></a>
606
746
 
@@ -615,7 +755,11 @@ Remove avatar of user by session of user not allow session user SU
615
755
 
616
756
  **Example**
617
757
  ```js
618
- const API = require('@docbrasil/api-systemmanager');
758
+ const API = require('@docbrasil/api-systemmanager');
759
+ const api = new API();
760
+ const orgId = '5dadd01dc4af3941d42f8c5c';
761
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
762
+ await api.admin.organizations.removeAvatar(orgId, session);
619
763
  ```
620
764
  <a name="Organization+findById"></a>
621
765
 
@@ -633,7 +777,11 @@ Find organization by id
633
777
 
634
778
  **Example**
635
779
  ```js
636
- const API = require('@docbrasil/api-systemmanager');
780
+ const API = require('@docbrasil/api-systemmanager');
781
+ const api = new API();
782
+ const orgId = '80443245000122';
783
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
784
+ await api.user.organization.findById(idCard, session);
637
785
  ```
638
786
  <a name="Organization+idCardExist"></a>
639
787
 
@@ -651,7 +799,11 @@ Check if id card exist
651
799
 
652
800
  **Example**
653
801
  ```js
654
- const API = require('@docbrasil/api-systemmanager');
802
+ const API = require('@docbrasil/api-systemmanager');
803
+ const api = new API();
804
+ const idCard = '80443245000122';
805
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
806
+ await api.user.organization.idCardExist(idCard, session);
655
807
  ```
656
808
  <a name="Organization+upsertAvatar"></a>
657
809
 
@@ -671,7 +823,14 @@ Update avatar of organization by session of user not allow session user SU
671
823
 
672
824
  **Example**
673
825
  ```js
674
- const API = require('@docbrasil/api-systemmanager');
675
826
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
676
827
  type: 'image/png',
828
+ const API = require('@docbrasil/api-systemmanager');
829
+ const api = new API();
830
+ const params = {
831
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
832
+ type: 'image/png',
833
+ };
834
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
835
+ await api.user.profile.updateAvatar(params, session);
677
836
  ```
678
837
  <a name="Organization+removeAvatar"></a>
679
838
 
@@ -688,7 +847,10 @@ Remove avatar of user by session of user not allow session user SU
688
847
 
689
848
  **Example**
690
849
  ```js
691
- const API = require('@docbrasil/api-systemmanager');
850
+ const API = require('@docbrasil/api-systemmanager');
851
+ const api = new API();
852
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
853
+ await api.user.profile.removeAvatar(session);
692
854
  ```
693
855
  <a name="Organization+callFetch"></a>
694
856
 
@@ -708,7 +870,14 @@ Call URL internal, need auth JWT (session)
708
870
 
709
871
  **Example**
710
872
  ```js
711
- const API = require('@docbrasil/api-systemmanager');
712
873
  url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
713
874
  method: 'POST'
875
+ const API = require('@docbrasil/api-systemmanager');
876
+ const api = new API();
877
+
878
+ const params = {
879
+ url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
880
+ method: 'POST'
881
+ }
882
+ await api.user.organization.callFetchs(params, session);
714
883
  ```
715
884
  <a name="AdminPlugin"></a>
716
885
 
@@ -738,7 +907,11 @@ Find plugins
738
907
 
739
908
  **Example**
740
909
  ```js
741
- const API = require('@docbrasil/api-systemmanager');
910
+ const API = require('@docbrasil/api-systemmanager');
911
+ const api = new API();
912
+ const params = {page: 1, perPage: 200};
913
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
914
+ await api.user.organization.findById(params, session);
742
915
  ```
743
916
  <a name="AdminPlugin+findById"></a>
744
917
 
@@ -756,7 +929,11 @@ Get plugin by ID
756
929
 
757
930
  **Example**
758
931
  ```js
759
- const API = require('@docbrasil/api-systemmanager');
932
+ const API = require('@docbrasil/api-systemmanager');
933
+ const api = new API();
934
+ const id ='55e4a3bd6be6b45210833fae',
935
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
936
+ await api.admin.plugin.findById(id, session);
760
937
  ```
761
938
  <a name="AdminPolicy"></a>
762
939
 
@@ -779,7 +956,10 @@ Find all policies
779
956
 
780
957
  **Example**
781
958
  ```js
782
- const API = require('@docbrasil/api-systemmanager');
959
+ const API = require('@docbrasil/api-systemmanager');
960
+ const api = new API();
961
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
962
+ await api.admin.policy.find(session);
783
963
  ```
784
964
  <a name="AdminProcesses"></a>
785
965
 
@@ -803,7 +983,16 @@ Advanced search of processes, check documentation, to verify all params, pass to
803
983
  **Author**: CloudBrasil <abernardo.br@gmail.com>
804
984
  **Example**
805
985
  ```js
806
- const API = require('@docbrasil/api-systemmanager');
807
986
  orgId: '5edd11c46b6ce9729c2c297c',
808
987
  ...
809
988
  ...
810
989
  ...
990
+ const API = require('@docbrasil/api-systemmanager');
991
+ const api = new API();
992
+ const params = {
993
+ orgId: '5edd11c46b6ce9729c2c297c',
994
+ ...
995
+ ...
996
+ ...
997
+ };
998
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
999
+ await api.admin.processes.search(params, session);
811
1000
  ```
812
1001
  <a name="AdminProcesses+advancedSearch"></a>
813
1002
 
@@ -823,7 +1012,23 @@ Advanced search of process in elastic search ussing system manager
823
1012
 
824
1013
  **Example**
825
1014
  ```js
826
- const API = require('@docbrasil/api-systemmanager');
827
1015
  orgProcessId: '5edd11c46b6ce9729c2c297c',
828
1016
  query: {
829
1017
  "_source": "processData.properties.processProperties",
830
1018
  "query": {
831
1019
  "term": {
832
1020
  "initParams.email.keyword": {
833
1021
  "value": "clintes001@gmail.com"
834
1022
  }
835
1023
  }
836
1024
  }
837
1025
  }
1026
+ const API = require('@docbrasil/api-systemmanager');
1027
+ const api = new API();
1028
+ const params = {
1029
+ orgProcessId: '5edd11c46b6ce9729c2c297c',
1030
+ query: {
1031
+ "_source": "processData.properties.processProperties",
1032
+ "query": {
1033
+ "term": {
1034
+ "initParams.email.keyword": {
1035
+ "value": "clintes001@gmail.com"
1036
+ }
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1042
+ await api.admin.processes.advancedSearch(params, session);
838
1043
  ```
839
1044
  <a name="AdminTask"></a>
840
1045
 
@@ -854,7 +1059,13 @@ Get task by user Id
854
1059
 
855
1060
  **Example**
856
1061
  ```js
857
- const API = require('@docbrasil/api-systemmanager');
858
1062
  userId: '55e4a3bd6be6b45210833fae',
1063
+ const API = require('@docbrasil/api-systemmanager');
1064
+ const api = new API();
1065
+ const params = {
1066
+ userId: '55e4a3bd6be6b45210833fae',
1067
+ };
1068
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1069
+ await api.admin.task.find(params, session);
859
1070
  ```
860
1071
  <a name="AdminUser"></a>
861
1072
 
@@ -888,7 +1099,11 @@ Request profile by userId
888
1099
 
889
1100
  **Example**
890
1101
  ```js
891
- const API = require('@docbrasil/api-systemmanager');
1102
+ const API = require('@docbrasil/api-systemmanager');
1103
+ const api = new API();
1104
+ const userId = '55e4a3bd6be6b45210833fae';
1105
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1106
+ await api.admin.user.findById(userId, session);
892
1107
  ```
893
1108
  <a name="AdminUser+findByIds"></a>
894
1109
 
@@ -906,7 +1121,11 @@ Request profile by userId
906
1121
 
907
1122
  **Example**
908
1123
  ```js
909
- const API = require('@docbrasil/api-systemmanager');
1124
+ const API = require('@docbrasil/api-systemmanager');
1125
+ const api = new API();
1126
+ const userIds = ['55e4a3bd6be6b45210833fae', '55e4a3bd6be6b45210833fae'];
1127
+ const apiKey = 'c9bbd652-d112-454e-8595-f1669f49dde0';
1128
+ await api.admin.user.findByIds(userIds, apiKey);
910
1129
  ```
911
1130
  <a name="AdminUser+findByIdAndUpdatePassword"></a>
912
1131
 
@@ -927,7 +1146,15 @@ Update password by userId
927
1146
 
928
1147
  **Example**
929
1148
  ```js
930
- const API = require('@docbrasil/api-systemmanager');
931
1149
  userId: '55e4a3bd6be6b45210833fae',
932
1150
  oldPassword: '123456',
933
1151
  newPassword: '123456789'
1152
+ const API = require('@docbrasil/api-systemmanager');
1153
+ const api = new API();
1154
+ const params = {
1155
+ userId: '55e4a3bd6be6b45210833fae',
1156
+ oldPassword: '123456',
1157
+ newPassword: '123456789'
1158
+ };
1159
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1160
+ await api.admin.user.findByIdAndUpdatePassword(params, session);
934
1161
  ```
935
1162
  <a name="AdminUser+emailExist"></a>
936
1163
 
@@ -945,7 +1172,11 @@ Check if email is unique
945
1172
 
946
1173
  **Example**
947
1174
  ```js
948
- const API = require('@docbrasil/api-systemmanager');
1175
+ const API = require('@docbrasil/api-systemmanager');
1176
+ const api = new API();
1177
+ const email = 'ana.silva@gmail.com';
1178
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1179
+ await api.admin.user.emailExist(email, session);
949
1180
  ```
950
1181
  <a name="AdminUser+findByIdAndUpdate"></a>
951
1182
 
@@ -963,7 +1194,12 @@ update userData by userSMId
963
1194
 
964
1195
  **Example**
965
1196
  ```js
966
- const userId = '55e4a3bd6be6b45210833fae';
967
1197
  name: 'Maria joaquina',
968
1198
  email: 'maria@gmail.com'
1199
+ const userId = '55e4a3bd6be6b45210833fae';
1200
+ const payload = {
1201
+ name: 'Maria joaquina',
1202
+ email: 'maria@gmail.com'
1203
+ };
1204
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
969
1205
  ```
970
1206
  <a name="AdminUser+getChangePasswordGuid"></a>
971
1207
 
@@ -979,7 +1215,10 @@ Request GUID to change the password
979
1215
 
980
1216
  **Example**
981
1217
  ```js
982
- const payload = {
983
1218
  email: 'maria@gmail.com'
1219
+ const payload = {
1220
+ email: 'maria@gmail.com'
1221
+ };
1222
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
984
1223
  ```
985
1224
  <a name="AdminUser+changePasswordGuid"></a>
986
1225
 
@@ -997,143 +1236,11 @@ Change password guid
997
1236
 
998
1237
  **Example**
999
1238
  ```js
1000
- const payload = {
1001
1239
  guid: '5b3c049c-4861-4353-a423-5e3f14242642',
1002
1240
  newPassword: '123456789'
1003
- ```
1004
- <a name="Dispatch"></a>
1005
-
1006
- ## Dispatch
1007
- Api dispatch manager
1008
-
1009
- **Kind**: global class
1010
-
1011
- * [Dispatch](#Dispatch)
1012
- * [.getContext(url, session)](#Dispatch+getContext) ⇒ <code>Promise.&lt;object&gt;</code>
1013
- * [.getClient()](#Dispatch+getClient) ⇒ <code>promise</code>
1014
-
1015
- <a name="Dispatch+getContext"></a>
1016
-
1017
- ### dispatch.getContext(url, session) ⇒ <code>Promise.&lt;object&gt;</code>
1018
- Get the URL context
1019
-
1020
- **Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
1021
- **Returns**: <code>Promise.&lt;object&gt;</code> - The full data context of the URL
1022
- **Access**: public
1023
-
1024
- | Param | Type | Default | Description |
1025
- | --- | --- | --- | --- |
1026
- | url | <code>string</code> | | Full url |
1027
- | session | <code>session</code> | <code></code> | Session, token JWT |
1028
-
1029
- **Example**
1030
- ```js
1031
- const API = require('@docbrasil/api-systemmanager');
1032
- ```
1033
- <a name="Dispatch+getClient"></a>
1034
-
1035
- ### dispatch.getClient() ⇒ <code>promise</code>
1036
- Get client Axios
1037
-
1038
- **Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
1039
- **Returns**: <code>promise</code> - return client axios
1040
- **Access**: public
1041
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1042
- **Example**
1043
- ```js
1044
- const API = require('@docbrasil/api-systemmanager');
1045
- ```
1046
- <a name="External"></a>
1047
-
1048
- ## External
1049
- Class for documents, permission user
1050
-
1051
- **Kind**: global class
1052
-
1053
- * [External](#External)
1054
- * [.context(params)](#External+context) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>array.&lt;object&gt;</code>
1055
- * [.getUploadDocumentSignedUrl(mime, authorization)](#External+getUploadDocumentSignedUrl) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1056
- * [.getUploadDocumentsSignedUrl(docs, authorization)](#External+getUploadDocumentsSignedUrl) ⇒ <code>Promise.&lt;array&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1057
- * [.handle(authorization, params)](#External+handle) ⇒ <code>Promise.&lt;boolean&gt;</code>
1058
-
1059
- <a name="External+context"></a>
1060
-
1061
- ### external.context(params) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>array.&lt;object&gt;</code>
1062
- Create new document
1063
-
1064
- **Kind**: instance method of [<code>External</code>](#External)
1065
- **Returns**: <code>Promise.&lt;object&gt;</code> - data<code>string</code> - _id the id of the form<code>string</code> - orgId the organization id of the form<code>string</code> - authorization the unique token registered internally by the system for all the next calls to the external form APIs
1066
1241
  The authorization is unique and is ONLY valid for this session.<code>array.&lt;object&gt;</code> - groups the form groups to render
1067
- **Access**: public
1068
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1069
-
1070
- | Param | Type | Description |
1071
- | --- | --- | --- |
1072
- | params | <code>object</code> | Object for add new document |
1073
- | params.id | <code>string</code> | Organization form id |
1074
-
1075
- **Example**
1076
- ```js
1077
- const API = require('@docbrasil/api-systemmanager');
1078
1242
  id: '611e679741cc63168c26d7ee'
1079
- ```
1080
- <a name="External+getUploadDocumentSignedUrl"></a>
1081
-
1082
- ### external.getUploadDocumentSignedUrl(mime, authorization) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1083
- Get an upload signed url, so it will be possible to upload documents temporarily during the use of the external form
1084
-
1085
- **Kind**: instance method of [<code>External</code>](#External)
1086
- **Returns**: <code>Promise.&lt;object&gt;</code> - doc<code>string</code> - doc.mime the original mime type of the document<code>string</code> - doc.signedUrl the signed url to upload the document<code>string</code> - doc.filename the filename of the uploaded file<code>string</code> - doc.extension the extension of the filename, obtained from the mime type
1087
- **Access**: public
1088
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1089
-
1090
- | Param | Type | Description |
1091
- | --- | --- | --- |
1092
- | mime | <code>string</code> | the mime type of the document |
1093
- | authorization | <code>string</code> | a legal authorization |
1094
-
1095
- **Example**
1096
- ```js
1097
- const API = require('@docbrasil/api-systemmanager');
1098
1243
  mime: 'application/pdf'
1099
- ```
1100
- <a name="External+getUploadDocumentsSignedUrl"></a>
1101
-
1102
- ### external.getUploadDocumentsSignedUrl(docs, authorization) ⇒ <code>Promise.&lt;array&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1103
- Get an upload signed url, for many documents. So it will be possible to upload documents temporarily during the use of the external form
1104
-
1105
- **Kind**: instance method of [<code>External</code>](#External)
1106
- **Returns**: <code>Promise.&lt;array&gt;</code> - docs<code>string</code> - docs.mime the original mime type of the document<code>string</code> - docs.signedUrl the signed url to upload the document<code>string</code> - docs.filename the filename of the uploaded file<code>string</code> - docs.extension the extension of the filename, obtained from the mime type
1107
- **Access**: public
1108
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1109
-
1110
- | Param | Type | Description |
1111
- | --- | --- | --- |
1112
- | docs | <code>array.&lt;object&gt;</code> | the list of documents |
1113
- | docs.mime | <code>string</code> | the mime type of the document |
1114
- | authorization | <code>string</code> | a legal authorization |
1115
-
1116
- **Example**
1117
- ```js
1118
- const API = require('@docbrasil/api-systemmanager');
1119
1244
  {
1120
1245
  mime: 'application/pdf'
1121
1246
  }
1122
- ```
1123
- <a name="External+handle"></a>
1124
-
1125
- ### external.handle(authorization, params) ⇒ <code>Promise.&lt;boolean&gt;</code>
1126
- Handles the execution of an external form
1127
-
1128
- **Kind**: instance method of [<code>External</code>](#External)
1129
- **Returns**: <code>Promise.&lt;boolean&gt;</code> - true|false if success
1130
- **Access**: public
1131
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1132
-
1133
- | Param | Type | Description |
1134
- | --- | --- | --- |
1135
- | authorization | <code>string</code> | a legal authorization |
1136
- | params | <code>object</code> | the parameters to handle the execution of an external form |
1137
- | params.payload | <code>array.&lt;object&gt;</code> | the payload of the external form. It should represent the form groups of the external form |
1138
- | params.payload.name | <code>string</code> | the name of the group |
1139
- | params.payload.fields | <code>array.&lt;object&gt;</code> | the fields that belong to each group |
1140
- | params.payload.fields.value | <code>\*</code> \| <code>Object</code> | besides all the data inside a field, it should have the value of the the field |
1141
-
1142
- **Example**
1143
- ```js
1144
- const API = require('@docbrasil/api-systemmanager');
1145
1247
  payload: [
1146
1248
  {
1147
1249
  name: 'My Group One',
1148
1250
  fields: [
1149
1251
  {}
1150
1252
  ]
1151
1253
  }
1152
1254
  ]
1255
+ const payload = {
1256
+ guid: '5b3c049c-4861-4353-a423-5e3f14242642',
1257
+ newPassword: '123456789'
1258
+ };
1259
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1153
1260
  ```
1154
1261
  <a name="GeoLocation"></a>
1155
1262
 
@@ -1158,7 +1265,13 @@ Get geo location of the address
1158
1265
 
1159
1266
  **Example**
1160
1267
  ```js
1161
- const API = require('@docbrasil/api-systemmanager');
1162
1268
  address: 'Rua Sud Menucci, 615 - Vila Camilopolis, Santo André - SP',
1163
1269
  apiKey: 'AIzaSyC7gJFOkuT-Mel3WZbX5uKuJ1USqLVkGnY',
1270
+ const API = require('@docbrasil/api-systemmanager');
1271
+ const api = new API();
1272
+ const params = {
1273
+ address: 'Rua Sud Menucci, 615 - Vila Camilopolis, Santo André - SP',
1274
+ apiKey: 'AIzaSyC7gJFOkuT-Mel3WZbX5uKuJ1USqLVkGnY',
1275
+ };
1276
+ await api.general.geo.location(params);
1164
1277
  ```
1165
1278
  <a name="Users"></a>
1166
1279
 
@@ -1190,241 +1303,102 @@ API request, user permission level
1190
1303
  | options | <code>object</code> | Params of the constructor |
1191
1304
  | options.parent | <code>object</code> | This of the pararent |
1192
1305
 
1193
- <a name="Login"></a>
1306
+ <a name="Application"></a>
1194
1307
 
1195
- ## Login
1196
- Login manager
1308
+ ## Application
1309
+ Class for Applications, permission user
1197
1310
 
1198
1311
  **Kind**: global class
1312
+ <a name="Application+list"></a>
1199
1313
 
1200
- * [Login](#Login)
1201
- * [.facebook(params)](#Login+facebook) <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1202
- * [.google(params)](#Login+google) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1203
- * [.apiKey(apikey)](#Login+apiKey) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1204
- * [.userPass(params)](#Login+userPass) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1205
- * [.logout(session)](#Login+logout) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1206
- * [.recover(username)](#Login+recover) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1207
-
1208
- <a name="Login+facebook"></a>
1209
-
1210
- ### login.facebook(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1211
- Login with social login Facebook
1314
+ ### application.list(params, session) ⇒ <code>promise</code>
1315
+ Get the available applications for this user in this organizations
1212
1316
 
1213
- **Kind**: instance method of [<code>Login</code>](#Login)
1214
- **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
1317
+ **Kind**: instance method of [<code>Application</code>](#Application)
1215
1318
  **Access**: public
1216
1319
  **Author**: CloudBrasil <abernardo.br@gmail.com>
1217
1320
 
1218
1321
  | Param | Type | Description |
1219
1322
  | --- | --- | --- |
1220
- | params | <code>object</code> | Params to login Facebook |
1221
- | params.accessToken | <code>string</code> | Access token of the system manager |
1222
- | params.initialUserData | <code>object</code> | Object with roles default if sigin |
1223
- | params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
1323
+ | params | <code>object</code> | Params to get task |
1324
+ | params.orgId | <code>object</code> | Organization id (_id database) |
1325
+ | session | <code>string</code> | Session, token JWT |
1224
1326
 
1225
1327
  **Example**
1226
1328
  ```js
1227
- const API = require('@docbrasil/api-systemmanager');
1329
+ const API = require('@docbrasil/api-systemmanager');
1330
+ const api = new API();
1331
+ const params = {
1332
+ orgId: '55e4a3bd6be6b45210833fae',
1333
+ };
1334
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1335
+ await api.user.application.list(params, session);
1228
1336
  ```
1229
- <a name="Login+google"></a>
1337
+ <a name="Datasource"></a>
1230
1338
 
1231
- ### login.google(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1232
- Login with social login Google
1339
+ ## Datasource
1340
+ Class for user datasource access, to be used with when creating new documents
1233
1341
 
1234
- **Kind**: instance method of [<code>Login</code>](#Login)
1235
- **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
1342
+ **Kind**: global class
1343
+ <a name="Datasource+autocomplete"></a>
1344
+
1345
+ ### datasource.autocomplete(params, session) ⇒ <code>promise.&lt;array&gt;</code> \| <code>string</code> \| <code>object</code>
1346
+ Method to get autocomplete data from a datasource
1347
+
1348
+ **Kind**: instance method of [<code>Datasource</code>](#Datasource)
1349
+ **Returns**: <code>promise.&lt;array&gt;</code> - docs The returned documents field with autocomplete<code>string</code> - docs._id the _id of the document<code>object</code> - data.docTypeFieldsData the field values
1236
1350
  **Access**: public
1237
1351
  **Author**: CloudBrasil <abernardo.br@gmail.com>
1238
1352
 
1239
1353
  | Param | Type | Description |
1240
1354
  | --- | --- | --- |
1241
- | params | <code>object</code> | Params to login Google |
1242
- | params.accessToken | <code>string</code> | Access token of the system manager |
1243
- | params.initialUserData | <code>object</code> | Object with roles default if sigin |
1244
- | params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
1355
+ | params | <code>object</code> | Params to add notification token |
1356
+ | params.orgId | <code>string</code> | The user organization _id |
1357
+ | params.dataSources | <code>array.&lt;object&gt;</code> | The document type data sources information |
1358
+ | params.dataSources._id | <code>string</code> | The document type data sources _id |
1359
+ | params.dataSources.fields | <code>array.&lt;object&gt;</code> | The document type data sources list of fields |
1360
+ | params.documents | <code>array.&lt;object&gt;</code> | The document list |
1361
+ | params.documents._id | <code>string</code> | The document _id |
1362
+ | session | <code>string</code> | Is token JWT of user NOT allow SU |
1245
1363
 
1246
1364
  **Example**
1247
1365
  ```js
1248
- const API = require('@docbrasil/api-systemmanager');
1366
+ const API = require('@docbrasil/api-systemmanager');
1367
+ const api = new API();
1368
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1369
+ const params = {
1370
+ orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
1371
+ dataSources: [{}],
1372
+ documents: [{}]
1373
+ };
1374
+ const retData = await api.user.datasource.autocomplete(params, session);
1249
1375
  ```
1250
- <a name="Login+apiKey"></a>
1376
+ <a name="Documents"></a>
1251
1377
 
1252
- ### login.apiKey(apikey) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1253
- Login with apikey
1378
+ ## Documents
1379
+ Class for documents, permission user
1254
1380
 
1255
- **Kind**: instance method of [<code>Login</code>](#Login)
1256
- **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
1257
- **Access**: public
1258
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1381
+ **Kind**: global class
1259
1382
 
1260
- | Param | Type | Description |
1261
- | --- | --- | --- |
1262
- | apikey | <code>string</code> | Access key |
1383
+ * [Documents](#Documents)
1384
+ * [.add(params, session)](#Documents+add) <code>Promise</code>
1385
+ * [.findByIdAndUpdate(id, params, session)](#Documents+findByIdAndUpdate) ⇒ <code>Promise</code>
1386
+ * [.findById(id, session)](#Documents+findById) ⇒ <code>Promise</code>
1387
+ * [.find(params, session)](#Documents+find) ⇒ <code>Promise</code>
1388
+ * [.findByIdAndRemove(params, session)](#Documents+findByIdAndRemove) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1389
+ * [.findByIdsAndRemove(params, session)](#Documents+findByIdsAndRemove) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1390
+ * [.signedUrl(params, session)](#Documents+signedUrl) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1391
+ * [.signedUrls(params, session)](#Documents+signedUrls) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1392
+ * [.uploadSignedDocument(params)](#Documents+uploadSignedDocument) ⇒ <code>Promise.&lt;boolean&gt;</code>
1393
+ * [.checkPrimaryKeys(params, session)](#Documents+checkPrimaryKeys) ⇒ <code>Promise.&lt;array&gt;</code> \| <code>array.&lt;string&gt;</code>
1394
+ * [.searchDocuments(params, session)](#Documents+searchDocuments) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
1263
1395
 
1264
- **Example**
1265
- ```js
1266
- const API = require('@docbrasil/api-systemmanager');
1267
- ```
1268
- <a name="Login+userPass"></a>
1396
+ <a name="Documents+add"></a>
1269
1397
 
1270
- ### login.userPass(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
1271
- Login with user and password
1398
+ ### documents.add(params, session) ⇒ <code>Promise</code>
1399
+ Create new document
1272
1400
 
1273
- **Kind**: instance method of [<code>Login</code>](#Login)
1274
- **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
1275
- **Access**: public
1276
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1277
-
1278
- | Param | Type | Description |
1279
- | --- | --- | --- |
1280
- | params | <code>object</code> | Object with user and password |
1281
- | params.username | <code>string</code> | Username or email of the user |
1282
- | params.password | <code>string</code> | Password of the user |
1283
- | params.orgname | <code>string</code> | The organame of the user |
1284
-
1285
- **Example**
1286
- ```js
1287
- const API = require('@docbrasil/api-systemmanager');
1288
1401
  username: 'ana.silva@gmail.com',
1289
1402
  password: '123456'
1290
- ```
1291
- <a name="Login+logout"></a>
1292
-
1293
- ### login.logout(session) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1294
- Logout user system manager
1295
-
1296
- **Kind**: instance method of [<code>Login</code>](#Login)
1297
- **Returns**: <code>promise.&lt;object&gt;</code> - } data<code>boolean</code> - data.success true|false
1298
- **Access**: public
1299
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1300
-
1301
- | Param | Type | Description |
1302
- | --- | --- | --- |
1303
- | session | <code>string</code> | Session, token JWT |
1304
-
1305
- **Example**
1306
- ```js
1307
- const API = require('@docbrasil/api-systemmanager');
1308
- ```
1309
- <a name="Login+recover"></a>
1310
-
1311
- ### login.recover(username) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
1312
- Recover the password
1313
-
1314
- **Kind**: instance method of [<code>Login</code>](#Login)
1315
- **Returns**: <code>promise.&lt;object&gt;</code> - } data<code>boolean</code> - data.success true|false
1316
- **Access**: public
1317
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1318
-
1319
- | Param | Type | Description |
1320
- | --- | --- | --- |
1321
- | username | <code>string</code> | The username or email |
1322
-
1323
- **Example**
1324
- ```js
1325
- const API = require('@docbrasil/api-systemmanager');
1326
- ```
1327
- <a name="Session"></a>
1328
-
1329
- ## Session
1330
- Session manager of the API
1331
-
1332
- **Kind**: global class
1333
- <a name="Session+information"></a>
1334
-
1335
- ### session.information(sessionId, suSessionId) ⇒ <code>Promise</code>
1336
- Show information for session, thus validating the session (Valid token JWT)
1337
-
1338
- **Kind**: instance method of [<code>Session</code>](#Session)
1339
- **Access**: public
1340
-
1341
- | Param | Type | Default | Description |
1342
- | --- | --- | --- | --- |
1343
- | sessionId | <code>string</code> | | The user session (JWT Token) |
1344
- | suSessionId | <code>string</code> | <code>&quot;sessionId&quot;</code> | Given a JWT Token of a SU (SuperAdmin), allow to check session for another user. |
1345
-
1346
- **Example**
1347
- ```js
1348
- const API = require('@docbrasil/api-systemmanager');
1349
- ```
1350
- <a name="Application"></a>
1351
-
1352
- ## Application
1353
- Class for Applications, permission user
1354
-
1355
- **Kind**: global class
1356
- <a name="Application+list"></a>
1357
-
1358
- ### application.list(params, session) ⇒ <code>promise</code>
1359
- Get the available applications for this user in this organizations
1360
-
1361
- **Kind**: instance method of [<code>Application</code>](#Application)
1362
- **Access**: public
1363
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1364
-
1365
- | Param | Type | Description |
1366
- | --- | --- | --- |
1367
- | params | <code>object</code> | Params to get task |
1368
- | params.orgId | <code>object</code> | Organization id (_id database) |
1369
- | session | <code>string</code> | Session, token JWT |
1370
-
1371
- **Example**
1372
- ```js
1373
- const API = require('@docbrasil/api-systemmanager');
1374
1403
  orgId: '55e4a3bd6be6b45210833fae',
1375
- ```
1376
- <a name="Datasource"></a>
1377
-
1378
- ## Datasource
1379
- Class for user datasource access, to be used with when creating new documents
1380
-
1381
- **Kind**: global class
1382
- <a name="Datasource+autocomplete"></a>
1383
-
1384
- ### datasource.autocomplete(params, session) ⇒ <code>promise.&lt;array&gt;</code> \| <code>string</code> \| <code>object</code>
1385
- Method to get autocomplete data from a datasource
1386
-
1387
- **Kind**: instance method of [<code>Datasource</code>](#Datasource)
1388
- **Returns**: <code>promise.&lt;array&gt;</code> - docs The returned documents field with autocomplete<code>string</code> - docs._id the _id of the document<code>object</code> - data.docTypeFieldsData the field values
1389
- **Access**: public
1390
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1391
-
1392
- | Param | Type | Description |
1393
- | --- | --- | --- |
1394
- | params | <code>object</code> | Params to add notification token |
1395
- | params.orgId | <code>string</code> | The user organization _id |
1396
- | params.dataSources | <code>array.&lt;object&gt;</code> | The document type data sources information |
1397
- | params.dataSources._id | <code>string</code> | The document type data sources _id |
1398
- | params.dataSources.fields | <code>array.&lt;object&gt;</code> | The document type data sources list of fields |
1399
- | params.documents | <code>array.&lt;object&gt;</code> | The document list |
1400
- | params.documents._id | <code>string</code> | The document _id |
1401
- | session | <code>string</code> | Is token JWT of user NOT allow SU |
1402
-
1403
- **Example**
1404
- ```js
1405
- const API = require('@docbrasil/api-systemmanager');
1406
1404
  orgId: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
1407
1405
  dataSources: [{}],
1408
1406
  documents: [{}]
1409
- ```
1410
- <a name="Documents"></a>
1411
-
1412
- ## Documents
1413
- Class for documents, permission user
1414
-
1415
- **Kind**: global class
1416
-
1417
- * [Documents](#Documents)
1418
- * [.add(params, session)](#Documents+add) ⇒ <code>Promise</code>
1419
- * [.find(params, session)](#Documents+find) ⇒ <code>Promise</code>
1420
- * [.findByIdAndRemove(params, session)](#Documents+findByIdAndRemove) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1421
- * [.findByIdsAndRemove(params, session)](#Documents+findByIdsAndRemove) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1422
- * [.signedUrl(params, session)](#Documents+signedUrl) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1423
- * [.signedUrls(params, session)](#Documents+signedUrls) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
1424
- * [.uploadSignedDocument(params)](#Documents+uploadSignedDocument) ⇒ <code>Promise.&lt;boolean&gt;</code>
1425
- * [.checkPrimaryKeys(params, session)](#Documents+checkPrimaryKeys) ⇒ <code>Promise.&lt;array&gt;</code> \| <code>array.&lt;string&gt;</code>
1426
- * [.searchDocuments(params, session)](#Documents+searchDocuments) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
1427
-
1428
- <a name="Documents+add"></a>
1429
-
1430
- ### documents.add(params, session) ⇒ <code>Promise</code>
1431
- Create new document
1432
-
1433
- **Kind**: instance method of [<code>Documents</code>](#Documents)
1407
+ **Kind**: instance method of [<code>Documents</code>](#Documents)
1434
1408
  **Access**: public
1435
1409
  **Author**: CloudBrasil <abernardo.br@gmail.com>
1436
1410
 
@@ -1459,7 +1433,68 @@ Create new document
1459
1433
 
1460
1434
  **Example**
1461
1435
  ```js
1462
- const API = require('@docbrasil/api-systemmanager');
1463
1436
  orgname: 'cloundbrasil',
1464
1437
  areaId: '5edf9f8ee896b817e45b8dac',
1465
1438
  docId: '5edf86fbe896b817e45b8da6',
1466
1439
  fileName: 'foto',
1467
1440
  type: 'image/png',
1468
1441
  name: 'Fotografia',
1469
1442
  docTypeId = '5edf9f8ee896b817e45b8dac',
1470
1443
  bytes: 12345,
1471
1444
  signedUrl: 'https://s3.amazonaws.com...'
1472
1445
  docTypeFieldsData: {extraUser: '12349f8ee896b817e45b8dac'},
1473
1446
  orgId: '5df7f19618430c89a41a19d2',
1447
+ const API = require('@docbrasil/api-systemmanager');
1448
+ const api = new API();
1449
+ const params = {
1450
+ orgname: 'cloundbrasil',
1451
+ areaId: '5edf9f8ee896b817e45b8dac',
1452
+ docId: '5edf86fbe896b817e45b8da6',
1453
+ fileName: 'foto',
1454
+ type: 'image/png',
1455
+ name: 'Fotografia',
1456
+ docTypeId = '5edf9f8ee896b817e45b8dac',
1457
+ bytes: 12345,
1458
+ signedUrl: 'https://s3.amazonaws.com...'
1459
+ docTypeFieldsData: {extraUser: '12349f8ee896b817e45b8dac'},
1460
+ orgId: '5df7f19618430c89a41a19d2',
1461
+ };
1462
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1463
+ await api.user.document.add(params, session);
1464
+ ```
1465
+ <a name="Documents+findByIdAndUpdate"></a>
1466
+
1467
+ ### documents.findByIdAndUpdate(id, params, session) ⇒ <code>Promise</code>
1468
+ Updates a document
1469
+
1470
+ **Kind**: instance method of [<code>Documents</code>](#Documents)
1471
+ **Access**: public
1472
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
1473
+
1474
+ | Param | Type | Description |
1475
+ | --- | --- | --- |
1476
+ | id | <code>string</code> | Document _id |
1477
+ | params | <code>object</code> | Object for document payload to update. It has to be the FULL document data, that you can get with findById |
1478
+ | session | <code>string</code> | Session, token JWT |
1479
+
1480
+ **Example**
1481
+ ```js
1482
+ const API = require('@docbrasil/api-systemmanager');
1483
+ const api = new API();
1484
+ const params = { ... };
1485
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1486
+ await api.user.document.findByIdAndUpdate('5edf9f8ee896b817e45b8dad', params, session);
1487
+ ```
1488
+ <a name="Documents+findById"></a>
1489
+
1490
+ ### documents.findById(id, session) ⇒ <code>Promise</code>
1491
+ Updates a document.
1492
+ IMPORTANT: if your document has a content, it will NOT bring the content.
1493
+
1494
+ **Kind**: instance method of [<code>Documents</code>](#Documents)
1495
+ **Access**: public
1496
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
1497
+
1498
+ | Param | Type | Description |
1499
+ | --- | --- | --- |
1500
+ | id | <code>string</code> | Document _id |
1501
+ | session | <code>string</code> | Session, token JWT |
1502
+
1503
+ **Example**
1504
+ ```js
1505
+ const API = require('@docbrasil/api-systemmanager');
1506
+ const api = new API();
1507
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1508
+ await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);
1474
1509
  ```
1475
1510
  <a name="Documents+find"></a>
1476
1511
 
@@ -1487,7 +1522,18 @@ const API = require('@docbrasil/api-systemmanager');
1487
1522
 
1488
1523
  **Example**
1489
1524
  ```js
1490
- const API = require('@docbrasil/api-systemmanager');
1491
1525
  index: 'extraCity',
1492
1526
  txtToSearch: 'São',
1493
1527
  docId: '5df7f19618430c89a41a19d2',
1494
1528
  docAreaId: '5edd11c46b6ce9729c2c297c',
1495
1529
  tag: 'Nome da cidade',
1496
1530
  orgId: '1234d01dc4af3941d42f8c5c'
1531
+ const API = require('@docbrasil/api-systemmanager');
1532
+ const api = new API();
1533
+ const params - {
1534
+ index: 'extraCity',
1535
+ txtToSearch: 'São',
1536
+ docId: '5df7f19618430c89a41a19d2',
1537
+ docAreaId: '5edd11c46b6ce9729c2c297c',
1538
+ tag: 'Nome da cidade',
1539
+ orgId: '1234d01dc4af3941d42f8c5c'
1540
+ };
1541
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1542
+ await api.user.document.findByIdAndRemove(params, session);
1497
1543
  ```
1498
1544
  <a name="Documents+findByIdAndRemove"></a>
1499
1545
 
@@ -1508,7 +1554,14 @@ Remove document by id
1508
1554
 
1509
1555
  **Example**
1510
1556
  ```js
1511
- const API = require('@docbrasil/api-systemmanager');
1512
1557
  docId: '5dadd01dc4af3941d42f8c5c',
1513
1558
  orgIdId: '5df7f19618430c89a41a19d2',
1559
+ const API = require('@docbrasil/api-systemmanager');
1560
+ const api = new API();
1561
+ const params - {
1562
+ docId: '5dadd01dc4af3941d42f8c5c',
1563
+ orgIdId: '5df7f19618430c89a41a19d2',
1564
+ };
1565
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1566
+ await api.user.document.findByIdAndRemove(params, session);
1514
1567
  ```
1515
1568
  <a name="Documents+findByIdsAndRemove"></a>
1516
1569
 
@@ -1530,7 +1583,14 @@ Remove documents
1530
1583
 
1531
1584
  **Example**
1532
1585
  ```js
1533
- const API = require('@docbrasil/api-systemmanager');
1534
1586
  documents: [{ _id: '5dadd01dc4af3941d42f8c5c' }],
1535
1587
  orgId: '5df7f19618430c89a41a19d2',
1588
+ const API = require('@docbrasil/api-systemmanager');
1589
+ const api = new API();
1590
+ const params - {
1591
+ documents: [{ _id: '5dadd01dc4af3941d42f8c5c' }],
1592
+ orgId: '5df7f19618430c89a41a19d2',
1593
+ };
1594
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1595
+ await api.user.document.findByIdsAndRemove(params, session);
1536
1596
  ```
1537
1597
  <a name="Documents+signedUrl"></a>
1538
1598
 
@@ -1556,11 +1616,30 @@ Request signed url url to put or get
1556
1616
 
1557
1617
  **Example**
1558
1618
  ```js
1559
- const API = require('@docbrasil/api-systemmanager');
1560
1619
  methodType: 'put',
1561
1620
  docId: '5dadd01dc4af3941d42f8c5c',
1562
1621
  docAreaId: '5df7f19618430c89a41a19d2',
1563
1622
  fileName: 'Foto',
1564
1623
  type: 'image/png'
1565
1624
  orgId: '5df7f19618430c89a41a19f8'
1625
+ const API = require('@docbrasil/api-systemmanager');
1626
+ const api = new API();
1627
+ const params - {
1628
+ methodType: 'put',
1629
+ docId: '5dadd01dc4af3941d42f8c5c',
1630
+ docAreaId: '5df7f19618430c89a41a19d2',
1631
+ fileName: 'Foto',
1632
+ type: 'image/png'
1633
+ orgId: '5df7f19618430c89a41a19f8'
1634
+ };
1635
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1636
+ // each doc: { docId, name, areaId, type, signedUrl }
1637
+ const { docs } = await api.user.document.signedUrl(params, session);
1566
1638
  ```
1567
1639
  **Example**
1568
1640
  ```js
1569
- const API = require('@docbrasil/api-systemmanager');
1570
1641
  methodType: 'get',
1571
1642
  document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf',
1643
+ const API = require('@docbrasil/api-systemmanager');
1644
+ const api = new API();
1645
+ const params - {
1646
+ methodType: 'get',
1647
+ document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf',
1648
+ };
1649
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1650
+ const base64Data = await api.user.document.signedUrl(params, session);
1572
1651
  ```
1573
1652
  <a name="Documents+signedUrls"></a>
1574
1653
 
@@ -1587,11 +1666,36 @@ Request signed url url to put or get
1587
1666
 
1588
1667
  **Example**
1589
1668
  ```js
1590
- const API = require('@docbrasil/api-systemmanager');
1591
1669
  methodType: 'put',
1592
1670
  orgId: '5df7f19618430c89a41a19f8'
1593
1671
  docs: [
1594
1672
  {
1595
1673
  docId: '5dadd01dc4af3941d42f8c5c',
1596
1674
  areaId: '5df7f19618430c89a41a19d2',
1597
1675
  name: 'Foto.png',
1598
1676
  type: 'image/png'
1599
1677
  }
1600
1678
  ]
1601
- ```
1602
- **Example**
1603
- ```js
1604
- const API = require('@docbrasil/api-systemmanager');
1605
1679
  methodType: 'get',
1606
1680
  docs: [
1607
1681
  { document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf' }
1608
1682
  ],
1683
+ const API = require('@docbrasil/api-systemmanager');
1684
+ const api = new API();
1685
+ const params - {
1686
+ methodType: 'put',
1687
+ orgId: '5df7f19618430c89a41a19f8'
1688
+ docs: [
1689
+ {
1690
+ docId: '5dadd01dc4af3941d42f8c5c',
1691
+ areaId: '5df7f19618430c89a41a19d2',
1692
+ name: 'Foto.png',
1693
+ type: 'image/png'
1694
+ }
1695
+ ]
1696
+ };
1697
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1698
+ // each doc: { docId, name, areaId, type, signedUrl }
1699
+ const { docs } = await api.user.document.signedUrls(params, session);
1700
+ ```
1701
+ **Example**
1702
+ ```js
1703
+ const API = require('@docbrasil/api-systemmanager');
1704
+ const api = new API();
1705
+ const params - {
1706
+ methodType: 'get',
1707
+ docs: [
1708
+ { document: 'pinkandthebrain/5df7f19618430c89a41a19d2/5dadd01dc4af3941d42f8c5c/9dadd01dc4af3941d42f6dd4.pdf' }
1709
+ ],
1710
+ };
1711
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1712
+ const base64Data = await api.user.document.signedUrls(params, session);
1609
1713
  ```
1610
1714
  <a name="Documents+uploadSignedDocument"></a>
1611
1715
 
@@ -1612,7 +1716,21 @@ Uploads the file
1612
1716
 
1613
1717
  **Example**
1614
1718
  ```js
1615
- const FS = require('fs');
1616
1719
  content: FS.readFileSync(Path.join(__dirname, '.mypdf.pdf')),
1617
1720
  signedUrl: 'https://signedurl.com/token...',
1618
1721
  type: 'application/pdf'
1619
1722
  - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
1620
1723
  - loaded: The number of bytes of the file that have been uploaded.
1621
1724
  - total: The total number of bytes in the file.
1725
+ const FS = require('fs');
1726
+ const Path = require('path');
1727
+ const API = require('@docbrasil/api-systemmanager');
1728
+ const api = new API();
1729
+ const params - {
1730
+ content: FS.readFileSync(Path.join(__dirname, '.mypdf.pdf')),
1731
+ signedUrl: 'https://signedurl.com/token...',
1732
+ type: 'application/pdf'
1733
+ };
1734
+ const retData = await api.user.document.uploadSignedDocument(params);
1735
+
1736
+ onUploadProgress return the progressEvent
1737
+ - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
1738
+ - loaded: The number of bytes of the file that have been uploaded.
1739
+ - total: The total number of bytes in the file.
1622
1740
  ```
1623
1741
  <a name="Documents+checkPrimaryKeys"></a>
1624
1742
 
@@ -1620,7 +1738,8 @@ const FS = require('fs');
1620
1738
  **Kind**: instance method of [<code>Documents</code>](#Documents)
1621
1739
  **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
1622
1740
  **Access**: public
1623
- **Author**: CloudBrasil <abernardo.br@gmail.com>
1741
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
1742
+ Checks if a document can be added and it does not repeat its primary key
1624
1743
 
1625
1744
  | Param | Type | Description |
1626
1745
  | --- | --- | --- |
@@ -1635,7 +1754,17 @@ const FS = require('fs');
1635
1754
 
1636
1755
  **Example**
1637
1756
  ```js
1638
- const API = require('@docbrasil/api-systemmanager');
1639
1757
  docs: [{ id: '5dadd01dc4af3941d42f8c5c', docTypeFields, docTypeFieldsData }],
1640
1758
  orgId: '5df7f19618430c89a41a19d2',
1641
1759
  docTypeId: '5df7f19618430c89a41a19d5',
1760
+ const API = require('@docbrasil/api-systemmanager');
1761
+ const api = new API();
1762
+ const docTypeFields = [...]; // the doc type fields array
1763
+ const docTypeFieldsData = {...}; // the data of this fields
1764
+ const params - {
1765
+ docs: [{ id: '5dadd01dc4af3941d42f8c5c', docTypeFields, docTypeFieldsData }],
1766
+ orgId: '5df7f19618430c89a41a19d2',
1767
+ docTypeId: '5df7f19618430c89a41a19d5',
1768
+ };
1769
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1770
+ const retDocs = await api.user.document.checkPrimaryKeys(params, session);
1642
1771
  ```
1643
1772
  <a name="Documents+searchDocuments"></a>
1644
1773
 
@@ -1656,7 +1785,14 @@ Method to search documents for
1656
1785
 
1657
1786
  **Example**
1658
1787
  ```js
1659
- const API = require('@docbrasil/api-systemmanager');
1660
1788
  query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1661
1789
  orgId: '55e4a3bd6be6b45210833fae',
1790
+ const API = require('@docbrasil/api-systemmanager');
1791
+ const api = new API();
1792
+ const params = {
1793
+ query: {p: 20, i: 1, s: 'Mais recentes', as: '', m: 'w', ai: '57e6a3bd6be6b45210833fae'},
1794
+ orgId: '55e4a3bd6be6b45210833fae',
1795
+ };
1796
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1797
+ const retSearch = await api.user.document.searchDocuments(params, session);
1662
1798
  ```
1663
1799
  <a name="Help"></a>
1664
1800
 
@@ -1684,7 +1820,10 @@ get heps topics
1684
1820
 
1685
1821
  **Example**
1686
1822
  ```js
1687
- const API = require('@docbrasil/api-systemmanager');
1823
+ const API = require('@docbrasil/api-systemmanager');
1824
+ const api = new API();
1825
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1826
+ await api.user.help.getTopics(session);
1688
1827
  ```
1689
1828
  <a name="Help+get"></a>
1690
1829
 
@@ -1703,7 +1842,13 @@ Method to find helps from a topic
1703
1842
 
1704
1843
  **Example**
1705
1844
  ```js
1706
- const API = require('@docbrasil/api-systemmanager');
1707
1845
  id: '5dadd01dc4af3941d42f8c5c'
1846
+ const API = require('@docbrasil/api-systemmanager');
1847
+ const api = new API();
1848
+ const params = {
1849
+ id: '5dadd01dc4af3941d42f8c5c'
1850
+ };
1851
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1852
+ await api.user.help.get(params, session);
1708
1853
  ```
1709
1854
  <a name="Users"></a>
1710
1855
 
@@ -1760,7 +1905,14 @@ Method to find my tasks for a user
1760
1905
 
1761
1906
  **Example**
1762
1907
  ```js
1763
- const API = require('@docbrasil/api-systemmanager');
1764
1908
  query: {"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
1765
1909
  orgId: '55e4a3bd6be6b45210833fae',
1910
+ const API = require('@docbrasil/api-systemmanager');
1911
+ const api = new API();
1912
+ const params = {
1913
+ query: {"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
1914
+ orgId: '55e4a3bd6be6b45210833fae',
1915
+ };
1916
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1917
+ const retSearch = await api.user.task.mytasks.find(params, session);
1766
1918
  ```
1767
1919
  <a name="Notification"></a>
1768
1920
 
@@ -1802,7 +1954,14 @@ Method to add a notification token
1802
1954
 
1803
1955
  **Example**
1804
1956
  ```js
1805
- const API = require('@docbrasil/api-systemmanager');
1806
1957
  token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
1807
1958
  type: 'FCM_WEB'
1959
+ const API = require('@docbrasil/api-systemmanager');
1960
+ const api = new API();
1961
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1962
+ const params = {
1963
+ token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
1964
+ type: 'FCM_WEB'
1965
+ };
1966
+ const retData = await api.user.notification.addToken(params, session);
1808
1967
  ```
1809
1968
  <a name="Notification+getNew"></a>
1810
1969
 
@@ -1819,7 +1978,10 @@ get new notifications
1819
1978
 
1820
1979
  **Example**
1821
1980
  ```js
1822
- const API = require('@docbrasil/api-systemmanager');
1981
+ const API = require('@docbrasil/api-systemmanager');
1982
+ const api = new API();
1983
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1984
+ await api.user.notification.getNew(session);
1823
1985
  ```
1824
1986
  <a name="Notification+getOld"></a>
1825
1987
 
@@ -1836,7 +1998,10 @@ get old notifications
1836
1998
 
1837
1999
  **Example**
1838
2000
  ```js
1839
- const API = require('@docbrasil/api-systemmanager');
2001
+ const API = require('@docbrasil/api-systemmanager');
2002
+ const api = new API();
2003
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2004
+ await api.user.notification.getOld(session);
1840
2005
  ```
1841
2006
  <a name="Notification+setRead"></a>
1842
2007
 
@@ -1855,7 +2020,13 @@ Set notification as readed
1855
2020
 
1856
2021
  **Example**
1857
2022
  ```js
1858
- const API = require('@docbrasil/api-systemmanager');
1859
2023
  id: '34c344c43c34c344c43c'
2024
+ const API = require('@docbrasil/api-systemmanager');
2025
+ const api = new API();
2026
+ const params = {
2027
+ id: '34c344c43c34c344c43c'
2028
+ };
2029
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2030
+ await api.user.notification.setRead(params, session);
1860
2031
  ```
1861
2032
  <a name="Notification+setUnread"></a>
1862
2033
 
@@ -1874,7 +2045,13 @@ Set notification as unreaded
1874
2045
 
1875
2046
  **Example**
1876
2047
  ```js
1877
- const API = require('@docbrasil/api-systemmanager');
1878
2048
  id: '34c344c43c34c344c43c'
2049
+ const API = require('@docbrasil/api-systemmanager');
2050
+ const api = new API();
2051
+ const params = {
2052
+ id: '34c344c43c34c344c43c'
2053
+ };
2054
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2055
+ await api.user.notification.setUnread(params, session);
1879
2056
  ```
1880
2057
  <a name="Organization"></a>
1881
2058
 
@@ -1911,7 +2088,15 @@ Update avatar of organization by session of user not allow session user SU
1911
2088
 
1912
2089
  **Example**
1913
2090
  ```js
1914
- const API = require('@docbrasil/api-systemmanager');
1915
2091
  orgId: '5dadd01dc4af3941d42f8c5c',
1916
2092
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
1917
2093
  type: 'image/png',
2094
+ const API = require('@docbrasil/api-systemmanager');
2095
+ const api = new API();
2096
+ const params = {
2097
+ orgId: '5dadd01dc4af3941d42f8c5c',
2098
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
2099
+ type: 'image/png',
2100
+ };
2101
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2102
+ await api.admin.organizations.upsertAvatar(params, session);
1918
2103
  ```
1919
2104
  <a name="Organization+removeAvatar"></a>
1920
2105
 
@@ -1929,7 +2114,11 @@ Remove avatar of user by session of user not allow session user SU
1929
2114
 
1930
2115
  **Example**
1931
2116
  ```js
1932
- const API = require('@docbrasil/api-systemmanager');
2117
+ const API = require('@docbrasil/api-systemmanager');
2118
+ const api = new API();
2119
+ const orgId = '5dadd01dc4af3941d42f8c5c';
2120
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2121
+ await api.admin.organizations.removeAvatar(orgId, session);
1933
2122
  ```
1934
2123
  <a name="Organization+findById"></a>
1935
2124
 
@@ -1947,7 +2136,11 @@ Find organization by id
1947
2136
 
1948
2137
  **Example**
1949
2138
  ```js
1950
- const API = require('@docbrasil/api-systemmanager');
2139
+ const API = require('@docbrasil/api-systemmanager');
2140
+ const api = new API();
2141
+ const orgId = '80443245000122';
2142
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2143
+ await api.user.organization.findById(idCard, session);
1951
2144
  ```
1952
2145
  <a name="Organization+idCardExist"></a>
1953
2146
 
@@ -1965,7 +2158,11 @@ Check if id card exist
1965
2158
 
1966
2159
  **Example**
1967
2160
  ```js
1968
- const API = require('@docbrasil/api-systemmanager');
2161
+ const API = require('@docbrasil/api-systemmanager');
2162
+ const api = new API();
2163
+ const idCard = '80443245000122';
2164
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2165
+ await api.user.organization.idCardExist(idCard, session);
1969
2166
  ```
1970
2167
  <a name="Organization+upsertAvatar"></a>
1971
2168
 
@@ -1985,7 +2182,14 @@ Update avatar of organization by session of user not allow session user SU
1985
2182
 
1986
2183
  **Example**
1987
2184
  ```js
1988
- const API = require('@docbrasil/api-systemmanager');
1989
2185
  avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
1990
2186
  type: 'image/png',
2187
+ const API = require('@docbrasil/api-systemmanager');
2188
+ const api = new API();
2189
+ const params = {
2190
+ avatar: 'iVBORw0KGgoAAAANSUhEUgAAAasAAAHnCAYAAAAGi3J6AAA9BElEQVR...He3/kk/m7kl35S8AAAAASUVORK5CYII=',
2191
+ type: 'image/png',
2192
+ };
2193
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2194
+ await api.user.profile.updateAvatar(params, session);
1991
2195
  ```
1992
2196
  <a name="Organization+removeAvatar"></a>
1993
2197
 
@@ -2002,7 +2206,10 @@ Remove avatar of user by session of user not allow session user SU
2002
2206
 
2003
2207
  **Example**
2004
2208
  ```js
2005
- const API = require('@docbrasil/api-systemmanager');
2209
+ const API = require('@docbrasil/api-systemmanager');
2210
+ const api = new API();
2211
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2212
+ await api.user.profile.removeAvatar(session);
2006
2213
  ```
2007
2214
  <a name="Organization+callFetch"></a>
2008
2215
 
@@ -2022,7 +2229,14 @@ Call URL internal, need auth JWT (session)
2022
2229
 
2023
2230
  **Example**
2024
2231
  ```js
2025
- const API = require('@docbrasil/api-systemmanager');
2026
2232
  url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
2027
2233
  method: 'POST'
2234
+ const API = require('@docbrasil/api-systemmanager');
2235
+ const api = new API();
2236
+
2237
+ const params = {
2238
+ url: 'http://localhost:8080/organizations/..../process/..../task/candidateAccepted/end/....',
2239
+ method: 'POST'
2240
+ }
2241
+ await api.user.organization.callFetchs(params, session);
2028
2242
  ```
2029
2243
  <a name="Page"></a>
2030
2244
 
@@ -2049,7 +2263,15 @@ Get the available page for an application inside an organization
2049
2263
 
2050
2264
  **Example**
2051
2265
  ```js
2052
- const API = require('@docbrasil/api-systemmanager');
2053
2266
  orgId: '55e4a3bd6be6b45210833fae',
2054
2267
  appId: '57e4a3bd6be6b45210833fa7',
2055
2268
  pageId: '57e4a3bd6be6b45210833fab'
2269
+ const API = require('@docbrasil/api-systemmanager');
2270
+ const api = new API();
2271
+ const params = {
2272
+ orgId: '55e4a3bd6be6b45210833fae',
2273
+ appId: '57e4a3bd6be6b45210833fa7',
2274
+ pageId: '57e4a3bd6be6b45210833fab'
2275
+ };
2276
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2277
+ await api.user.application.page.get(params, session);
2056
2278
  ```
2057
2279
  <a name="Process"></a>
2058
2280
 
@@ -2088,7 +2310,15 @@ Start process
2088
2310
 
2089
2311
  **Example**
2090
2312
  ```js
2091
- const API = require('@docbrasil/api-systemmanager');
2092
2313
  orgProcessId: '5dadd01dc4af3941d42f8c5c',
2093
2314
  orgId: '5edd11c46b6ce9729c2c297c',
2094
2315
  payload: {}
2316
+ const API = require('@docbrasil/api-systemmanager');
2317
+ const api = new API();
2318
+ const params = {
2319
+ orgProcessId: '5dadd01dc4af3941d42f8c5c',
2320
+ orgId: '5edd11c46b6ce9729c2c297c',
2321
+ payload: {}
2322
+ }
2323
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2324
+ await api.user.process.start(params, session);
2095
2325
  ```
2096
2326
  <a name="Process+getProcessProperties"></a>
2097
2327
 
@@ -2108,7 +2338,14 @@ Get process properties of process
2108
2338
 
2109
2339
  **Example**
2110
2340
  ```js
2111
- const API = require('@docbrasil/api-systemmanager');
2112
2341
  processId: '5dadd01dc4af3941d42f8c5c',
2113
2342
  orgId: '5edd11c46b6ce9729c2c297c',
2343
+ const API = require('@docbrasil/api-systemmanager');
2344
+ const api = new API();
2345
+ const params = {
2346
+ processId: '5dadd01dc4af3941d42f8c5c',
2347
+ orgId: '5edd11c46b6ce9729c2c297c',
2348
+ }
2349
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2350
+ await api.user.process.getProcessProperties(params, session);
2114
2351
  ```
2115
2352
  <a name="Process+getOrgProcessSearchInfo"></a>
2116
2353
 
@@ -2116,7 +2353,8 @@ const API = require('@docbrasil/api-systemmanager');
2116
2353
  Get the search info of a organization process
2117
2354
 
2118
2355
  **Kind**: instance method of [<code>Process</code>](#Process)
2119
- **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
2356
+ **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
2357
+ @
2120
2358
  **Access**: public
2121
2359
  **Author**: CloudBrasil <abernardo.br@gmail.com>
2122
2360
 
@@ -2129,7 +2367,14 @@ Get the search info of a organization process
2129
2367
 
2130
2368
  **Example**
2131
2369
  ```js
2132
- const API = require('@docbrasil/api-systemmanager');
2133
2370
  orgProcessId: '5dadd01dc4af3941d42f8c67',
2134
2371
  orgId: '5edd11c46b6ce9729c2c297c',
2372
+ const API = require('@docbrasil/api-systemmanager');
2373
+ const api = new API();
2374
+ const params = {
2375
+ orgProcessId: '5dadd01dc4af3941d42f8c67',
2376
+ orgId: '5edd11c46b6ce9729c2c297c',
2377
+ }
2378
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2379
+ const retSearchInfo = await api.user.process.getOrgProcessSearchInfo(params, session);
2135
2380
  ```
2136
2381
  <a name="Process+find"></a>
2137
2382
 
@@ -2150,7 +2395,14 @@ Method to search processes
2150
2395
 
2151
2396
  **Example**
2152
2397
  ```js
2153
- const API = require('@docbrasil/api-systemmanager');
2154
2398
  query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2155
2399
  orgId: '55e4a3bd6be6b45210833fae',
2400
+ const API = require('@docbrasil/api-systemmanager');
2401
+ const api = new API();
2402
+ const params = {
2403
+ query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2404
+ orgId: '55e4a3bd6be6b45210833fae',
2405
+ };
2406
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2407
+ const retSearch = await api.user.process.find(params, session);
2156
2408
  ```
2157
2409
  <a name="Process+remove"></a>
2158
2410
 
@@ -2170,7 +2422,14 @@ Method to remove process
2170
2422
 
2171
2423
  **Example**
2172
2424
  ```js
2173
- const API = require('@docbrasil/api-systemmanager');
2174
2425
  orgId: '55e4a3bd6be6b45210833fae',
2175
2426
  processId: '55e4a3bd6be6b45210833fae'
2427
+ const API = require('@docbrasil/api-systemmanager');
2428
+ const api = new API();
2429
+ const params = {
2430
+ orgId: '55e4a3bd6be6b45210833fae',
2431
+ processId: '55e4a3bd6be6b45210833fae'
2432
+ };
2433
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2434
+ const retSearch = await api.user.process.remove(params, session);
2176
2435
  ```
2177
2436
  <a name="Process+exportStatusData"></a>
2178
2437
 
@@ -2190,7 +2449,14 @@ Method to export status data
2190
2449
 
2191
2450
  **Example**
2192
2451
  ```js
2193
- const API = require('@docbrasil/api-systemmanager');
2194
2452
  query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2195
2453
  orgId: '55e4a3bd6be6b45210833fae',
2454
+ const API = require('@docbrasil/api-systemmanager');
2455
+ const api = new API();
2456
+ const params = {
2457
+ query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2458
+ orgId: '55e4a3bd6be6b45210833fae',
2459
+ };
2460
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2461
+ const retSearch = await api.user.process.exportStatusData(params, session);
2196
2462
  ```
2197
2463
  <a name="Process+exportProcessData"></a>
2198
2464
 
@@ -2210,7 +2476,14 @@ Method to export process data
2210
2476
 
2211
2477
  **Example**
2212
2478
  ```js
2213
- const API = require('@docbrasil/api-systemmanager');
2214
2479
  query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2215
2480
  orgId: '55e4a3bd6be6b45210833fae',
2481
+ const API = require('@docbrasil/api-systemmanager');
2482
+ const api = new API();
2483
+ const params = {
2484
+ query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2485
+ orgId: '55e4a3bd6be6b45210833fae',
2486
+ };
2487
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2488
+ const retSearch = await api.user.process.exportProcessData(params, session);
2216
2489
  ```
2217
2490
  <a name="Process+processDocs"></a>
2218
2491
 
@@ -2232,7 +2505,15 @@ Method to get Process Docs
2232
2505
 
2233
2506
  **Example**
2234
2507
  ```js
2235
- const API = require('@docbrasil/api-systemmanager');
2236
2508
  orgProcessId: '55e4a3bd6be6b45210833fae',
2237
2509
  processId: '55e4a3bd6be6b45210833fae',
2238
2510
  orgId: '55e4a3bd6be6b45210833fae',
2511
+ const API = require('@docbrasil/api-systemmanager');
2512
+ const api = new API();
2513
+ const params = {
2514
+ orgProcessId: '55e4a3bd6be6b45210833fae',
2515
+ processId: '55e4a3bd6be6b45210833fae',
2516
+ orgId: '55e4a3bd6be6b45210833fae',
2517
+ };
2518
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2519
+ const retSearch = await api.user.process.processDocs(params, session);
2239
2520
  ```
2240
2521
  <a name="Process+downloadDocs"></a>
2241
2522
 
@@ -2255,7 +2536,16 @@ Method to download the process documents
2255
2536
 
2256
2537
  **Example**
2257
2538
  ```js
2258
- const API = require('@docbrasil/api-systemmanager');
2259
2539
  orgId: '55e4a3bd6be6b45210833fae',
2260
2540
  type: 'Docs',
2261
2541
  docIds: ['55e4a3bd6be6b45210833fae'],
2262
2542
  footer: 'Documento - {page} de {pages}'
2543
+ const API = require('@docbrasil/api-systemmanager');
2544
+ const api = new API();
2545
+ const params = {
2546
+ orgId: '55e4a3bd6be6b45210833fae',
2547
+ type: 'Docs',
2548
+ docIds: ['55e4a3bd6be6b45210833fae'],
2549
+ footer: 'Documento - {page} de {pages}'
2550
+ };
2551
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2552
+ const result = await api.user.process.downloadDocs(params, session);
2263
2553
  ```
2264
2554
  <a name="Register"></a>
2265
2555
 
@@ -2283,7 +2573,12 @@ Class for user registration in a user
2283
2573
 
2284
2574
  **Example**
2285
2575
  ```js
2286
- const API = require('@docbrasil/api-systemmanager');
2287
2576
  registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...'
2577
+ const API = require('@docbrasil/api-systemmanager');
2578
+ const api = new API();
2579
+ const params = {
2580
+ registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...'
2581
+ };
2582
+ const orgname = await api.user.register.getOrgname(params);
2288
2583
  ```
2289
2584
  <a name="Register+validateEmail"></a>
2290
2585
 
@@ -2303,7 +2598,13 @@ Method to find task by id
2303
2598
 
2304
2599
  **Example**
2305
2600
  ```js
2306
- const API = require('@docbrasil/api-systemmanager');
2307
2601
  registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
2308
2602
  email: 'myemail@company.com'
2603
+ const API = require('@docbrasil/api-systemmanager');
2604
+ const api = new API();
2605
+ const params = {
2606
+ registerId: 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
2607
+ email: 'myemail@company.com'
2608
+ };
2609
+ const retData = await api.user.register.validateEmail(params);
2309
2610
  ```
2310
2611
  <a name="Register+execute"></a>
2311
2612
 
@@ -2337,60 +2638,30 @@ Method to register a user
2337
2638
 
2338
2639
  **Example**
2339
2640
  ```js
2340
- const API = require('@docbrasil/api-systemmanager');
2341
2641
  "registerId": 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
2342
2642
  "type": 'sign',
2343
2643
  "login": false,
2344
2644
  "emailInfo": {
2345
2645
  "code": "5974",
2346
2646
  "email": "cbtoto_1@mailinator.com"
2347
2647
  },
2348
2648
  "registerData": {
2349
2649
  "name": "Augusto Totlo",
2350
2650
  "registerEmail": "cbtoto_1@mailinator.com",
2351
2651
  "phone": "",
2352
2652
  "idcard": "",
2353
2653
  "dob": "1978-01-12T03:00:00.000Z",
2354
2654
  "registerPassword": "123456",
2355
2655
  "emailValidationCode": "5974",
2356
2656
  "phoneValidationCode": "",
2357
2657
  "language": "en-US",
2358
2658
  "timezone": "Europe/Dublin"
2359
2659
  }
2360
2660
  };
2361
- ```
2362
- <a name="TaskAvailable"></a>
2363
-
2364
- ## TaskAvailable
2365
- Class for available tasks, permission user
2366
-
2367
- **Kind**: global class
2368
-
2369
- * [TaskAvailable](#TaskAvailable)
2370
- * [.find(params, session)](#TaskAvailable+find) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
2371
- * [.claim(params, session)](#TaskAvailable+claim) ⇒ <code>promise</code> \| <code>boolean</code>
2372
-
2373
- <a name="TaskAvailable+find"></a>
2374
-
2375
- ### taskAvailable.find(params, session) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
2376
- Method to find available tasks for a user
2377
-
2378
- **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
2379
- **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
2380
- **Access**: public
2381
- **Author**: CloudBrasil <abernardo.br@gmail.com>
2382
-
2383
- | Param | Type | Description |
2384
- | --- | --- | --- |
2385
- | params | <code>object</code> | Params to get task |
2386
- | params.query | <code>object</code> | Search available tasks query |
2387
- | params.orgId | <code>object</code> | Organization id (_id database) |
2388
- | session | <code>string</code> | Session, token JWT |
2389
-
2390
- **Example**
2391
- ```js
2392
- const API = require('@docbrasil/api-systemmanager');
2393
2661
  query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2394
2662
  orgId: '55e4a3bd6be6b45210833fae',
2395
- ```
2396
- <a name="TaskAvailable+claim"></a>
2397
-
2398
- ### taskAvailable.claim(params, session) ⇒ <code>promise</code> \| <code>boolean</code>
2399
- Method for a user to claim an available task
2400
-
2401
- **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
2402
- **Returns**: <code>promise</code> - returned data from the method call<code>boolean</code> - success true|false if the method was successful
2403
- **Access**: public
2404
- **Author**: CloudBrasil <abernardo.br@gmail.com>
2405
-
2406
- | Param | Type | Description |
2407
- | --- | --- | --- |
2408
- | params | <code>object</code> | Params to get task |
2409
- | params.taskId | <code>object</code> | the task id to claim |
2410
- | params.orgname | <code>object</code> | Organization slug (short name of the orgnization) |
2411
- | session | <code>string</code> | Session, token JWT |
2412
-
2413
- **Example**
2414
- ```js
2415
- const API = require('@docbrasil/api-systemmanager');
2416
2663
  taskId: '55e4a3bd6be6b45210833f67',
2417
2664
  orgname: 'acme',
2665
+ const API = require('@docbrasil/api-systemmanager');
2666
+ const api = new API();
2667
+ const params ={
2668
+ "registerId": 'U2FsdGVkX1+xEq+sV6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz24O5koH+rGmdl/DjqfyWfENe5NFuQ+6xXhuOSN24Z+Topo87+e+CrRO8ox...',
2669
+ "type": 'sign',
2670
+ "login": false,
2671
+ "emailInfo": {
2672
+ "code": "5974",
2673
+ "email": "cbtoto_1@mailinator.com"
2674
+ },
2675
+ "registerData": {
2676
+ "name": "Augusto Totlo",
2677
+ "registerEmail": "cbtoto_1@mailinator.com",
2678
+ "phone": "",
2679
+ "idcard": "",
2680
+ "dob": "1978-01-12T03:00:00.000Z",
2681
+ "registerPassword": "123456",
2682
+ "emailValidationCode": "5974",
2683
+ "phoneValidationCode": "",
2684
+ "language": "en-US",
2685
+ "timezone": "Europe/Dublin"
2686
+ }
2687
+ };
2688
+ const retData = await api.user.register.execute(params);
2418
2689
  ```
2419
2690
  <a name="Task"></a>
2420
2691
 
@@ -2423,7 +2694,15 @@ Method to find task by id
2423
2694
 
2424
2695
  **Example**
2425
2696
  ```js
2426
- const API = require('@docbrasil/api-systemmanager');
2427
2697
  processId: '5dadd01dc4af3941d42f8c5c',
2428
2698
  taskId: '5df7f19618430c89a41a19d2',
2429
2699
  orgId: '55e4a3bd6be6b45210833fae',
2700
+ const API = require('@docbrasil/api-systemmanager');
2701
+ const api = new API();
2702
+ const params = {
2703
+ processId: '5dadd01dc4af3941d42f8c5c',
2704
+ taskId: '5df7f19618430c89a41a19d2',
2705
+ orgId: '55e4a3bd6be6b45210833fae',
2706
+ };
2707
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2708
+ await api.user.task.findById(params, session);
2430
2709
  ```
2431
2710
  <a name="Task+findByIdAndUpdate"></a>
2432
2711
 
@@ -2449,7 +2728,17 @@ Find task by id and update
2449
2728
 
2450
2729
  **Example**
2451
2730
  ```js
2452
- const API = require('@docbrasil/api-systemmanager');
2453
2731
  userId: '5739d4c6ccb0ebc61f2a9557',
2454
2732
  processId: '5dadd01dc4af3941d42f8c5c',
2455
2733
  taskId: '5df7f19618430c89a41a19d2',
2456
2734
  action: 1,
2457
2735
  formData: {name: 'CloudBrasil'},
2736
+ const API = require('@docbrasil/api-systemmanager');
2737
+ const api = new API();
2738
+ const params = {
2739
+ userId: '5739d4c6ccb0ebc61f2a9557',
2740
+ processId: '5dadd01dc4af3941d42f8c5c',
2741
+ taskId: '5df7f19618430c89a41a19d2',
2742
+ action: 1,
2743
+ formData: {name: 'CloudBrasil'},
2744
+ };
2745
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2746
+ await api.user.task.findByIdAndUpdate(params, session);
2458
2747
  ```
2459
2748
  <a name="Task+executeActionFinalize"></a>
2460
2749
 
@@ -2471,32 +2760,111 @@ Find task by id and update
2471
2760
 
2472
2761
  **Example**
2473
2762
  ```js
2474
- const API = require('@docbrasil/api-systemmanager');
2475
2763
  taskId: '5df7f19618430c89a41a19d2',
2476
2764
  actionGuid: 'b3823a2ae52c7a05bfb9590fe427038d'
2477
2765
  orgId: '5df7f19618430c89a41a1bc3',
2478
2766
  payload: {}',
2767
+ const API = require('@docbrasil/api-systemmanager');
2768
+ const api = new API();
2769
+ const params = {
2770
+ taskId: '5df7f19618430c89a41a19d2',
2771
+ actionGuid: 'b3823a2ae52c7a05bfb9590fe427038d'
2772
+ orgId: '5df7f19618430c89a41a1bc3',
2773
+ payload: {}',
2774
+ };
2775
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2776
+ await api.user.task.executeActionFinalize(params, session);
2479
2777
  ```
2480
- <a name="Updates"></a>
2778
+ <a name="TaskAvailable"></a>
2481
2779
 
2482
- ## Updates
2483
- Class for user registration in a user
2780
+ ## TaskAvailable
2781
+ Class for available tasks, permission user
2484
2782
 
2485
2783
  **Kind**: global class
2486
- <a name="Updates+get"></a>
2487
2784
 
2488
- ### updates.get(session)
2489
- get updates
2785
+ * [TaskAvailable](#TaskAvailable)
2786
+ * [.find(params, session)](#TaskAvailable+find) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
2787
+ * [.claim(params, session)](#TaskAvailable+claim) ⇒ <code>promise</code> \| <code>boolean</code>
2490
2788
 
2491
- **Kind**: instance method of [<code>Updates</code>](#Updates)
2789
+ <a name="TaskAvailable+find"></a>
2790
+
2791
+ ### taskAvailable.find(params, session) ⇒ <code>promise</code> \| <code>number</code> \| <code>array.&lt;object&gt;</code> \| <code>number</code> \| <code>number</code>
2792
+ Method to find available tasks for a user
2793
+
2794
+ **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
2795
+ **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
2492
2796
  **Access**: public
2493
- **Author**: Augusto Pissarra <abernardo.br@gmail.com>
2797
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
2494
2798
 
2495
2799
  | Param | Type | Description |
2496
2800
  | --- | --- | --- |
2497
- | session | <code>string</code> | JWT token |
2801
+ | params | <code>object</code> | Params to get task |
2802
+ | params.query | <code>object</code> | Search available tasks query |
2803
+ | params.orgId | <code>object</code> | Organization id (_id database) |
2804
+ | session | <code>string</code> | Session, token JWT |
2498
2805
 
2499
2806
  **Example**
2500
2807
  ```js
2501
- const API = require('@docbrasil/api-systemmanager');
2808
+ const API = require('@docbrasil/api-systemmanager');
2809
+ const api = new API();
2810
+ const params = {
2811
+ query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
2812
+ orgId: '55e4a3bd6be6b45210833fae',
2813
+ };
2814
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2815
+ const retSearch = await api.user.task.available.find(params, session);
2502
2816
  ```
2503
- <a name="User"></a>
2817
+ <a name="TaskAvailable+claim"></a>
2818
+
2819
+ ### taskAvailable.claim(params, session) ⇒ <code>promise</code> \| <code>boolean</code>
2820
+ Method for a user to claim an available task
2821
+
2822
+ **Kind**: instance method of [<code>TaskAvailable</code>](#TaskAvailable)
2823
+ **Returns**: <code>promise</code> - returned data from the method call<code>boolean</code> - success true|false if the method was successful
2824
+ **Access**: public
2825
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
2826
+
2827
+ | Param | Type | Description |
2828
+ | --- | --- | --- |
2829
+ | params | <code>object</code> | Params to get task |
2830
+ | params.taskId | <code>object</code> | the task id to claim |
2831
+ | params.orgname | <code>object</code> | Organization slug (short name of the orgnization) |
2832
+ | session | <code>string</code> | Session, token JWT |
2833
+
2834
+ **Example**
2835
+ ```js
2836
+ const API = require('@docbrasil/api-systemmanager');
2837
+ const api = new API();
2838
+ const params = {
2839
+ taskId: '55e4a3bd6be6b45210833f67',
2840
+ orgname: 'acme',
2841
+ };
2842
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2843
+ const success = await api.user.task.available.claim(params, session);
2844
+ ```
2845
+ <a name="Updates"></a>
2846
+
2847
+ ## Updates
2848
+ Class for user registration in a user
2849
+
2850
+ **Kind**: global class
2851
+ <a name="Updates+get"></a>
2852
+
2853
+ ### updates.get(session)
2854
+ get updates
2855
+
2856
+ **Kind**: instance method of [<code>Updates</code>](#Updates)
2857
+ **Access**: public
2858
+ **Author**: Augusto Pissarra <abernardo.br@gmail.com>
2859
+
2860
+ | Param | Type | Description |
2861
+ | --- | --- | --- |
2862
+ | session | <code>string</code> | JWT token |
2863
+
2864
+ **Example**
2865
+ ```js
2866
+ const API = require('@docbrasil/api-systemmanager');
2867
+ const api = new API();
2868
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2869
+ await api.user.updates.get(session);
2870
+ ```
2871
+ <a name="User"></a>
2504
2872
 
2505
2873
  ## User
2506
2874
  Class for user, permission user
@@ -2529,7 +2897,14 @@ Update avatar of user by session of user not allow session user SU
2529
2897
 
2530
2898
  **Example**
2531
2899
  ```js
2532
- const API = require('@docbrasil/api-systemmanager');
2533
2900
  avatar: '55e4a3bd6be6b45210833fae',
2534
2901
  type: '123456',
2902
+ const API = require('@docbrasil/api-systemmanager');
2903
+ const api = new API();
2904
+ const params = {
2905
+ avatar: '55e4a3bd6be6b45210833fae',
2906
+ type: '123456',
2907
+ };
2908
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2909
+ await api.user.profile.updateAvatar(params, session);
2535
2910
  ```
2536
2911
  <a name="User+removeAvatar"></a>
2537
2912
 
@@ -2546,7 +2921,10 @@ Remove avatar of user by session of user not allow session user SU
2546
2921
 
2547
2922
  **Example**
2548
2923
  ```js
2549
- const API = require('@docbrasil/api-systemmanager');
2924
+ const API = require('@docbrasil/api-systemmanager');
2925
+ const api = new API();
2926
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2927
+ await api.user.profile.removeAvatar(session);
2550
2928
  ```
2551
2929
  <a name="User+removeSignature"></a>
2552
2930
 
@@ -2563,7 +2941,10 @@ Remove the signature of user by session
2563
2941
 
2564
2942
  **Example**
2565
2943
  ```js
2566
- const API = require('@docbrasil/api-systemmanager');
2944
+ const API = require('@docbrasil/api-systemmanager');
2945
+ const api = new API();
2946
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2947
+ await api.user.profile.removeSignature(session);
2567
2948
  ```
2568
2949
  <a name="User+saveSignature"></a>
2569
2950
 
@@ -2583,7 +2964,23 @@ Sava a new signature of user by session
2583
2964
 
2584
2965
  **Example**
2585
2966
  ```js
2586
- const API = require('@docbrasil/api-systemmanager');
2587
2967
  type: 'CURSIVE',
2588
2968
  file: 'allura:Mary John Heart'
2589
2969
  type: 'HANDWRITE',
2590
2970
  file: 'iVBORw0KGgoAAAANSUhEUgAAAj...'
2971
+ const API = require('@docbrasil/api-systemmanager');
2972
+ const api = new API();
2973
+ const data = {
2974
+ type: 'CURSIVE',
2975
+ file: 'allura:Mary John Heart'
2976
+ };
2977
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2978
+ await api.user.profile.saveSignature(data, session);
2979
+
2980
+ const API = require('@docbrasil/api-systemmanager');
2981
+ const api = new API();
2982
+ const data = {
2983
+ type: 'HANDWRITE',
2984
+ file: 'iVBORw0KGgoAAAANSUhEUgAAAj...'
2985
+ };
2986
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
2987
+ await api.user.profile.saveSignature(session);
2591
2988
  ```
2592
2989
  <a name="User+findByIdAndUpdate"></a>
2593
2990
 
@@ -2617,7 +3014,13 @@ Update a user profile by id
2617
3014
 
2618
3015
  **Example**
2619
3016
  ```js
2620
- const API = require('@docbrasil/api-systemmanager');
2621
3017
  name: 'New Name'
3018
+ const API = require('@docbrasil/api-systemmanager');
3019
+ const api = new API();
3020
+ const params = {
3021
+ name: 'New Name'
3022
+ };
3023
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
3024
+ await api.user.profile.findByIdAndUpdate(params, session);
2622
3025
  ```
2623
3026
  <a name="User+changeOrganization"></a>
2624
3027
 
@@ -2635,5 +3038,379 @@ Change a user's organization
2635
3038
 
2636
3039
  **Example**
2637
3040
  ```js
2638
- const API = require('@docbrasil/api-systemmanager');
3041
+ const API = require('@docbrasil/api-systemmanager');
3042
+ const api = new API();
3043
+ const id = '616eccaaa9360a05293b10fe';
3044
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
3045
+ await api.user.changeOrganization.updateAvatar(id, session);
3046
+ ```
3047
+ <a name="Dispatch"></a>
3048
+
3049
+ ## Dispatch
3050
+ Api dispatch manager
3051
+
3052
+ **Kind**: global class
3053
+
3054
+ * [Dispatch](#Dispatch)
3055
+ * [.getContext(url, session)](#Dispatch+getContext) ⇒ <code>Promise.&lt;object&gt;</code>
3056
+ * [.getClient()](#Dispatch+getClient) ⇒ <code>promise</code>
3057
+
3058
+ <a name="Dispatch+getContext"></a>
3059
+
3060
+ ### dispatch.getContext(url, session) ⇒ <code>Promise.&lt;object&gt;</code>
3061
+ Get the URL context
3062
+
3063
+ **Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
3064
+ **Returns**: <code>Promise.&lt;object&gt;</code> - The full data context of the URL
3065
+ **Access**: public
3066
+
3067
+ | Param | Type | Default | Description |
3068
+ | --- | --- | --- | --- |
3069
+ | url | <code>string</code> | | Full url |
3070
+ | session | <code>session</code> | <code></code> | Session, token JWT |
3071
+
3072
+ **Example**
3073
+ ```js
3074
+ const API = require('@docbrasil/api-systemmanager');
3075
+ const api = new API();
3076
+ const retContext = await api.dispatch.getContext('http://myndware.io/login/myorg);
3077
+ ```
3078
+ <a name="Dispatch+getClient"></a>
3079
+
3080
+ ### dispatch.getClient() ⇒ <code>promise</code>
3081
+ Get client Axios
3082
+
3083
+ **Kind**: instance method of [<code>Dispatch</code>](#Dispatch)
3084
+ **Returns**: <code>promise</code> - return client axios
3085
+ **Access**: public
3086
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3087
+ **Example**
3088
+ ```js
3089
+ const API = require('@docbrasil/api-systemmanager');
3090
+ const api = new API();
3091
+ await api.dispatch.getClient();
3092
+ ```
3093
+ <a name="External"></a>
3094
+
3095
+ ## External
3096
+ Class for documents, permission user
3097
+
3098
+ **Kind**: global class
3099
+
3100
+ * [External](#External)
3101
+ * [.context(params)](#External+context) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>array.&lt;object&gt;</code>
3102
+ * [.getUploadDocumentSignedUrl(mime, authorization)](#External+getUploadDocumentSignedUrl) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
3103
+ * [.getUploadDocumentsSignedUrl(docs, authorization)](#External+getUploadDocumentsSignedUrl) ⇒ <code>Promise.&lt;array&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
3104
+ * [.handle(authorization, params)](#External+handle) ⇒ <code>Promise.&lt;boolean&gt;</code>
3105
+
3106
+ <a name="External+context"></a>
3107
+
3108
+ ### external.context(params) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>array.&lt;object&gt;</code>
3109
+ Create new document
3110
+
3111
+ **Kind**: instance method of [<code>External</code>](#External)
3112
+ **Returns**: <code>Promise.&lt;object&gt;</code> - data<code>string</code> - _id the id of the form<code>string</code> - orgId the organization id of the form<code>string</code> - authorization the unique token registered internally by the system for all the next calls to the external form APIs
3113
+ The authorization is unique and is ONLY valid for this session.<code>array.&lt;object&gt;</code> - groups the form groups to render
3114
+ **Access**: public
3115
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3116
+
3117
+ | Param | Type | Description |
3118
+ | --- | --- | --- |
3119
+ | params | <code>object</code> | Object for add new document |
3120
+ | params.id | <code>string</code> | Organization form id |
3121
+
3122
+ **Example**
3123
+ ```js
3124
+ const API = require('@docbrasil/api-systemmanager');
3125
+ const api = new API();
3126
+ const params = {
3127
+ id: '611e679741cc63168c26d7ee'
3128
+ };
3129
+ const retForm = await api.external.context(params);
3130
+ ```
3131
+ <a name="External+getUploadDocumentSignedUrl"></a>
3132
+
3133
+ ### external.getUploadDocumentSignedUrl(mime, authorization) ⇒ <code>Promise.&lt;object&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
3134
+ Get an upload signed url, so it will be possible to upload documents temporarily during the use of the external form
3135
+
3136
+ **Kind**: instance method of [<code>External</code>](#External)
3137
+ **Returns**: <code>Promise.&lt;object&gt;</code> - doc<code>string</code> - doc.mime the original mime type of the document<code>string</code> - doc.signedUrl the signed url to upload the document<code>string</code> - doc.filename the filename of the uploaded file<code>string</code> - doc.extension the extension of the filename, obtained from the mime type
3138
+ **Access**: public
3139
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3140
+
3141
+ | Param | Type | Description |
3142
+ | --- | --- | --- |
3143
+ | mime | <code>string</code> | the mime type of the document |
3144
+ | authorization | <code>string</code> | a legal authorization |
3145
+
3146
+ **Example**
3147
+ ```js
3148
+ const API = require('@docbrasil/api-systemmanager');
3149
+ const api = new API();
3150
+ const authorization = '...';
3151
+ const doc = {
3152
+ mime: 'application/pdf'
3153
+ };
3154
+ const retDoc = await api.external.getUploadDocumentSignedUrl(doc, authorization);
3155
+ ```
3156
+ <a name="External+getUploadDocumentsSignedUrl"></a>
3157
+
3158
+ ### external.getUploadDocumentsSignedUrl(docs, authorization) ⇒ <code>Promise.&lt;array&gt;</code> \| <code>string</code> \| <code>string</code> \| <code>string</code> \| <code>string</code>
3159
+ Get an upload signed url, for many documents. So it will be possible to upload documents temporarily during the use of the external form
3160
+
3161
+ **Kind**: instance method of [<code>External</code>](#External)
3162
+ **Returns**: <code>Promise.&lt;array&gt;</code> - docs<code>string</code> - docs.mime the original mime type of the document<code>string</code> - docs.signedUrl the signed url to upload the document<code>string</code> - docs.filename the filename of the uploaded file<code>string</code> - docs.extension the extension of the filename, obtained from the mime type
3163
+ **Access**: public
3164
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3165
+
3166
+ | Param | Type | Description |
3167
+ | --- | --- | --- |
3168
+ | docs | <code>array.&lt;object&gt;</code> | the list of documents |
3169
+ | docs.mime | <code>string</code> | the mime type of the document |
3170
+ | authorization | <code>string</code> | a legal authorization |
3171
+
3172
+ **Example**
3173
+ ```js
3174
+ const API = require('@docbrasil/api-systemmanager');
3175
+ const api = new API();
3176
+ const authorization = '...';
3177
+ const docs = [
3178
+ {
3179
+ mime: 'application/pdf'
3180
+ }
3181
+ ];
3182
+ const retDocs = await api.external.getUploadDocumentsSignedUrl(docs, authorization);
3183
+ ```
3184
+ <a name="External+handle"></a>
3185
+
3186
+ ### external.handle(authorization, params) ⇒ <code>Promise.&lt;boolean&gt;</code>
3187
+ Handles the execution of an external form
3188
+
3189
+ **Kind**: instance method of [<code>External</code>](#External)
3190
+ **Returns**: <code>Promise.&lt;boolean&gt;</code> - true|false if success
3191
+ **Access**: public
3192
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3193
+
3194
+ | Param | Type | Description |
3195
+ | --- | --- | --- |
3196
+ | authorization | <code>string</code> | a legal authorization |
3197
+ | params | <code>object</code> | the parameters to handle the execution of an external form |
3198
+ | params.payload | <code>array.&lt;object&gt;</code> | the payload of the external form. It should represent the form groups of the external form |
3199
+ | params.payload.name | <code>string</code> | the name of the group |
3200
+ | params.payload.fields | <code>array.&lt;object&gt;</code> | the fields that belong to each group |
3201
+ | params.payload.fields.value | <code>\*</code> \| <code>Object</code> | besides all the data inside a field, it should have the value of the the field |
3202
+
3203
+ **Example**
3204
+ ```js
3205
+ const API = require('@docbrasil/api-systemmanager');
3206
+ const api = new API();
3207
+ const authorization = '...';
3208
+ const params = {
3209
+ payload: [
3210
+ {
3211
+ name: 'My Group One',
3212
+ fields: [
3213
+ {}
3214
+ ]
3215
+ }
3216
+ ]
3217
+ };
3218
+ const success = await api.external.handle(params, authorization);
3219
+ ```
3220
+ <a name="Login"></a>
3221
+
3222
+ ## Login
3223
+ Login manager
3224
+
3225
+ **Kind**: global class
3226
+
3227
+ * [Login](#Login)
3228
+ * [.facebook(params)](#Login+facebook) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3229
+ * [.google(params)](#Login+google) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3230
+ * [.apiKey(apikey)](#Login+apiKey) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3231
+ * [.userPass(params)](#Login+userPass) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3232
+ * [.logout(session)](#Login+logout) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
3233
+ * [.recover(username)](#Login+recover) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
3234
+
3235
+ <a name="Login+facebook"></a>
3236
+
3237
+ ### login.facebook(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3238
+ Login with social login Facebook
3239
+
3240
+ **Kind**: instance method of [<code>Login</code>](#Login)
3241
+ **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
3242
+ **Access**: public
3243
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3244
+
3245
+ | Param | Type | Description |
3246
+ | --- | --- | --- |
3247
+ | params | <code>object</code> | Params to login Facebook |
3248
+ | params.accessToken | <code>string</code> | Access token of the system manager |
3249
+ | params.initialUserData | <code>object</code> | Object with roles default if sigin |
3250
+ | params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
3251
+
3252
+ **Example**
3253
+ ```js
3254
+ const API = require('@docbrasil/api-systemmanager');
3255
+
3256
+ // Params of the instance
3257
+ const params = {...}
3258
+ const api = new API(params);
3259
+ const params = { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cC...' };
3260
+ const { auth, user } = await api.login.facebook(params);
3261
+ ```
3262
+ <a name="Login+google"></a>
3263
+
3264
+ ### login.google(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3265
+ Login with social login Google
3266
+
3267
+ **Kind**: instance method of [<code>Login</code>](#Login)
3268
+ **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
3269
+ **Access**: public
3270
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3271
+
3272
+ | Param | Type | Description |
3273
+ | --- | --- | --- |
3274
+ | params | <code>object</code> | Params to login Google |
3275
+ | params.accessToken | <code>string</code> | Access token of the system manager |
3276
+ | params.initialUserData | <code>object</code> | Object with roles default if sigin |
3277
+ | params.initialUserData.externalRoles | <code>array</code> | Array with permission of user |
3278
+
3279
+ **Example**
3280
+ ```js
3281
+ const API = require('@docbrasil/api-systemmanager');
3282
+
3283
+ // Params of the instance
3284
+ const params = {...}
3285
+ const api = new API(params);
3286
+ const accessToken = 'eyJhbGciOiJIUzI1NiIsInR5cC...';
3287
+ const { auth, user } = await api.login.google(accessToken);
3288
+ ```
3289
+ <a name="Login+apiKey"></a>
3290
+
3291
+ ### login.apiKey(apikey) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3292
+ Login with apikey
3293
+
3294
+ **Kind**: instance method of [<code>Login</code>](#Login)
3295
+ **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
3296
+ **Access**: public
3297
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3298
+
3299
+ | Param | Type | Description |
3300
+ | --- | --- | --- |
3301
+ | apikey | <code>string</code> | Access key |
3302
+
3303
+ **Example**
3304
+ ```js
3305
+ const API = require('@docbrasil/api-systemmanager');
3306
+
3307
+ // Params of the instance
3308
+ const params = {...}
3309
+ const api = new API(params);
3310
+ const apiKey = '043a0eb2-f5c3-4900-b781-7f229d00d092';
3311
+ const { auth, user } = await api.login.apiKey(apiKey);
3312
+ ```
3313
+ <a name="Login+userPass"></a>
3314
+
3315
+ ### login.userPass(params) ⇒ <code>promise.&lt;object&gt;</code> \| <code>object</code> \| <code>object</code>
3316
+ Login with user and password
3317
+
3318
+ **Kind**: instance method of [<code>Login</code>](#Login)
3319
+ **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
3320
+ **Access**: public
3321
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3322
+
3323
+ | Param | Type | Description |
3324
+ | --- | --- | --- |
3325
+ | params | <code>object</code> | Object with user and password |
3326
+ | params.username | <code>string</code> | Username or email of the user |
3327
+ | params.password | <code>string</code> | Password of the user |
3328
+ | params.orgname | <code>string</code> | The organame of the user |
3329
+
3330
+ **Example**
3331
+ ```js
3332
+ const API = require('@docbrasil/api-systemmanager');
3333
+
3334
+ // Params of the instance
3335
+ const params = {...}
3336
+ const api = new API(params);
3337
+ const params = {
3338
+ username: 'ana.silva@gmail.com',
3339
+ password: '123456'
3340
+ };
3341
+ const { auth, user } = await api.login.userPass(params);
3342
+ ```
3343
+ <a name="Login+logout"></a>
3344
+
3345
+ ### login.logout(session) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
3346
+ Logout user system manager
3347
+
3348
+ **Kind**: instance method of [<code>Login</code>](#Login)
3349
+ **Returns**: <code>promise.&lt;object&gt;</code> - } data<code>boolean</code> - data.success true|false
3350
+ **Access**: public
3351
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3352
+
3353
+ | Param | Type | Description |
3354
+ | --- | --- | --- |
3355
+ | session | <code>string</code> | Session, token JWT |
3356
+
3357
+ **Example**
3358
+ ```js
3359
+ const API = require('@docbrasil/api-systemmanager');
3360
+
3361
+ // Params of the instance
3362
+ const params = {...}
3363
+ const api = new API(params);
3364
+ const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
3365
+ const { success } = await api.login.logout(session);
3366
+ ```
3367
+ <a name="Login+recover"></a>
3368
+
3369
+ ### login.recover(username) ⇒ <code>promise.&lt;object&gt;</code> \| <code>boolean</code>
3370
+ Recover the password
3371
+
3372
+ **Kind**: instance method of [<code>Login</code>](#Login)
3373
+ **Returns**: <code>promise.&lt;object&gt;</code> - } data<code>boolean</code> - data.success true|false
3374
+ **Access**: public
3375
+ **Author**: CloudBrasil <abernardo.br@gmail.com>
3376
+
3377
+ | Param | Type | Description |
3378
+ | --- | --- | --- |
3379
+ | username | <code>string</code> | The username or email |
3380
+
3381
+ **Example**
3382
+ ```js
3383
+ const API = require('@docbrasil/api-systemmanager');
3384
+
3385
+ // Params of the instance
3386
+ const params = {...}
3387
+ const api = new API(params);
3388
+ const { success } = await api.login.recover('myusername');
3389
+ ```
3390
+ <a name="Session"></a>
3391
+
3392
+ ## Session
3393
+ Session manager of the API
3394
+
3395
+ **Kind**: global class
3396
+ <a name="Session+information"></a>
3397
+
3398
+ ### session.information(sessionId, suSessionId) ⇒ <code>Promise</code>
3399
+ Show information for session, thus validating the session (Valid token JWT)
3400
+
3401
+ **Kind**: instance method of [<code>Session</code>](#Session)
3402
+ **Access**: public
3403
+
3404
+ | Param | Type | Default | Description |
3405
+ | --- | --- | --- | --- |
3406
+ | sessionId | <code>string</code> | | The user session (JWT Token) |
3407
+ | suSessionId | <code>string</code> | <code>&quot;sessionId&quot;</code> | Given a JWT Token of a SU (SuperAdmin), allow to check session for another user. |
3408
+
3409
+ **Example**
3410
+ ```js
3411
+ const API = require('@docbrasil/api-systemmanager');
3412
+ const api = new API();
3413
+ const sessionId = 'eyJhbFVBBiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
3414
+ const suSessionId = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
3415
+ await api.session.information(sessionId, suSessionId);
2639
3416
  ```