@docbrasil/api-systemmanager 1.1.28 → 1.1.30

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,7 +238,7 @@ class Notification {
238
238
 
239
239
  /**
240
240
  * @author Myndware <augusto.pissarra@myndware.com>
241
- * @description Set notification as readed
241
+ * @description Set notification as read
242
242
  * @param {object} params Params to update the notification
243
243
  * @param {string} params.id Notification Id
244
244
  * @param {string} session JWT Token
@@ -257,14 +257,14 @@ class Notification {
257
257
  */
258
258
  async setRead(params = {}, session) {
259
259
  const self = this;
260
-
260
+
261
261
  try {
262
262
  Joi.assert(params, Joi.object().required());
263
263
  Joi.assert(params.id, Joi.string().required());
264
264
  Joi.assert(session, Joi.string().required());
265
-
265
+
266
266
  const {id} = params;
267
-
267
+
268
268
  const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
269
269
  return self._returnData(await apiCall);
270
270
  } catch (ex) {
@@ -272,6 +272,37 @@ class Notification {
272
272
  }
273
273
  }
274
274
 
275
+ /**
276
+ * @author Myndware <augusto.pissarra@myndware.com>
277
+ * @description Set all notification of the logged user as read
278
+ * @param {string} session JWT Token
279
+ * @return {Promise}
280
+ * @public
281
+ * @async
282
+ * @example
283
+ *
284
+ * const API = require('@docbrasil/api-systemmanager');
285
+ * const api = new API();
286
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
287
+ * await api.user.notification.setReadAll(session);
288
+ */
289
+ async setReadAll(session) {
290
+ const self = this;
291
+
292
+ try {
293
+ Joi.assert(params, Joi.object().required());
294
+ Joi.assert(params.id, Joi.string().required());
295
+ Joi.assert(session, Joi.string().required());
296
+
297
+ const {id} = params;
298
+
299
+ const apiCall = self._client.put(`/organizations/notifications/read/all`, {}, self._setHeader(session));
300
+ return self._returnData(await apiCall);
301
+ } catch (ex) {
302
+ throw ex;
303
+ }
304
+ }
305
+
275
306
  /**
276
307
  * @author Myndware <augusto.pissarra@myndware.com>
277
308
  * @description Set notification as unreaded
@@ -293,14 +324,14 @@ class Notification {
293
324
  */
294
325
  async setUnread(params = {}, session) {
295
326
  const self = this;
296
-
327
+
297
328
  try {
298
329
  Joi.assert(params, Joi.object().required());
299
330
  Joi.assert(params.id, Joi.string().required());
300
331
  Joi.assert(session, Joi.string().required());
301
-
332
+
302
333
  const {id} = params;
303
-
334
+
304
335
  const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
305
336
  return self._returnData(await apiCall);
306
337
  } catch (ex) {
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.28",
4
+ "version": "1.1.30",
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",