@docbrasil/api-systemmanager 1.0.112 → 1.0.114

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.
@@ -345,6 +345,100 @@ class Process {
345
345
  throw ex;
346
346
  }
347
347
  }
348
+
349
+ /**
350
+ * @author CloudBrasil <abernardo.br@gmail.com>
351
+ * @description Method to get Process Docs
352
+ * @param {object} params Params to get process docs
353
+ * @param {string} params.orgProcessId Organization Process Id
354
+ * @param {string} params.processId Process Id
355
+ * @param {string} params.orgId Organization id (_id database)
356
+ * @param {string} session Session, token JWT
357
+ * @returns {promise} returned data from the get process docs
358
+ * @returns {array<object>} Docs returned from process
359
+ * @public
360
+ * @example
361
+ *
362
+ * const API = require('@docbrasil/api-systemmanager');
363
+ * const api = new API();
364
+ * const params = {
365
+ * orgProcessId: '55e4a3bd6be6b45210833fae',
366
+ * processId: '55e4a3bd6be6b45210833fae',
367
+ * orgId: '55e4a3bd6be6b45210833fae',
368
+ * };
369
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
370
+ * const retSearch = await api.user.process.processDocs(params, session);
371
+ */
372
+ async processDocs(params, session) {
373
+ const self = this;
374
+
375
+ try {
376
+ Joi.assert(params, Joi.object().required(), 'Params to get process docs');
377
+ Joi.assert(params.orgProcessId, Joi.string().required(), 'Organization Process Id');
378
+ Joi.assert(params.processId, Joi.string().required(), 'Process Id');
379
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
380
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
381
+
382
+ const {orgProcessId, processId, orgId} = params;
383
+ const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/process/${processId}/documents`, self._setHeader(session));
384
+ return self._returnData(await apiCall);
385
+ } catch (ex) {
386
+ throw ex;
387
+ }
388
+ }
389
+
390
+ /**
391
+ * @author CloudBrasil <abernardo.br@gmail.com>
392
+ * @description Method to download the process documents
393
+ * @param {object} params Params to download the process documents
394
+ * @param {string} params.orgId Organization id (_id database)
395
+ * @param {string} params.type Document Type
396
+ * @param {array} params.docIds Documents Ids
397
+ * @param {string} params.footer Documents Footer
398
+ * @param {string} session Session, token JWT
399
+ * @returns {promise} returned data from the search
400
+ * @public
401
+ * @example
402
+ *
403
+ * const API = require('@docbrasil/api-systemmanager');
404
+ * const api = new API();
405
+ * const params = {
406
+ * orgId: '55e4a3bd6be6b45210833fae',
407
+ * type: 'Docs',
408
+ * docIds: ['55e4a3bd6be6b45210833fae'],
409
+ * footer: 'Documento - {page} de {pages}'
410
+ * };
411
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
412
+ * const result = await api.user.process.downloadDocs(params, session);
413
+ */
414
+ async downloadDocs(params, session) {
415
+ const self = this;
416
+
417
+ try {
418
+ Joi.assert(params, Joi.object().required(), 'Params to download the process documents');
419
+ Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
420
+ Joi.assert(params.type, Joi.string().required(), 'Document Type');
421
+ Joi.assert(params.docIds, Joi.array().required(), 'Document Ids');
422
+ Joi.assert(params.footer, Joi.string(), 'Documents Footer');
423
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
424
+
425
+ const {orgId, type, docIds, footer} = params;
426
+ const data = {
427
+ docIds
428
+ };
429
+
430
+ if (footer) {
431
+ data.footer = footer
432
+ }
433
+
434
+ const apiCall = self._client
435
+ .post(`/organizations/${orgId}/documents/download/${type}`, data, self._setHeader(session));
436
+
437
+ return self._returnData(await apiCall);
438
+ } catch (ex) {
439
+ throw ex;
440
+ }
441
+ }
348
442
  }
349
443
 
350
444
  export default Process;
package/dist/bundle.cjs CHANGED
@@ -1846,6 +1846,100 @@ class Process {
1846
1846
  throw ex;
1847
1847
  }
1848
1848
  }
1849
+
1850
+ /**
1851
+ * @author CloudBrasil <abernardo.br@gmail.com>
1852
+ * @description Method to get Process Docs
1853
+ * @param {object} params Params to get process docs
1854
+ * @param {string} params.orgProcessId Organization Process Id
1855
+ * @param {string} params.processId Process Id
1856
+ * @param {string} params.orgId Organization id (_id database)
1857
+ * @param {string} session Session, token JWT
1858
+ * @returns {promise} returned data from the get process docs
1859
+ * @returns {array<object>} Docs returned from process
1860
+ * @public
1861
+ * @example
1862
+ *
1863
+ * const API = require('@docbrasil/api-systemmanager');
1864
+ * const api = new API();
1865
+ * const params = {
1866
+ * orgProcessId: '55e4a3bd6be6b45210833fae',
1867
+ * processId: '55e4a3bd6be6b45210833fae',
1868
+ * orgId: '55e4a3bd6be6b45210833fae',
1869
+ * };
1870
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1871
+ * const retSearch = await api.user.process.processDocs(params, session);
1872
+ */
1873
+ async processDocs(params, session) {
1874
+ const self = this;
1875
+
1876
+ try {
1877
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get process docs');
1878
+ Joi__default["default"].assert(params.orgProcessId, Joi__default["default"].string().required(), 'Organization Process Id');
1879
+ Joi__default["default"].assert(params.processId, Joi__default["default"].string().required(), 'Process Id');
1880
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1881
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1882
+
1883
+ const {orgProcessId, processId, orgId} = params;
1884
+ const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/process/${processId}/documents`, self._setHeader(session));
1885
+ return self._returnData(await apiCall);
1886
+ } catch (ex) {
1887
+ throw ex;
1888
+ }
1889
+ }
1890
+
1891
+ /**
1892
+ * @author CloudBrasil <abernardo.br@gmail.com>
1893
+ * @description Method to download the process documents
1894
+ * @param {object} params Params to download the process documents
1895
+ * @param {string} params.orgId Organization id (_id database)
1896
+ * @param {string} params.type Document Type
1897
+ * @param {array} params.docIds Documents Ids
1898
+ * @param {string} params.footer Documents Footer
1899
+ * @param {string} session Session, token JWT
1900
+ * @returns {promise} returned data from the search
1901
+ * @public
1902
+ * @example
1903
+ *
1904
+ * const API = require('@docbrasil/api-systemmanager');
1905
+ * const api = new API();
1906
+ * const params = {
1907
+ * orgId: '55e4a3bd6be6b45210833fae',
1908
+ * type: 'Docs',
1909
+ * docIds: ['55e4a3bd6be6b45210833fae'],
1910
+ * footer: 'Documento - {page} de {pages}'
1911
+ * };
1912
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
1913
+ * const result = await api.user.process.downloadDocs(params, session);
1914
+ */
1915
+ async downloadDocs(params, session) {
1916
+ const self = this;
1917
+
1918
+ try {
1919
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to download the process documents');
1920
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
1921
+ Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), 'Document Type');
1922
+ Joi__default["default"].assert(params.docIds, Joi__default["default"].array().required(), 'Document Ids');
1923
+ Joi__default["default"].assert(params.footer, Joi__default["default"].string(), 'Documents Footer');
1924
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
1925
+
1926
+ const {orgId, type, docIds, footer} = params;
1927
+ const data = {
1928
+ docIds
1929
+ };
1930
+
1931
+ if (footer) {
1932
+ data.footer = footer;
1933
+ }
1934
+
1935
+ const apiCall = self._client
1936
+ .post(`/organizations/${orgId}/documents/download/${type}`, data, self._setHeader(session));
1937
+
1938
+ return self._returnData(await apiCall);
1939
+ } catch (ex) {
1940
+ throw ex;
1941
+ }
1942
+ }
1849
1943
  }
1850
1944
 
1851
1945
  /**