@docbrasil/api-systemmanager 1.0.105 → 1.0.106

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
@@ -124,6 +124,52 @@ class External {
124
124
  }
125
125
  }
126
126
 
127
+ /**
128
+ * @author CloudBrasil <abernardo.br@gmail.com>
129
+ * @description Handles the execution of an external form
130
+ * @param {string} authorization a legal authorization
131
+ * @param {object} params the parameters to handle the execution of an external form
132
+ * @param {array<object>} params.payload the payload of the external form. It should represent the form groups of the external form
133
+ * @param {string} params.payload.name the name of the group
134
+ * @param {array<object>} params.payload.fields the fields that belong to each group
135
+ * @param {*|{}} params.payload.fields.value besides all the data inside a field, it should have the value of the the field
136
+ * @returns {Promise<boolean>} true|false if success
137
+ * @public
138
+ * @async
139
+ * @example
140
+ *
141
+ * const API = require('@docbrasil/api-systemmanager');
142
+ * const api = new API();
143
+ * const authorization = '...';
144
+ * const params = {
145
+ * payload: [
146
+ * {
147
+ * name: 'My Group One',
148
+ * fields: [
149
+ * {}
150
+ * ]
151
+ * }
152
+ * ]
153
+ * };
154
+ * const success = await api.external.handle(params, authorization);
155
+ */
156
+ async handle(params, authorization) {
157
+ const self = this;
158
+
159
+ try {
160
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
161
+ Joi.assert(params.payload, Joi.array().required().error(new Error('form payload is required')));
162
+ Joi.assert(authorization, Joi.string().required().error(new Error('authorization is required')));
163
+
164
+ const apiCall = self._client
165
+ .put('/external/forms', params, self._setHeader(authorization));
166
+
167
+ return self._returnData(await apiCall);
168
+ } catch (ex) {
169
+ throw ex;
170
+ }
171
+ }
172
+
127
173
  }
128
174
 
129
175
  export default External;
package/dist/bundle.cjs CHANGED
@@ -11700,6 +11700,52 @@ class External {
11700
11700
  }
11701
11701
  }
11702
11702
 
11703
+ /**
11704
+ * @author CloudBrasil <abernardo.br@gmail.com>
11705
+ * @description Handles the execution of an external form
11706
+ * @param {string} authorization a legal authorization
11707
+ * @param {object} params the parameters to handle the execution of an external form
11708
+ * @param {array<object>} params.payload the payload of the external form. It should represent the form groups of the external form
11709
+ * @param {string} params.payload.name the name of the group
11710
+ * @param {array<object>} params.payload.fields the fields that belong to each group
11711
+ * @param {*|{}} params.payload.fields.value besides all the data inside a field, it should have the value of the the field
11712
+ * @returns {Promise<boolean>} true|false if success
11713
+ * @public
11714
+ * @async
11715
+ * @example
11716
+ *
11717
+ * const API = require('@docbrasil/api-systemmanager');
11718
+ * const api = new API();
11719
+ * const authorization = '...';
11720
+ * const params = {
11721
+ * payload: [
11722
+ * {
11723
+ * name: 'My Group One',
11724
+ * fields: [
11725
+ * {}
11726
+ * ]
11727
+ * }
11728
+ * ]
11729
+ * };
11730
+ * const success = await api.external.handle(params, authorization);
11731
+ */
11732
+ async handle(params, authorization) {
11733
+ const self = this;
11734
+
11735
+ try {
11736
+ Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
11737
+ Joi__default["default"].assert(params.payload, Joi__default["default"].array().required().error(new Error('form payload is required')));
11738
+ Joi__default["default"].assert(authorization, Joi__default["default"].string().required().error(new Error('authorization is required')));
11739
+
11740
+ const apiCall = self._client
11741
+ .put('/external/forms', params, self._setHeader(authorization));
11742
+
11743
+ return self._returnData(await apiCall);
11744
+ } catch (ex) {
11745
+ throw ex;
11746
+ }
11747
+ }
11748
+
11703
11749
  }
11704
11750
 
11705
11751
  /**