@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.
@@ -325,6 +325,81 @@ class Documents {
325
325
  }
326
326
  }
327
327
 
328
+ /**
329
+ * @author Myndware <augusto.pissarra@myndware.com>
330
+ * @description Add multiple documents to a doc area under a doc type
331
+ * @param {object} params Object for adding documents
332
+ * @param {string} params.orgId Organization id (_id database)
333
+ * @param {string} params.userId User id (_id database)
334
+ * @param {string} params.docAreaName The name of the doc area
335
+ * @param {string} params.docTypeName The name of the doc type
336
+ * @param {array<object>} params.docs Array of documents to add
337
+ * @param {string} [params.docs.document=''] The url to the document on S3, an external URL or a base64 representation of the document
338
+ * @param {string} [params.docs.type=''] The mime type of the document
339
+ * @param {string} [params.docs.name=''] The name of the document
340
+ * @param {string} [params.docs.content=''] The content of the document
341
+ * @param {number} [params.docs.bytes=0] The bytes (in kb) of the document
342
+ * @param {string} [params.docs.urlType=''] The urlType of the document
343
+ * @param {string} [params.docs.description=''] The description of the document
344
+ * @param {string} [params.docs.category=''] The category of the document
345
+ * @param {array<string>} [params.docs.tags=[]] The tags of the document
346
+ * @param {object} [params.docs.docTypeFieldsData={}] The data related to this document
347
+ * @param {boolean} [params.docs.hasPhisicalStorage=false] The flag to define if the document has physical storage or not
348
+ * @param {string} [params.docs.boxId=''] The boxId if we define the document has physical storage
349
+ * @param {number} [params.docs.status] The document status
350
+ * @param {string} [params.docs.storageStatus=''] The storageStatus if we define the document has physical storage
351
+ * @param {string} session Session, token JWT
352
+ * @return {Promise<object>} The result of the operation
353
+ * @return {boolean} return.success True if the operation was successful
354
+ * @return {array<object>} return.added Array of added documents
355
+ * @return {array<object>} return.notAdded Array of documents that could not be added
356
+ * @public
357
+ * @async
358
+ * @example
359
+ *
360
+ * const API = require('@docbrasil/api-systemmanager');
361
+ * const api = new API();
362
+ * const params = {
363
+ * orgId: '5df7f19618430c89a41a19d2',
364
+ * userId: '5df7f19618430c89a41a19d3',
365
+ * docAreaName: 'My Doc Area',
366
+ * docTypeName: 'My Doc Type',
367
+ * docs: [
368
+ * {
369
+ * document: 'https://s3.amazonaws.com/...',
370
+ * type: 'application/pdf',
371
+ * name: 'Document 1',
372
+ * description: 'First document',
373
+ * category: 'Category 1',
374
+ * tags: ['tag1', 'tag2'],
375
+ * docTypeFieldsData: { extraField: 'value' },
376
+ * bytes: 12345
377
+ * }
378
+ * ]
379
+ * };
380
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
381
+ * const result = await api.user.document.addDocuments(params, session);
382
+ */
383
+ async addDocuments(params, session) {
384
+ const self = this;
385
+ try {
386
+ Joi.assert(params, Joi.object().required().error(new Error('params is required')));
387
+ Joi.assert(params.orgId, Joi.string().required().error(new Error('orgId is required')));
388
+ Joi.assert(params.userId, Joi.string().required().error(new Error('userId is required')));
389
+ Joi.assert(params.docAreaName, Joi.string().required().error(new Error('docAreaName is required')));
390
+ Joi.assert(params.docTypeName, Joi.string().required().error(new Error('docTypeName is required')));
391
+ Joi.assert(params.docs, Joi.array().required().error(new Error('docs is required')));
392
+ Joi.assert(session, Joi.string().required().error(new Error('session is required')));
393
+
394
+ const apiCall = self._client
395
+ .put('/organizations/documents', params, self._setHeader(session));
396
+
397
+ return self._returnData(await apiCall);
398
+ } catch (ex) {
399
+ throw ex;
400
+ }
401
+ }
402
+
328
403
  /**
329
404
  * @author Myndware <augusto.pissarra@myndware.com>
330
405
  * @description Updates a document
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docbrasil/api-systemmanager",
3
3
  "description": "Module API System Manager",
4
- "version": "1.1.69",
4
+ "version": "1.1.70",
5
5
  "scripts": {
6
6
  "htmldoc": "rm -rf docs && jsdoc api/** -d docs -t ./node_modules/better-docs",
7
7
  "doc": "rm -rf doc && mkdir doc && jsdoc2md api/**/* api/* > doc/api.md",