@docbrasil/api-systemmanager 1.0.114 → 1.0.116
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/.project +11 -0
- package/api/user/notification.js +124 -0
- package/api/user/process.js +0 -1
- package/dist/bundle.cjs +124 -1
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +94 -0
- package/docs/user_process.js.html +0 -1
- package/package.json +1 -1
package/.project
ADDED
package/api/user/notification.js
CHANGED
|
@@ -96,6 +96,130 @@ class Notification {
|
|
|
96
96
|
throw ex;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
102
|
+
* @description get new notifications
|
|
103
|
+
* @param {string} session JWT token
|
|
104
|
+
* @public
|
|
105
|
+
* @async
|
|
106
|
+
* @example
|
|
107
|
+
*
|
|
108
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
109
|
+
* const api = new API();
|
|
110
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
111
|
+
* await api.user.notification.getNew(session);
|
|
112
|
+
*/
|
|
113
|
+
async getNew(session) {
|
|
114
|
+
const self = this;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
Joi.assert(session, Joi.string().required(), 'SM session (JWT) to call API');
|
|
118
|
+
|
|
119
|
+
const apiCall = self._client.get('/organizations/notifications/new', self._setHeader(session));
|
|
120
|
+
return self._returnData(await apiCall);
|
|
121
|
+
} catch (ex) {
|
|
122
|
+
throw ex;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
128
|
+
* @description get old notifications
|
|
129
|
+
* @param {string} session JWT token
|
|
130
|
+
* @public
|
|
131
|
+
* @async
|
|
132
|
+
* @example
|
|
133
|
+
*
|
|
134
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
135
|
+
* const api = new API();
|
|
136
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
137
|
+
* await api.user.notification.getOld(session);
|
|
138
|
+
*/
|
|
139
|
+
async getOld(session) {
|
|
140
|
+
const self = this;
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
Joi.assert(session, Joi.string().required(), 'SM session (JWT) to call API');
|
|
144
|
+
|
|
145
|
+
const apiCall = self._client.get('/organizations/notifications/old', self._setHeader(session));
|
|
146
|
+
return self._returnData(await apiCall);
|
|
147
|
+
} catch (ex) {
|
|
148
|
+
throw ex;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
154
|
+
* @description Set notification as readed
|
|
155
|
+
* @param {object} params Params to update the notification
|
|
156
|
+
* @param {string} params.id Notification Id
|
|
157
|
+
* @param {string} session JWT Token
|
|
158
|
+
* @return {Promise}
|
|
159
|
+
* @public
|
|
160
|
+
* @async
|
|
161
|
+
* @example
|
|
162
|
+
*
|
|
163
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
164
|
+
* const api = new API();
|
|
165
|
+
* const params = {
|
|
166
|
+
* id: '34c344c43c34c344c43c'
|
|
167
|
+
* };
|
|
168
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
169
|
+
* await api.user.notification.setRead(params, session);
|
|
170
|
+
*/
|
|
171
|
+
async setRead(params = {}, session) {
|
|
172
|
+
const self = this;
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
Joi.assert(params, Joi.object().required());
|
|
176
|
+
Joi.assert(params.id, Joi.string().required());
|
|
177
|
+
Joi.assert(session, Joi.string().required());
|
|
178
|
+
|
|
179
|
+
const {id} = params;
|
|
180
|
+
|
|
181
|
+
const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
|
|
182
|
+
return self._returnData(await apiCall);
|
|
183
|
+
} catch (ex) {
|
|
184
|
+
throw ex;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
190
|
+
* @description Set notification as unreaded
|
|
191
|
+
* @param {object} params Params to update the notification
|
|
192
|
+
* @param {string} params.id Notification Id
|
|
193
|
+
* @param {string} session JWT Token
|
|
194
|
+
* @return {Promise}
|
|
195
|
+
* @public
|
|
196
|
+
* @async
|
|
197
|
+
* @example
|
|
198
|
+
*
|
|
199
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
200
|
+
* const api = new API();
|
|
201
|
+
* const params = {
|
|
202
|
+
* id: '34c344c43c34c344c43c'
|
|
203
|
+
* };
|
|
204
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
205
|
+
* await api.user.notification.setUnread(params, session);
|
|
206
|
+
*/
|
|
207
|
+
async setUnread(params = {}, session) {
|
|
208
|
+
const self = this;
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
Joi.assert(params, Joi.object().required());
|
|
212
|
+
Joi.assert(params.id, Joi.string().required());
|
|
213
|
+
Joi.assert(session, Joi.string().required());
|
|
214
|
+
|
|
215
|
+
const {id} = params;
|
|
216
|
+
|
|
217
|
+
const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
|
|
218
|
+
return self._returnData(await apiCall);
|
|
219
|
+
} catch (ex) {
|
|
220
|
+
throw ex;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
99
223
|
}
|
|
100
224
|
|
|
101
225
|
export default Notification;
|
package/api/user/process.js
CHANGED
|
@@ -419,7 +419,6 @@ class Process {
|
|
|
419
419
|
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
420
420
|
Joi.assert(params.type, Joi.string().required(), 'Document Type');
|
|
421
421
|
Joi.assert(params.docIds, Joi.array().required(), 'Document Ids');
|
|
422
|
-
Joi.assert(params.footer, Joi.string(), 'Documents Footer');
|
|
423
422
|
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
424
423
|
|
|
425
424
|
const {orgId, type, docIds, footer} = params;
|
package/dist/bundle.cjs
CHANGED
|
@@ -1920,7 +1920,6 @@ class Process {
|
|
|
1920
1920
|
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
1921
1921
|
Joi__default["default"].assert(params.type, Joi__default["default"].string().required(), 'Document Type');
|
|
1922
1922
|
Joi__default["default"].assert(params.docIds, Joi__default["default"].array().required(), 'Document Ids');
|
|
1923
|
-
Joi__default["default"].assert(params.footer, Joi__default["default"].string(), 'Documents Footer');
|
|
1924
1923
|
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
1925
1924
|
|
|
1926
1925
|
const {orgId, type, docIds, footer} = params;
|
|
@@ -9579,6 +9578,130 @@ class Notification {
|
|
|
9579
9578
|
throw ex;
|
|
9580
9579
|
}
|
|
9581
9580
|
}
|
|
9581
|
+
|
|
9582
|
+
/**
|
|
9583
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9584
|
+
* @description get new notifications
|
|
9585
|
+
* @param {string} session JWT token
|
|
9586
|
+
* @public
|
|
9587
|
+
* @async
|
|
9588
|
+
* @example
|
|
9589
|
+
*
|
|
9590
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9591
|
+
* const api = new API();
|
|
9592
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9593
|
+
* await api.user.notification.getNew(session);
|
|
9594
|
+
*/
|
|
9595
|
+
async getNew(session) {
|
|
9596
|
+
const self = this;
|
|
9597
|
+
|
|
9598
|
+
try {
|
|
9599
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'SM session (JWT) to call API');
|
|
9600
|
+
|
|
9601
|
+
const apiCall = self._client.get('/organizations/notifications/new', self._setHeader(session));
|
|
9602
|
+
return self._returnData(await apiCall);
|
|
9603
|
+
} catch (ex) {
|
|
9604
|
+
throw ex;
|
|
9605
|
+
}
|
|
9606
|
+
}
|
|
9607
|
+
|
|
9608
|
+
/**
|
|
9609
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
9610
|
+
* @description get old notifications
|
|
9611
|
+
* @param {string} session JWT token
|
|
9612
|
+
* @public
|
|
9613
|
+
* @async
|
|
9614
|
+
* @example
|
|
9615
|
+
*
|
|
9616
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9617
|
+
* const api = new API();
|
|
9618
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9619
|
+
* await api.user.notification.getOld(session);
|
|
9620
|
+
*/
|
|
9621
|
+
async getOld(session) {
|
|
9622
|
+
const self = this;
|
|
9623
|
+
|
|
9624
|
+
try {
|
|
9625
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'SM session (JWT) to call API');
|
|
9626
|
+
|
|
9627
|
+
const apiCall = self._client.get('/organizations/notifications/old', self._setHeader(session));
|
|
9628
|
+
return self._returnData(await apiCall);
|
|
9629
|
+
} catch (ex) {
|
|
9630
|
+
throw ex;
|
|
9631
|
+
}
|
|
9632
|
+
}
|
|
9633
|
+
|
|
9634
|
+
/**
|
|
9635
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9636
|
+
* @description Set notification as readed
|
|
9637
|
+
* @param {object} params Params to update the notification
|
|
9638
|
+
* @param {string} params.id Notification Id
|
|
9639
|
+
* @param {string} session JWT Token
|
|
9640
|
+
* @return {Promise}
|
|
9641
|
+
* @public
|
|
9642
|
+
* @async
|
|
9643
|
+
* @example
|
|
9644
|
+
*
|
|
9645
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9646
|
+
* const api = new API();
|
|
9647
|
+
* const params = {
|
|
9648
|
+
* id: '34c344c43c34c344c43c'
|
|
9649
|
+
* };
|
|
9650
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9651
|
+
* await api.user.notification.setRead(params, session);
|
|
9652
|
+
*/
|
|
9653
|
+
async setRead(params = {}, session) {
|
|
9654
|
+
const self = this;
|
|
9655
|
+
|
|
9656
|
+
try {
|
|
9657
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
9658
|
+
Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
|
|
9659
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
9660
|
+
|
|
9661
|
+
const {id} = params;
|
|
9662
|
+
|
|
9663
|
+
const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
|
|
9664
|
+
return self._returnData(await apiCall);
|
|
9665
|
+
} catch (ex) {
|
|
9666
|
+
throw ex;
|
|
9667
|
+
}
|
|
9668
|
+
}
|
|
9669
|
+
|
|
9670
|
+
/**
|
|
9671
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9672
|
+
* @description Set notification as unreaded
|
|
9673
|
+
* @param {object} params Params to update the notification
|
|
9674
|
+
* @param {string} params.id Notification Id
|
|
9675
|
+
* @param {string} session JWT Token
|
|
9676
|
+
* @return {Promise}
|
|
9677
|
+
* @public
|
|
9678
|
+
* @async
|
|
9679
|
+
* @example
|
|
9680
|
+
*
|
|
9681
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
9682
|
+
* const api = new API();
|
|
9683
|
+
* const params = {
|
|
9684
|
+
* id: '34c344c43c34c344c43c'
|
|
9685
|
+
* };
|
|
9686
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
9687
|
+
* await api.user.notification.setUnread(params, session);
|
|
9688
|
+
*/
|
|
9689
|
+
async setUnread(params = {}, session) {
|
|
9690
|
+
const self = this;
|
|
9691
|
+
|
|
9692
|
+
try {
|
|
9693
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
9694
|
+
Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
|
|
9695
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
9696
|
+
|
|
9697
|
+
const {id} = params;
|
|
9698
|
+
|
|
9699
|
+
const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
|
|
9700
|
+
return self._returnData(await apiCall);
|
|
9701
|
+
} catch (ex) {
|
|
9702
|
+
throw ex;
|
|
9703
|
+
}
|
|
9704
|
+
}
|
|
9582
9705
|
}
|
|
9583
9706
|
|
|
9584
9707
|
/**
|