@docbrasil/api-systemmanager 1.0.113 → 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.
@@ -386,6 +386,59 @@ class Process {
386
386
  throw ex;
387
387
  }
388
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
+ }
389
442
  }
390
443
 
391
444
  export default Process;
package/dist/bundle.cjs CHANGED
@@ -1887,6 +1887,59 @@ class Process {
1887
1887
  throw ex;
1888
1888
  }
1889
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
+ }
1890
1943
  }
1891
1944
 
1892
1945
  /**