@docbrasil/api-systemmanager 1.0.98 → 1.0.100

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.
package/api/external.js CHANGED
@@ -52,7 +52,12 @@ class External {
52
52
  * @description Create new document
53
53
  * @param {object} params Object for add new document
54
54
  * @param {string} params.id Organization form id
55
- * @return {Promise<object>}
55
+ * @return {Promise<object>} data
56
+ * @return {string} _id the id of the form
57
+ * @return {string} orgId the organization id of the form
58
+ * @return {string} responseToken the unique token registered internally by the system for all the next calls to the external form APIs
59
+ * The responseToken is unique and is ONLY valid for this session.
60
+ * @return {array<object>} groups the form groups to render
56
61
  * @public
57
62
  * @async
58
63
  * @example
@@ -83,4 +88,4 @@ class External {
83
88
 
84
89
  }
85
90
 
86
- export default Documents;
91
+ export default External;
package/dist/bundle.cjs CHANGED
@@ -559,7 +559,7 @@ class Users$1 {
559
559
  * Class for documents, permission user
560
560
  * @class
561
561
  */
562
- class Documents$1 {
562
+ class Documents {
563
563
 
564
564
  constructor(options) {
565
565
  Joi__default["default"].assert(options, Joi__default["default"].object().required());
@@ -9481,7 +9481,7 @@ class Users {
9481
9481
  Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
9482
9482
 
9483
9483
  const self = this;
9484
- self.document = new Documents$1(options);
9484
+ self.document = new Documents(options);
9485
9485
  self.datasource = new Datasource(options);
9486
9486
  self.organization = new Organization$1(options);
9487
9487
  self.process = new Process(options);
@@ -11578,7 +11578,91 @@ class Admin {
11578
11578
  }
11579
11579
  }
11580
11580
 
11581
- var External = Documents;
11581
+ /**
11582
+ * Class for documents, permission user
11583
+ * @class
11584
+ */
11585
+ class External {
11586
+
11587
+ constructor(options) {
11588
+ Joi__default["default"].assert(options, Joi__default["default"].object().required());
11589
+ Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
11590
+
11591
+ const self = this;
11592
+ self.parent = options.parent;
11593
+ self._client = self.parent.dispatch.getClient();
11594
+ }
11595
+
11596
+ /**
11597
+ * @author Augusto Pissarra <abernardo.br@gmail.com>
11598
+ * @description Get the return data and check for errors
11599
+ * @param {object} retData Response HTTP
11600
+ * @return {*}
11601
+ * @private
11602
+ */
11603
+ _returnData(retData, def = {}) {
11604
+ if (retData.status !== 200) {
11605
+ throw Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
11606
+ } else {
11607
+ return ___default["default"].get(retData, 'data', def);
11608
+ }
11609
+ }
11610
+
11611
+ /**
11612
+ * @author CloudBrasil <abernardo.br@gmail.com>
11613
+ * @description Set header with new session
11614
+ * @param {string} session Session, token JWT
11615
+ * @return {object} header with new session
11616
+ * @private
11617
+ */
11618
+ _setHeader(session) {
11619
+ return {
11620
+ headers: {
11621
+ authorization: session,
11622
+ }
11623
+ };
11624
+ }
11625
+
11626
+ /**
11627
+ * @author CloudBrasil <abernardo.br@gmail.com>
11628
+ * @description Create new document
11629
+ * @param {object} params Object for add new document
11630
+ * @param {string} params.id Organization form id
11631
+ * @return {Promise<object>} data
11632
+ * @return {string} _id the id of the form
11633
+ * @return {string} orgId the organization id of the form
11634
+ * @return {string} responseToken the unique token registered internally by the system for all the next calls to the external form APIs
11635
+ * The responseToken is unique and is ONLY valid for this session.
11636
+ * @return {array<object>} groups the form groups to render
11637
+ * @public
11638
+ * @async
11639
+ * @example
11640
+ *
11641
+ * const API = require('@docbrasil/api-systemmanager');
11642
+ * const api = new API();
11643
+ * const params = {
11644
+ * id: 'cloundbrasil'
11645
+ * };
11646
+ * const retForm = await api.external.context(params);
11647
+ */
11648
+ async context(params) {
11649
+ const self = this;
11650
+
11651
+ try {
11652
+ Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
11653
+ Joi__default["default"].assert(params.id, Joi__default["default"].string().required().error(new Error('organization form id is required')));
11654
+
11655
+ const { id } = params;
11656
+ const apiCall = self._client
11657
+ .get(`/component/external/forms/${id}`);
11658
+
11659
+ return self._returnData(await apiCall);
11660
+ } catch (ex) {
11661
+ throw ex;
11662
+ }
11663
+ }
11664
+
11665
+ }
11582
11666
 
11583
11667
  /**
11584
11668
  * Class API