@docbrasil/api-systemmanager 1.0.118 → 1.0.120
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/api/user/updates.js +1 -1
- package/dist/bundle.cjs +74 -3
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
package/api/user/updates.js
CHANGED
package/dist/bundle.cjs
CHANGED
|
@@ -9488,7 +9488,7 @@ class Register {
|
|
|
9488
9488
|
* Class for user registration in a user
|
|
9489
9489
|
* @class
|
|
9490
9490
|
*/
|
|
9491
|
-
class Notification
|
|
9491
|
+
class Notification {
|
|
9492
9492
|
|
|
9493
9493
|
constructor(options) {
|
|
9494
9494
|
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
@@ -9704,7 +9704,78 @@ class Notification$1 {
|
|
|
9704
9704
|
}
|
|
9705
9705
|
}
|
|
9706
9706
|
|
|
9707
|
-
|
|
9707
|
+
/**
|
|
9708
|
+
* Class for user registration in a user
|
|
9709
|
+
* @class
|
|
9710
|
+
*/
|
|
9711
|
+
class Updates {
|
|
9712
|
+
|
|
9713
|
+
constructor(options) {
|
|
9714
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
9715
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
9716
|
+
|
|
9717
|
+
const self = this;
|
|
9718
|
+
self.parent = options.parent;
|
|
9719
|
+
self._client = self.parent.dispatch.getClient();
|
|
9720
|
+
}
|
|
9721
|
+
|
|
9722
|
+
/**
|
|
9723
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9724
|
+
* @description Get the return data and check for errors
|
|
9725
|
+
* @param {object} retData Response HTTP
|
|
9726
|
+
* @return {*}
|
|
9727
|
+
* @private
|
|
9728
|
+
*/
|
|
9729
|
+
_returnData(retData, def = {}) {
|
|
9730
|
+
if (retData.status !== 200) {
|
|
9731
|
+
return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
9732
|
+
} else {
|
|
9733
|
+
return ___default["default"].get(retData, 'data', def);
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
|
|
9737
|
+
/**
|
|
9738
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9739
|
+
* @description Set header with new session
|
|
9740
|
+
* @param {string} session Session, token JWT
|
|
9741
|
+
* @return {object} header with new session
|
|
9742
|
+
* @private
|
|
9743
|
+
*/
|
|
9744
|
+
_setHeader(session) {
|
|
9745
|
+
return {
|
|
9746
|
+
headers: {
|
|
9747
|
+
authorization: session,
|
|
9748
|
+
}
|
|
9749
|
+
};
|
|
9750
|
+
}
|
|
9751
|
+
|
|
9752
|
+
/**
|
|
9753
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9754
|
+
* @description get updates
|
|
9755
|
+
* @param {string} session JWT token
|
|
9756
|
+
* @public
|
|
9757
|
+
* @async
|
|
9758
|
+
* @example
|
|
9759
|
+
*
|
|
9760
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9761
|
+
* const api = new API();
|
|
9762
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9763
|
+
* await api.user.updates.get(session);
|
|
9764
|
+
*/
|
|
9765
|
+
async get(session) {
|
|
9766
|
+
const self = this;
|
|
9767
|
+
|
|
9768
|
+
try {
|
|
9769
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'SM session (JWT) to call API');
|
|
9770
|
+
|
|
9771
|
+
const apiCall = self._client.get('/updates', self._setHeader(session));
|
|
9772
|
+
return self._returnData(await apiCall);
|
|
9773
|
+
} catch (ex) {
|
|
9774
|
+
throw ex;
|
|
9775
|
+
}
|
|
9776
|
+
}
|
|
9777
|
+
|
|
9778
|
+
}
|
|
9708
9779
|
|
|
9709
9780
|
/**
|
|
9710
9781
|
* Class for user datasource access, to be used with when creating new documents
|
|
@@ -9867,7 +9938,7 @@ class Users {
|
|
|
9867
9938
|
self.task = new Task(options);
|
|
9868
9939
|
self.user = self.profile = new User(options);
|
|
9869
9940
|
self.register = new Register(options);
|
|
9870
|
-
self.notification = new Notification
|
|
9941
|
+
self.notification = new Notification(options);
|
|
9871
9942
|
self.updates = new Updates(options);
|
|
9872
9943
|
}
|
|
9873
9944
|
}
|