@docbrasil/api-systemmanager 1.1.31 → 1.1.32
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/notification.js +47 -6
- package/dist/bundle.cjs +47 -6
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +35 -4
- package/docs/Dispatch.html +2 -2
- package/docs/Notification.html +324 -10
- package/docs/dispatch.js.html +1 -6
- package/docs/user_notification.js.html +47 -6
- package/package.json +1 -1
package/api/user/notification.js
CHANGED
|
@@ -62,8 +62,10 @@ class Notification {
|
|
|
62
62
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
63
63
|
* @description Method to add a notification token
|
|
64
64
|
* @param {object} params Params to add notification token
|
|
65
|
-
* @param {
|
|
66
|
-
* @param {object} params.
|
|
65
|
+
* @param {obhect} params.token The token
|
|
66
|
+
* @param {object} params.token.value The token value
|
|
67
|
+
* @param {object} params.token.type The token type
|
|
68
|
+
* @param {object} params.token.data The extra data of a token, if there is.
|
|
67
69
|
* @param {string} session Is token JWT of user NOT allow SU
|
|
68
70
|
* @returns {promise<object>} data
|
|
69
71
|
* @returns {boolean} data._id the id of the added token
|
|
@@ -74,21 +76,60 @@ class Notification {
|
|
|
74
76
|
* const api = new API();
|
|
75
77
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
76
78
|
* const params = {
|
|
77
|
-
* token:
|
|
78
|
-
*
|
|
79
|
+
* token: {
|
|
80
|
+
* value: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
|
|
81
|
+
* type: 'FCM_CAPACITOR'
|
|
82
|
+
* }
|
|
79
83
|
* };
|
|
80
84
|
* const retData = await api.user.notification.addToken(params, session);
|
|
81
85
|
*/
|
|
82
86
|
async addToken(params = {}, session) {
|
|
83
87
|
const self = this;
|
|
84
88
|
|
|
89
|
+
try {
|
|
90
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
91
|
+
Joi.assert(params.token, Joi.object().required(), 'Token information to add');
|
|
92
|
+
Joi.assert(params.token.value, Joi.string().required(), 'Token token value');
|
|
93
|
+
Joi.assert(params.token.type, Joi.string().required(), 'The type of the token');
|
|
94
|
+
|
|
95
|
+
const apiCall = self._client
|
|
96
|
+
.put(`/notifications/token`, params, self._setHeader(session));
|
|
97
|
+
|
|
98
|
+
const retData = self._returnData(await apiCall);
|
|
99
|
+
return retData;
|
|
100
|
+
} catch (ex) {
|
|
101
|
+
throw ex;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
107
|
+
* @description Method to remove a notification token
|
|
108
|
+
* @param {object} params Params to add notification token
|
|
109
|
+
* @param {obhect} params.token The token value
|
|
110
|
+
* @param {string} session Is token JWT of user NOT allow SU
|
|
111
|
+
* @returns {promise<object>} data
|
|
112
|
+
* @returns {boolean} data._id the id of the added token
|
|
113
|
+
* @public
|
|
114
|
+
* @example
|
|
115
|
+
*
|
|
116
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
117
|
+
* const api = new API();
|
|
118
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
119
|
+
* const params = {
|
|
120
|
+
* token:'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2'
|
|
121
|
+
* };
|
|
122
|
+
* const retData = await api.user.notification.removeToken(params, session);
|
|
123
|
+
*/
|
|
124
|
+
async removeToken(params = {}, session) {
|
|
125
|
+
const self = this;
|
|
126
|
+
|
|
85
127
|
try {
|
|
86
128
|
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
87
129
|
Joi.assert(params.token, Joi.string().required(), 'Token is required');
|
|
88
|
-
Joi.assert(params.type, Joi.string().required(), ' The token type');
|
|
89
130
|
|
|
90
131
|
const apiCall = self._client
|
|
91
|
-
|
|
132
|
+
.delete(`/notifications/token/${params.token}`, self._setHeader(session));
|
|
92
133
|
|
|
93
134
|
const retData = self._returnData(await apiCall);
|
|
94
135
|
return retData;
|
package/dist/bundle.cjs
CHANGED
|
@@ -10384,8 +10384,10 @@ class Notification {
|
|
|
10384
10384
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
10385
10385
|
* @description Method to add a notification token
|
|
10386
10386
|
* @param {object} params Params to add notification token
|
|
10387
|
-
* @param {
|
|
10388
|
-
* @param {object} params.
|
|
10387
|
+
* @param {obhect} params.token The token
|
|
10388
|
+
* @param {object} params.token.value The token value
|
|
10389
|
+
* @param {object} params.token.type The token type
|
|
10390
|
+
* @param {object} params.token.data The extra data of a token, if there is.
|
|
10389
10391
|
* @param {string} session Is token JWT of user NOT allow SU
|
|
10390
10392
|
* @returns {promise<object>} data
|
|
10391
10393
|
* @returns {boolean} data._id the id of the added token
|
|
@@ -10396,21 +10398,60 @@ class Notification {
|
|
|
10396
10398
|
* const api = new API();
|
|
10397
10399
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
10398
10400
|
* const params = {
|
|
10399
|
-
* token:
|
|
10400
|
-
*
|
|
10401
|
+
* token: {
|
|
10402
|
+
* value: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
|
|
10403
|
+
* type: 'FCM_CAPACITOR'
|
|
10404
|
+
* }
|
|
10401
10405
|
* };
|
|
10402
10406
|
* const retData = await api.user.notification.addToken(params, session);
|
|
10403
10407
|
*/
|
|
10404
10408
|
async addToken(params = {}, session) {
|
|
10405
10409
|
const self = this;
|
|
10406
10410
|
|
|
10411
|
+
try {
|
|
10412
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
10413
|
+
Joi__default["default"].assert(params.token, Joi__default["default"].object().required(), 'Token information to add');
|
|
10414
|
+
Joi__default["default"].assert(params.token.value, Joi__default["default"].string().required(), 'Token token value');
|
|
10415
|
+
Joi__default["default"].assert(params.token.type, Joi__default["default"].string().required(), 'The type of the token');
|
|
10416
|
+
|
|
10417
|
+
const apiCall = self._client
|
|
10418
|
+
.put(`/notifications/token`, params, self._setHeader(session));
|
|
10419
|
+
|
|
10420
|
+
const retData = self._returnData(await apiCall);
|
|
10421
|
+
return retData;
|
|
10422
|
+
} catch (ex) {
|
|
10423
|
+
throw ex;
|
|
10424
|
+
}
|
|
10425
|
+
}
|
|
10426
|
+
|
|
10427
|
+
/**
|
|
10428
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
10429
|
+
* @description Method to remove a notification token
|
|
10430
|
+
* @param {object} params Params to add notification token
|
|
10431
|
+
* @param {obhect} params.token The token value
|
|
10432
|
+
* @param {string} session Is token JWT of user NOT allow SU
|
|
10433
|
+
* @returns {promise<object>} data
|
|
10434
|
+
* @returns {boolean} data._id the id of the added token
|
|
10435
|
+
* @public
|
|
10436
|
+
* @example
|
|
10437
|
+
*
|
|
10438
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
10439
|
+
* const api = new API();
|
|
10440
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
10441
|
+
* const params = {
|
|
10442
|
+
* token:'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2'
|
|
10443
|
+
* };
|
|
10444
|
+
* const retData = await api.user.notification.removeToken(params, session);
|
|
10445
|
+
*/
|
|
10446
|
+
async removeToken(params = {}, session) {
|
|
10447
|
+
const self = this;
|
|
10448
|
+
|
|
10407
10449
|
try {
|
|
10408
10450
|
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
10409
10451
|
Joi__default["default"].assert(params.token, Joi__default["default"].string().required(), 'Token is required');
|
|
10410
|
-
Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), ' The token type');
|
|
10411
10452
|
|
|
10412
10453
|
const apiCall = self._client
|
|
10413
|
-
|
|
10454
|
+
.delete(`/notifications/token/${params.token}`, self._setHeader(session));
|
|
10414
10455
|
|
|
10415
10456
|
const retData = self._returnData(await apiCall);
|
|
10416
10457
|
return retData;
|