@docbrasil/api-systemmanager 1.0.121 → 1.0.122
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/index.js +2 -0
- package/dist/bundle.cjs +109 -0
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
package/api/user/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import User from './user.js';
|
|
|
9
9
|
import Register from './register.js';
|
|
10
10
|
import Notification from './notification.js';
|
|
11
11
|
import Updates from './updates.js';
|
|
12
|
+
import Help from './help.js';
|
|
12
13
|
import Datasource from './datasource.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -35,6 +36,7 @@ class Users {
|
|
|
35
36
|
self.register = new Register(options);
|
|
36
37
|
self.notification = new Notification(options);
|
|
37
38
|
self.updates = new Updates(options);
|
|
39
|
+
self.help = new Help(options);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
package/dist/bundle.cjs
CHANGED
|
@@ -9777,6 +9777,114 @@ class Updates {
|
|
|
9777
9777
|
|
|
9778
9778
|
}
|
|
9779
9779
|
|
|
9780
|
+
/**
|
|
9781
|
+
* Class for user registration in a user
|
|
9782
|
+
* @class
|
|
9783
|
+
*/
|
|
9784
|
+
class Help {
|
|
9785
|
+
|
|
9786
|
+
constructor(options) {
|
|
9787
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
9788
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
9789
|
+
|
|
9790
|
+
const self = this;
|
|
9791
|
+
self.parent = options.parent;
|
|
9792
|
+
self._client = self.parent.dispatch.getClient();
|
|
9793
|
+
}
|
|
9794
|
+
|
|
9795
|
+
/**
|
|
9796
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9797
|
+
* @description Get the return data and check for errors
|
|
9798
|
+
* @param {object} retData Response HTTP
|
|
9799
|
+
* @return {*}
|
|
9800
|
+
* @private
|
|
9801
|
+
*/
|
|
9802
|
+
_returnData(retData, def = {}) {
|
|
9803
|
+
if (retData.status !== 200) {
|
|
9804
|
+
return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
9805
|
+
} else {
|
|
9806
|
+
return ___default["default"].get(retData, 'data', def);
|
|
9807
|
+
}
|
|
9808
|
+
}
|
|
9809
|
+
|
|
9810
|
+
/**
|
|
9811
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9812
|
+
* @description Set header with new session
|
|
9813
|
+
* @param {string} session Session, token JWT
|
|
9814
|
+
* @return {object} header with new session
|
|
9815
|
+
* @private
|
|
9816
|
+
*/
|
|
9817
|
+
_setHeader(session) {
|
|
9818
|
+
return {
|
|
9819
|
+
headers: {
|
|
9820
|
+
authorization: session,
|
|
9821
|
+
}
|
|
9822
|
+
};
|
|
9823
|
+
}
|
|
9824
|
+
|
|
9825
|
+
/**
|
|
9826
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9827
|
+
* @description get heps topics
|
|
9828
|
+
* @param {string} session JWT token
|
|
9829
|
+
* @public
|
|
9830
|
+
* @async
|
|
9831
|
+
* @example
|
|
9832
|
+
*
|
|
9833
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9834
|
+
* const api = new API();
|
|
9835
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9836
|
+
* await api.user.help.getTopics(session);
|
|
9837
|
+
*/
|
|
9838
|
+
async getTopics(session) {
|
|
9839
|
+
const self = this;
|
|
9840
|
+
|
|
9841
|
+
try {
|
|
9842
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'SM session (JWT) to call API');
|
|
9843
|
+
|
|
9844
|
+
const apiCall = self._client.get('/help/topics', self._setHeader(session));
|
|
9845
|
+
return self._returnData(await apiCall);
|
|
9846
|
+
} catch (ex) {
|
|
9847
|
+
throw ex;
|
|
9848
|
+
}
|
|
9849
|
+
}
|
|
9850
|
+
|
|
9851
|
+
/**
|
|
9852
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9853
|
+
* @description Method to find helps from a topic
|
|
9854
|
+
* @param {object} params Params to get helps from topic
|
|
9855
|
+
* @param {object} params.id Topic id (_id database)
|
|
9856
|
+
* @param {string} session Session, token JWT
|
|
9857
|
+
* @returns {promise}
|
|
9858
|
+
* @public
|
|
9859
|
+
* @example
|
|
9860
|
+
*
|
|
9861
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9862
|
+
* const api = new API();
|
|
9863
|
+
* const params = {
|
|
9864
|
+
* id: '5dadd01dc4af3941d42f8c5c'
|
|
9865
|
+
* };
|
|
9866
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9867
|
+
* await api.user.help.get(params, session);
|
|
9868
|
+
*/
|
|
9869
|
+
async get(params, session) {
|
|
9870
|
+
const self = this;
|
|
9871
|
+
|
|
9872
|
+
try {
|
|
9873
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to helps from a topic');
|
|
9874
|
+
Joi__default["default"].assert(params.id, Joi__default["default"].string().required(), 'Topic id (_id database)');
|
|
9875
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
9876
|
+
|
|
9877
|
+
const {id} = params;
|
|
9878
|
+
const apiCall = self._client.get(`/help/topic/${id}`, self._setHeader(session));
|
|
9879
|
+
|
|
9880
|
+
return self._returnData(await apiCall);
|
|
9881
|
+
} catch (ex) {
|
|
9882
|
+
throw ex;
|
|
9883
|
+
}
|
|
9884
|
+
}
|
|
9885
|
+
|
|
9886
|
+
}
|
|
9887
|
+
|
|
9780
9888
|
/**
|
|
9781
9889
|
* Class for user datasource access, to be used with when creating new documents
|
|
9782
9890
|
* @class
|
|
@@ -9940,6 +10048,7 @@ class Users {
|
|
|
9940
10048
|
self.register = new Register(options);
|
|
9941
10049
|
self.notification = new Notification(options);
|
|
9942
10050
|
self.updates = new Updates(options);
|
|
10051
|
+
self.help = new Help(options);
|
|
9943
10052
|
}
|
|
9944
10053
|
}
|
|
9945
10054
|
|