@docbrasil/api-systemmanager 1.1.66 → 1.1.67

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.
@@ -275,7 +275,10 @@ class Documents {
275
275
  * @author Myndware <augusto.pissarra@myndware.com>
276
276
  * @description Updates a document
277
277
  * @param {array<string>} ids array of document _id
278
- * @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
278
+ * @param {object} params Object for document payload to update. It has the orgId and areaId (required) and the fields to update.
279
+ * Partial updates accepted, such as docTypeFieldsData.extraFieldName
280
+ * @param {string} params.orgId The orgId of the organization
281
+ * @param {string} params.areaId The areaId to update in batch
279
282
  * @param {string} session Session, token JWT
280
283
  * @return {Promise}
281
284
  * @public
@@ -284,7 +287,7 @@ class Documents {
284
287
  *
285
288
  * const API = require('@docbrasil/api-systemmanager');
286
289
  * const api = new API();
287
- * const params = { ... };
290
+ * const params = { orgId: '5edf9f8ee896b817e45b8da7', areaId: '5edf9f8ee896b817e45b8da8', 'docTypeFieldsData.extraName': 'New name' };
288
291
  * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
289
292
  * await api.user.document.findByIdsAndUpdate(['5edf9f8ee896b817e45b8dad'], params, session);
290
293
  */
@@ -293,11 +296,14 @@ class Documents {
293
296
  try {
294
297
  Joi.assert(ids, Joi.array().required().error(new Error('ids is required')));
295
298
  Joi.assert(params, Joi.object().required().error(new Error('params is required')));
299
+ Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
300
+ Joi.assert(params.areaId, Joi.string().required().error(new Error('areaId is required')));
296
301
  Joi.assert(session, Joi.string().required().error(new Error('session is required')));
297
302
  const { areaId, orgId } = params;
298
- params.ids = ids;
303
+ delete params.areaId;
304
+ delete params.orgId;
299
305
  const apiCall = self._client
300
- .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, params, self._setHeader(session));
306
+ .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, { ids, data: params }, self._setHeader(session));
301
307
 
302
308
  return self._returnData(await apiCall);
303
309
  } catch (ex) {
package/dist/bundle.cjs CHANGED
@@ -929,7 +929,10 @@ class Documents {
929
929
  * @author Myndware <augusto.pissarra@myndware.com>
930
930
  * @description Updates a document
931
931
  * @param {array<string>} ids array of document _id
932
- * @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
932
+ * @param {object} params Object for document payload to update. It has the orgId and areaId (required) and the fields to update.
933
+ * Partial updates accepted, such as docTypeFieldsData.extraFieldName
934
+ * @param {string} params.orgId The orgId of the organization
935
+ * @param {string} params.areaId The areaId to update in batch
933
936
  * @param {string} session Session, token JWT
934
937
  * @return {Promise}
935
938
  * @public
@@ -938,7 +941,7 @@ class Documents {
938
941
  *
939
942
  * const API = require('@docbrasil/api-systemmanager');
940
943
  * const api = new API();
941
- * const params = { ... };
944
+ * const params = { orgId: '5edf9f8ee896b817e45b8da7', areaId: '5edf9f8ee896b817e45b8da8', 'docTypeFieldsData.extraName': 'New name' };
942
945
  * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
943
946
  * await api.user.document.findByIdsAndUpdate(['5edf9f8ee896b817e45b8dad'], params, session);
944
947
  */
@@ -947,11 +950,14 @@ class Documents {
947
950
  try {
948
951
  Joi__default["default"].assert(ids, Joi__default["default"].array().required().error(new Error('ids is required')));
949
952
  Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
953
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required().error(new Error('orgId is required')));
954
+ Joi__default["default"].assert(params.areaId, Joi__default["default"].string().required().error(new Error('areaId is required')));
950
955
  Joi__default["default"].assert(session, Joi__default["default"].string().required().error(new Error('session is required')));
951
956
  const { areaId, orgId } = params;
952
- params.ids = ids;
957
+ delete params.areaId;
958
+ delete params.orgId;
953
959
  const apiCall = self._client
954
- .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, params, self._setHeader(session));
960
+ .put(`/organizations/${orgId}/areas/${areaId}/documents/batch`, { ids, data: params }, self._setHeader(session));
955
961
 
956
962
  return self._returnData(await apiCall);
957
963
  } catch (ex) {