@docbrasil/api-systemmanager 1.1.29 → 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.
@@ -84,6 +84,42 @@ class Application {
84
84
  throw ex;
85
85
  }
86
86
  }
87
+
88
+ /**
89
+ * @author Myndware <augusto.pissarra@myndware.com>
90
+ * @description Changes the application for a user in an organization
91
+ * @param {object} params Params to get task
92
+ * @param {object} params.applicationId The application id to change to
93
+ * @param {string} session Session, token JWT
94
+ * @returns {promise}
95
+ * @public
96
+ * @example
97
+ *
98
+ * const API = require('@docbrasil/api-systemmanager');
99
+ * const api = new API();
100
+ * const params = {
101
+ * applicationId: '55e4a3bd6be6b45210833fae',
102
+ * };
103
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
104
+ * await api.user.application.changeApplication(params, session);
105
+ */
106
+ async changeApplication(params, session) {
107
+ const self = this;
108
+
109
+ try {
110
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
111
+ Joi.assert(params.applicationId, Joi.string().required(), 'The application id');
112
+ Joi.assert(session, Joi.string().required(), 'Session token JWT');
113
+
114
+ const { orgId} = params;
115
+ const apiCall = self._client
116
+ .put('/organizations/applications/change', { applicationId: params.applicationId }, self._setHeader(session));
117
+
118
+ return self._returnData(await apiCall);
119
+ } catch (ex) {
120
+ throw ex;
121
+ }
122
+ }
87
123
  }
88
124
 
89
125
  export default Application;
@@ -151,7 +151,7 @@ class Notification {
151
151
 
152
152
  /**
153
153
  * @author Myndware <augusto.pissarra@myndware.com>
154
- * @description Set notification as readed
154
+ * @description Set notification as read
155
155
  * @param {object} params Params to update the notification
156
156
  * @param {string} params.id Notification Id
157
157
  * @param {string} session JWT Token
@@ -170,14 +170,14 @@ class Notification {
170
170
  */
171
171
  async setRead(params = {}, session) {
172
172
  const self = this;
173
-
173
+
174
174
  try {
175
175
  Joi.assert(params, Joi.object().required());
176
176
  Joi.assert(params.id, Joi.string().required());
177
177
  Joi.assert(session, Joi.string().required());
178
-
178
+
179
179
  const {id} = params;
180
-
180
+
181
181
  const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
182
182
  return self._returnData(await apiCall);
183
183
  } catch (ex) {
@@ -185,6 +185,37 @@ class Notification {
185
185
  }
186
186
  }
187
187
 
188
+ /**
189
+ * @author Myndware <augusto.pissarra@myndware.com>
190
+ * @description Set all notification of the logged user as read
191
+ * @param {string} session JWT Token
192
+ * @return {Promise}
193
+ * @public
194
+ * @async
195
+ * @example
196
+ *
197
+ * const API = require('@docbrasil/api-systemmanager');
198
+ * const api = new API();
199
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
200
+ * await api.user.notification.setReadAll(session);
201
+ */
202
+ async setReadAll(session) {
203
+ const self = this;
204
+
205
+ try {
206
+ Joi.assert(params, Joi.object().required());
207
+ Joi.assert(params.id, Joi.string().required());
208
+ Joi.assert(session, Joi.string().required());
209
+
210
+ const {id} = params;
211
+
212
+ const apiCall = self._client.put(`/organizations/notifications/read/all`, {}, self._setHeader(session));
213
+ return self._returnData(await apiCall);
214
+ } catch (ex) {
215
+ throw ex;
216
+ }
217
+ }
218
+
188
219
  /**
189
220
  * @author Myndware <augusto.pissarra@myndware.com>
190
221
  * @description Set notification as unreaded
@@ -206,14 +237,14 @@ class Notification {
206
237
  */
207
238
  async setUnread(params = {}, session) {
208
239
  const self = this;
209
-
240
+
210
241
  try {
211
242
  Joi.assert(params, Joi.object().required());
212
243
  Joi.assert(params.id, Joi.string().required());
213
244
  Joi.assert(session, Joi.string().required());
214
-
245
+
215
246
  const {id} = params;
216
-
247
+
217
248
  const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
218
249
  return self._returnData(await apiCall);
219
250
  } catch (ex) {
package/dist/bundle.cjs CHANGED
@@ -10473,7 +10473,7 @@ class Notification {
10473
10473
 
10474
10474
  /**
10475
10475
  * @author Myndware <augusto.pissarra@myndware.com>
10476
- * @description Set notification as readed
10476
+ * @description Set notification as read
10477
10477
  * @param {object} params Params to update the notification
10478
10478
  * @param {string} params.id Notification Id
10479
10479
  * @param {string} session JWT Token
@@ -10492,14 +10492,14 @@ class Notification {
10492
10492
  */
10493
10493
  async setRead(params = {}, session) {
10494
10494
  const self = this;
10495
-
10495
+
10496
10496
  try {
10497
10497
  Joi__default["default"].assert(params, Joi__default["default"].object().required());
10498
10498
  Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
10499
10499
  Joi__default["default"].assert(session, Joi__default["default"].string().required());
10500
-
10500
+
10501
10501
  const {id} = params;
10502
-
10502
+
10503
10503
  const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
10504
10504
  return self._returnData(await apiCall);
10505
10505
  } catch (ex) {
@@ -10507,6 +10507,37 @@ class Notification {
10507
10507
  }
10508
10508
  }
10509
10509
 
10510
+ /**
10511
+ * @author Myndware <augusto.pissarra@myndware.com>
10512
+ * @description Set all notification of the logged user as read
10513
+ * @param {string} session JWT Token
10514
+ * @return {Promise}
10515
+ * @public
10516
+ * @async
10517
+ * @example
10518
+ *
10519
+ * const API = require('@docbrasil/api-systemmanager');
10520
+ * const api = new API();
10521
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
10522
+ * await api.user.notification.setReadAll(session);
10523
+ */
10524
+ async setReadAll(session) {
10525
+ const self = this;
10526
+
10527
+ try {
10528
+ Joi__default["default"].assert(params, Joi__default["default"].object().required());
10529
+ Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
10530
+ Joi__default["default"].assert(session, Joi__default["default"].string().required());
10531
+
10532
+ const {id} = params;
10533
+
10534
+ const apiCall = self._client.put(`/organizations/notifications/read/all`, {}, self._setHeader(session));
10535
+ return self._returnData(await apiCall);
10536
+ } catch (ex) {
10537
+ throw ex;
10538
+ }
10539
+ }
10540
+
10510
10541
  /**
10511
10542
  * @author Myndware <augusto.pissarra@myndware.com>
10512
10543
  * @description Set notification as unreaded
@@ -10528,14 +10559,14 @@ class Notification {
10528
10559
  */
10529
10560
  async setUnread(params = {}, session) {
10530
10561
  const self = this;
10531
-
10562
+
10532
10563
  try {
10533
10564
  Joi__default["default"].assert(params, Joi__default["default"].object().required());
10534
10565
  Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
10535
10566
  Joi__default["default"].assert(session, Joi__default["default"].string().required());
10536
-
10567
+
10537
10568
  const {id} = params;
10538
-
10569
+
10539
10570
  const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
10540
10571
  return self._returnData(await apiCall);
10541
10572
  } catch (ex) {
@@ -11038,6 +11069,42 @@ class Application {
11038
11069
  throw ex;
11039
11070
  }
11040
11071
  }
11072
+
11073
+ /**
11074
+ * @author Myndware <augusto.pissarra@myndware.com>
11075
+ * @description Changes the application for a user in an organization
11076
+ * @param {object} params Params to get task
11077
+ * @param {object} params.applicationId The application id to change to
11078
+ * @param {string} session Session, token JWT
11079
+ * @returns {promise}
11080
+ * @public
11081
+ * @example
11082
+ *
11083
+ * const API = require('@docbrasil/api-systemmanager');
11084
+ * const api = new API();
11085
+ * const params = {
11086
+ * applicationId: '55e4a3bd6be6b45210833fae',
11087
+ * };
11088
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
11089
+ * await api.user.application.changeApplication(params, session);
11090
+ */
11091
+ async changeApplication(params, session) {
11092
+ const self = this;
11093
+
11094
+ try {
11095
+ Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
11096
+ Joi__default["default"].assert(params.applicationId, Joi__default["default"].string().required(), 'The application id');
11097
+ Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
11098
+
11099
+ const { orgId} = params;
11100
+ const apiCall = self._client
11101
+ .put('/organizations/applications/change', { applicationId: params.applicationId }, self._setHeader(session));
11102
+
11103
+ return self._returnData(await apiCall);
11104
+ } catch (ex) {
11105
+ throw ex;
11106
+ }
11107
+ }
11041
11108
  }
11042
11109
 
11043
11110
  /**