@docbrasil/api-systemmanager 1.1.6 → 1.1.7
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/dist/bundle.cjs +65 -1
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +47 -0
- package/docs/Documents.html +469 -8
- package/docs/user_document.js.html +65 -1
- package/package.json +1 -1
package/dist/bundle.cjs
CHANGED
|
@@ -777,6 +777,71 @@ class Documents {
|
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
|
|
780
|
+
/**
|
|
781
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
782
|
+
* @description Updates a document
|
|
783
|
+
* @param {string} id Document _id
|
|
784
|
+
* @param {object} params Object for document payload to update. It has to be the FULL document data, that you can get with findById
|
|
785
|
+
* @param {string} session Session, token JWT
|
|
786
|
+
* @return {Promise}
|
|
787
|
+
* @public
|
|
788
|
+
* @async
|
|
789
|
+
* @example
|
|
790
|
+
*
|
|
791
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
792
|
+
* const api = new API();
|
|
793
|
+
* const params = { ... };
|
|
794
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
795
|
+
* await api.user.document.findByIdAndUpdate('5edf9f8ee896b817e45b8dad', params, session);
|
|
796
|
+
*/
|
|
797
|
+
async findByIdAndUpdate(id, params, session) {
|
|
798
|
+
const self = this;
|
|
799
|
+
try {
|
|
800
|
+
Joi__default["default"].assert(params._id, Joi__default["default"].string().required().error(new Error('_id is required')));
|
|
801
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
802
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required().error(new Error('session is required')));
|
|
803
|
+
const {areaId, orgId} = params;
|
|
804
|
+
const apiCall = self._client
|
|
805
|
+
.put(`/organizations/${orgId}/areas/${areaId}/documents/${id}`, params, self._setHeader(session));
|
|
806
|
+
|
|
807
|
+
return self._returnData(await apiCall);
|
|
808
|
+
} catch (ex) {
|
|
809
|
+
throw ex;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
815
|
+
* @description Updates a document.
|
|
816
|
+
* IMPORTANT: if your document has a content, it will NOT bring the content.
|
|
817
|
+
* @param {string} id Document _id
|
|
818
|
+
* @param {string} session Session, token JWT
|
|
819
|
+
* @return {Promise}
|
|
820
|
+
* @public
|
|
821
|
+
* @async
|
|
822
|
+
* @example
|
|
823
|
+
*
|
|
824
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
825
|
+
* const api = new API();
|
|
826
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
827
|
+
* await api.user.document.findById('5edf9f8ee896b817e45b8dad', session);
|
|
828
|
+
*/
|
|
829
|
+
async findById(id, session) {
|
|
830
|
+
const self = this;
|
|
831
|
+
try {
|
|
832
|
+
Joi__default["default"].assert(params._id, Joi__default["default"].string().required().error(new Error('_id is required')));
|
|
833
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
834
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required().error(new Error('session is required')));
|
|
835
|
+
const {areaId, orgId} = params;
|
|
836
|
+
const apiCall = self._client
|
|
837
|
+
.get(`/organizations/${orgId}/documents/${id}/data/DOC`, params, self._setHeader(session));
|
|
838
|
+
|
|
839
|
+
return self._returnData(await apiCall);
|
|
840
|
+
} catch (ex) {
|
|
841
|
+
throw ex;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
780
845
|
/**
|
|
781
846
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
782
847
|
* @param {object} params Object with params
|
|
@@ -1274,7 +1339,6 @@ class Documents {
|
|
|
1274
1339
|
throw ex;
|
|
1275
1340
|
}
|
|
1276
1341
|
}
|
|
1277
|
-
|
|
1278
1342
|
}
|
|
1279
1343
|
|
|
1280
1344
|
/**
|