@docbrasil/api-systemmanager 1.1.69 → 1.1.70

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.
@@ -238,6 +238,81 @@ class Documents {
238
238
  }
239
239
  }
240
240
 
241
+ /**
242
+ * @author Myndware <augusto.pissarra@myndware.com>
243
+ * @description Add multiple documents to a doc area under a doc type
244
+ * @param {object} params Object for adding documents
245
+ * @param {string} params.orgId Organization id (_id database)
246
+ * @param {string} params.userId User id (_id database)
247
+ * @param {string} params.docAreaName The name of the doc area
248
+ * @param {string} params.docTypeName The name of the doc type
249
+ * @param {array<object>} params.docs Array of documents to add
250
+ * @param {string} [params.docs.document=''] The url to the document on S3, an external URL or a base64 representation of the document
251
+ * @param {string} [params.docs.type=''] The mime type of the document
252
+ * @param {string} [params.docs.name=''] The name of the document
253
+ * @param {string} [params.docs.content=''] The content of the document
254
+ * @param {number} [params.docs.bytes=0] The bytes (in kb) of the document
255
+ * @param {string} [params.docs.urlType=''] The urlType of the document
256
+ * @param {string} [params.docs.description=''] The description of the document
257
+ * @param {string} [params.docs.category=''] The category of the document
258
+ * @param {array<string>} [params.docs.tags=[]] The tags of the document
259
+ * @param {object} [params.docs.docTypeFieldsData={}] The data related to this document
260
+ * @param {boolean} [params.docs.hasPhisicalStorage=false] The flag to define if the document has physical storage or not
261
+ * @param {string} [params.docs.boxId=''] The boxId if we define the document has physical storage
262
+ * @param {number} [params.docs.status] The document status
263
+ * @param {string} [params.docs.storageStatus=''] The storageStatus if we define the document has physical storage
264
+ * @param {string} session Session, token JWT
265
+ * @return {Promise<object>} The result of the operation
266
+ * @return {boolean} return.success True if the operation was successful
267
+ * @return {array<object>} return.added Array of added documents
268
+ * @return {array<object>} return.notAdded Array of documents that could not be added
269
+ * @public
270
+ * @async
271
+ * @example
272
+ *
273
+ * const API = require('@docbrasil/api-systemmanager');
274
+ * const api = new API();
275
+ * const params = {
276
+ * orgId: '5df7f19618430c89a41a19d2',
277
+ * userId: '5df7f19618430c89a41a19d3',
278
+ * docAreaName: 'My Doc Area',
279
+ * docTypeName: 'My Doc Type',
280
+ * docs: [
281
+ * {
282
+ * document: 'https://s3.amazonaws.com/...',
283
+ * type: 'application/pdf',
284
+ * name: 'Document 1',
285
+ * description: 'First document',
286
+ * category: 'Category 1',
287
+ * tags: ['tag1', 'tag2'],
288
+ * docTypeFieldsData: { extraField: 'value' },
289
+ * bytes: 12345
290
+ * }
291
+ * ]
292
+ * };
293
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
294
+ * const result = await api.user.document.addDocuments(params, session);
295
+ */
296
+ async addDocuments(params, session) {
297
+ const self = this;
298
+ try {
299
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
300
+ Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
301
+ Joi.assert(params.userId, Joi.string().required().error(new Error('userId is required')));
302
+ Joi.assert(params.docAreaName, Joi.string().required().error(new Error('docAreaName is required')));
303
+ Joi.assert(params.docTypeName, Joi.string().required().error(new Error('docTypeName is required')));
304
+ Joi.assert(params.docs, Joi.array().required().error(new Error('docs is required')));
305
+ Joi.assert(session, Joi.string().required().error(new Error('session is required')));
306
+
307
+ const apiCall = self._client
308
+ .put('/organizations/documents', params, self._setHeader(session));
309
+
310
+ return self._returnData(await apiCall);
311
+ } catch (ex) {
312
+ throw ex;
313
+ }
314
+ }
315
+
241
316
  /**
242
317
  * @author Myndware <augusto.pissarra@myndware.com>
243
318
  * @description Updates a document
package/dist/bundle.cjs CHANGED
@@ -892,6 +892,81 @@ class Documents {
892
892
  }
893
893
  }
894
894
 
895
+ /**
896
+ * @author Myndware <augusto.pissarra@myndware.com>
897
+ * @description Add multiple documents to a doc area under a doc type
898
+ * @param {object} params Object for adding documents
899
+ * @param {string} params.orgId Organization id (_id database)
900
+ * @param {string} params.userId User id (_id database)
901
+ * @param {string} params.docAreaName The name of the doc area
902
+ * @param {string} params.docTypeName The name of the doc type
903
+ * @param {array<object>} params.docs Array of documents to add
904
+ * @param {string} [params.docs.document=''] The url to the document on S3, an external URL or a base64 representation of the document
905
+ * @param {string} [params.docs.type=''] The mime type of the document
906
+ * @param {string} [params.docs.name=''] The name of the document
907
+ * @param {string} [params.docs.content=''] The content of the document
908
+ * @param {number} [params.docs.bytes=0] The bytes (in kb) of the document
909
+ * @param {string} [params.docs.urlType=''] The urlType of the document
910
+ * @param {string} [params.docs.description=''] The description of the document
911
+ * @param {string} [params.docs.category=''] The category of the document
912
+ * @param {array<string>} [params.docs.tags=[]] The tags of the document
913
+ * @param {object} [params.docs.docTypeFieldsData={}] The data related to this document
914
+ * @param {boolean} [params.docs.hasPhisicalStorage=false] The flag to define if the document has physical storage or not
915
+ * @param {string} [params.docs.boxId=''] The boxId if we define the document has physical storage
916
+ * @param {number} [params.docs.status] The document status
917
+ * @param {string} [params.docs.storageStatus=''] The storageStatus if we define the document has physical storage
918
+ * @param {string} session Session, token JWT
919
+ * @return {Promise<object>} The result of the operation
920
+ * @return {boolean} return.success True if the operation was successful
921
+ * @return {array<object>} return.added Array of added documents
922
+ * @return {array<object>} return.notAdded Array of documents that could not be added
923
+ * @public
924
+ * @async
925
+ * @example
926
+ *
927
+ * const API = require('@docbrasil/api-systemmanager');
928
+ * const api = new API();
929
+ * const params = {
930
+ * orgId: '5df7f19618430c89a41a19d2',
931
+ * userId: '5df7f19618430c89a41a19d3',
932
+ * docAreaName: 'My Doc Area',
933
+ * docTypeName: 'My Doc Type',
934
+ * docs: [
935
+ * {
936
+ * document: 'https://s3.amazonaws.com/...',
937
+ * type: 'application/pdf',
938
+ * name: 'Document 1',
939
+ * description: 'First document',
940
+ * category: 'Category 1',
941
+ * tags: ['tag1', 'tag2'],
942
+ * docTypeFieldsData: { extraField: 'value' },
943
+ * bytes: 12345
944
+ * }
945
+ * ]
946
+ * };
947
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
948
+ * const result = await api.user.document.addDocuments(params, session);
949
+ */
950
+ async addDocuments(params, session) {
951
+ const self = this;
952
+ try {
953
+ Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
954
+ Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required().error(new Error('orgId is required')));
955
+ Joi__default["default"].assert(params.userId, Joi__default["default"].string().required().error(new Error('userId is required')));
956
+ Joi__default["default"].assert(params.docAreaName, Joi__default["default"].string().required().error(new Error('docAreaName is required')));
957
+ Joi__default["default"].assert(params.docTypeName, Joi__default["default"].string().required().error(new Error('docTypeName is required')));
958
+ Joi__default["default"].assert(params.docs, Joi__default["default"].array().required().error(new Error('docs is required')));
959
+ Joi__default["default"].assert(session, Joi__default["default"].string().required().error(new Error('session is required')));
960
+
961
+ const apiCall = self._client
962
+ .put('/organizations/documents', params, self._setHeader(session));
963
+
964
+ return self._returnData(await apiCall);
965
+ } catch (ex) {
966
+ throw ex;
967
+ }
968
+ }
969
+
895
970
  /**
896
971
  * @author Myndware <augusto.pissarra@myndware.com>
897
972
  * @description Updates a document