@docbrasil/api-systemmanager 1.1.31 → 1.1.33

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.
@@ -62,7 +62,7 @@ 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 {string} params.token The token
65
+ * @param {obhect} params.token The token value
66
66
  * @param {object} params.type The token type
67
67
  * @param {string} session Is token JWT of user NOT allow SU
68
68
  * @returns {promise<object>} data
@@ -75,20 +75,56 @@ class Notification {
75
75
  * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
76
76
  * const params = {
77
77
  * token: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
78
- * type: 'FCM_WEB'
78
+ * type: 'FCM_CAPACITOR'
79
79
  * };
80
80
  * const retData = await api.user.notification.addToken(params, session);
81
81
  */
82
82
  async addToken(params = {}, session) {
83
83
  const self = this;
84
84
 
85
+ try {
86
+ Joi.assert(params, Joi.object().required(), 'Params to get task');
87
+ Joi.assert(params.token, Joi.string().required(), 'Token token value');
88
+ Joi.assert(params.type, Joi.string().required(), 'The type of the token');
89
+
90
+ const apiCall = self._client
91
+ .put(`/notifications/token`, params, self._setHeader(session));
92
+
93
+ const retData = self._returnData(await apiCall);
94
+ return retData;
95
+ } catch (ex) {
96
+ throw ex;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @author Myndware <augusto.pissarra@myndware.com>
102
+ * @description Method to remove a notification token
103
+ * @param {object} params Params to add notification token
104
+ * @param {obhect} params.token The token value
105
+ * @param {string} session Is token JWT of user NOT allow SU
106
+ * @returns {promise<object>} data
107
+ * @returns {boolean} data._id the id of the added token
108
+ * @public
109
+ * @example
110
+ *
111
+ * const API = require('@docbrasil/api-systemmanager');
112
+ * const api = new API();
113
+ * const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
114
+ * const params = {
115
+ * token:'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2'
116
+ * };
117
+ * const retData = await api.user.notification.removeToken(params, session);
118
+ */
119
+ async removeToken(params = {}, session) {
120
+ const self = this;
121
+
85
122
  try {
86
123
  Joi.assert(params, Joi.object().required(), 'Params to get task');
87
124
  Joi.assert(params.token, Joi.string().required(), 'Token is required');
88
- Joi.assert(params.type, Joi.string().required(), ' The token type');
89
125
 
90
126
  const apiCall = self._client
91
- .put(`/users/notifications/token`, params, self._setHeader(session));
127
+ .delete(`/notifications/token/${params.token}`, self._setHeader(session));
92
128
 
93
129
  const retData = self._returnData(await apiCall);
94
130
  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 {string} params.token The token
10388
- * @param {object} params.type The token type
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: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
10400
- * type: 'FCM_WEB'
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
- .put(`/users/notifications/token`, params, self._setHeader(session));
10454
+ .delete(`/notifications/token/${params.token}`, self._setHeader(session));
10414
10455
 
10415
10456
  const retData = self._returnData(await apiCall);
10416
10457
  return retData;