@docbrasil/api-systemmanager 1.0.83 → 1.0.85
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/admin/notification.js +24 -0
- package/api/user/process.js +44 -0
- package/api/user/task.js +2 -0
- package/api/user/task_available.js +134 -0
- package/dist/bundle.cjs +198 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +100 -0
- package/package.json +1 -1
|
@@ -47,6 +47,30 @@ class AdminNotification {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @description Send real time notification
|
|
52
|
+
* @param {object} params Params to send notification
|
|
53
|
+
* @param {string} params.userIds Users to send notification
|
|
54
|
+
* @param {object} params.message Object with data to send user
|
|
55
|
+
* @param {object} session Session, token JWT
|
|
56
|
+
* @returns {Promise<*>}
|
|
57
|
+
*/
|
|
58
|
+
async realTime(params, session) {
|
|
59
|
+
const self = this;
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
Joi.assert(params, Joi.object().required(), 'Object with params to add notifications');
|
|
63
|
+
Joi.assert(params.userIds, Joi.array().required(), 'OrgId of the user SU');
|
|
64
|
+
Joi.assert(params.message, Joi.object().required(), 'Object with data to send user');
|
|
65
|
+
Joi.assert(session, Joi.string().required(), 'Session, token JWT');
|
|
66
|
+
|
|
67
|
+
const apiCall = self.client.post(`/admin/send/notifications`, params, self._setHeader(session));
|
|
68
|
+
return self._returnData(await apiCall);
|
|
69
|
+
} catch (ex) {
|
|
70
|
+
throw ex;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
50
74
|
/**
|
|
51
75
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
52
76
|
* @description Create notification
|
package/api/user/process.js
CHANGED
|
@@ -142,6 +142,50 @@ class Process {
|
|
|
142
142
|
throw ex;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
148
|
+
* @description Get the search info of a organization process
|
|
149
|
+
* @param {object} params Params to get search info
|
|
150
|
+
* @param {string} params.orgProcessId The id of an organization process (_id database);
|
|
151
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
152
|
+
* @param {string} session Session, token JWT
|
|
153
|
+
* @return {Promise} the search info result
|
|
154
|
+
* @return {string} name the name of the organization process
|
|
155
|
+
* @return {object} processIndexFields the list of fields to index
|
|
156
|
+
* @return {object} processParticipantsGroup the permissions in this organization process
|
|
157
|
+
* @return {object} stepsProperties the organization process steps properties
|
|
158
|
+
* @return {string} _id the same organization id
|
|
159
|
+
* @
|
|
160
|
+
* @public
|
|
161
|
+
* @async
|
|
162
|
+
* @example
|
|
163
|
+
*
|
|
164
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
165
|
+
* const api = new API();
|
|
166
|
+
* const params = {
|
|
167
|
+
* orgProcessId: '5dadd01dc4af3941d42f8c67',
|
|
168
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
169
|
+
* }
|
|
170
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
171
|
+
* const retSearchInfo = await api.user.process.getOrgProcessSearchInfo(params, session);
|
|
172
|
+
*/
|
|
173
|
+
async getOrgProcessSearchInfo(params, session) {
|
|
174
|
+
const self = this;
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
Joi.assert(params, Joi.object().required());
|
|
178
|
+
Joi.assert(params.orgProcessId, Joi.string().required());
|
|
179
|
+
Joi.assert(params.orgId, Joi.string().required());
|
|
180
|
+
Joi.assert(session, Joi.string().required());
|
|
181
|
+
|
|
182
|
+
const {orgProcessId, orgId} = params;
|
|
183
|
+
const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/search/info`, self._setHeader(session));
|
|
184
|
+
return self._returnData(await apiCall);
|
|
185
|
+
} catch (ex) {
|
|
186
|
+
throw ex;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
145
189
|
}
|
|
146
190
|
|
|
147
191
|
export default Process;
|
package/api/user/task.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import Boom from '@hapi/boom';
|
|
3
3
|
import Joi from 'joi';
|
|
4
|
+
import TaskAvailable from './task_available';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Class for task, permission user
|
|
@@ -15,6 +16,7 @@ class Task {
|
|
|
15
16
|
const self = this;
|
|
16
17
|
self.parent = options.parent;
|
|
17
18
|
self._client = self.parent.dispatch.getClient();
|
|
19
|
+
self.available = new TaskAvailable(options);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class for available tasks, permission user
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class TaskAvailable {
|
|
10
|
+
|
|
11
|
+
constructor(options) {
|
|
12
|
+
Joi.assert(options, Joi.object().required());
|
|
13
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
14
|
+
|
|
15
|
+
const self = this;
|
|
16
|
+
self.parent = options.parent;
|
|
17
|
+
self._client = self.parent.dispatch.getClient();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
22
|
+
* @description Get the return data and check for errors
|
|
23
|
+
* @param {object} retData Response HTTP
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
_returnData(retData, def = {}) {
|
|
28
|
+
if (retData.status !== 200) {
|
|
29
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
30
|
+
} else {
|
|
31
|
+
return _.get(retData, 'data', def);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
37
|
+
* @description Set header with new session
|
|
38
|
+
* @param {string} session Session, token JWT
|
|
39
|
+
* @return {object} header with new session
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
_setHeader(session) {
|
|
43
|
+
return {
|
|
44
|
+
headers: {
|
|
45
|
+
authorization: session,
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
52
|
+
* @description Method to find available tasks for a user
|
|
53
|
+
* @param {object} params Params to get task
|
|
54
|
+
* @param {object} params.query Search process query
|
|
55
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
56
|
+
* @param {string} session Session, token JWT
|
|
57
|
+
* @returns {promise} returned data from the search
|
|
58
|
+
* @returns {number} count the count of items searched
|
|
59
|
+
* @returns {array<object>} items the items returned from search
|
|
60
|
+
* @returns {number} page the page of the search (on pagination), zero indexed
|
|
61
|
+
* @returns {number} perPage how many items per page
|
|
62
|
+
* @public
|
|
63
|
+
* @example
|
|
64
|
+
*
|
|
65
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
66
|
+
* const api = new API();
|
|
67
|
+
* const params = {
|
|
68
|
+
* query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
|
|
69
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
70
|
+
* };
|
|
71
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
72
|
+
* const retSearch = await api.user.task.available.find(params, session);
|
|
73
|
+
*/
|
|
74
|
+
async find(params, session) {
|
|
75
|
+
const self = this;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
79
|
+
Joi.assert(params.query, Joi.object().required(), ' The query for the search');
|
|
80
|
+
Joi.assert(params.orgId, Joi.string().required(), 'Organization id (_id database)');
|
|
81
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
82
|
+
|
|
83
|
+
const {query, orgId} = params;
|
|
84
|
+
const apiCall = self._client
|
|
85
|
+
.post(`/organizations/${orgId}/users/tasks/groups/advsearch?query=${JSON.stringify(query)}`, self._setHeader(session));
|
|
86
|
+
|
|
87
|
+
return self._returnData(await apiCall);
|
|
88
|
+
} catch (ex) {
|
|
89
|
+
throw ex;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
95
|
+
* @description Method for a user to claim an available task
|
|
96
|
+
* @param {object} params Params to get task
|
|
97
|
+
* @param {object} params.taskId the task id to claim
|
|
98
|
+
* @param {object} params.orgname Organization slug (short name of the orgnization)
|
|
99
|
+
* @param {string} session Session, token JWT
|
|
100
|
+
* @returns {promise} returned data from the method call
|
|
101
|
+
* @returns {boolean} success true|false if the method was successful
|
|
102
|
+
* @public
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
106
|
+
* const api = new API();
|
|
107
|
+
* const params = {
|
|
108
|
+
* taskId: '55e4a3bd6be6b45210833f67',
|
|
109
|
+
* orgname: 'acme',
|
|
110
|
+
* };
|
|
111
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
112
|
+
* const success = await api.user.task.available.claim(params, session);
|
|
113
|
+
*/
|
|
114
|
+
async claim(params, session) {
|
|
115
|
+
const self = this;
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
119
|
+
Joi.assert(params.taskId, Joi.object().required(), 'The task id to claim');
|
|
120
|
+
Joi.assert(params.orgname, Joi.string().required(), 'The slug of the organization');
|
|
121
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
122
|
+
|
|
123
|
+
const {query, orgId} = params;
|
|
124
|
+
const apiCall = self._client
|
|
125
|
+
.put(`/organizations/${orgname}/users/tasks/${taskId}/claim`, self._setHeader(session));
|
|
126
|
+
|
|
127
|
+
return self._returnData(await apiCall);
|
|
128
|
+
} catch (ex) {
|
|
129
|
+
throw ex;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default TaskAvailable;
|
package/dist/bundle.cjs
CHANGED
|
@@ -1600,6 +1600,179 @@ class Process {
|
|
|
1600
1600
|
throw ex;
|
|
1601
1601
|
}
|
|
1602
1602
|
}
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1606
|
+
* @description Get the search info of a organization process
|
|
1607
|
+
* @param {object} params Params to get search info
|
|
1608
|
+
* @param {string} params.orgProcessId The id of an organization process (_id database);
|
|
1609
|
+
* @param {string} params.orgId Organization id (_id database);
|
|
1610
|
+
* @param {string} session Session, token JWT
|
|
1611
|
+
* @return {Promise} the search info result
|
|
1612
|
+
* @return {string} name the name of the organization process
|
|
1613
|
+
* @return {object} processIndexFields the list of fields to index
|
|
1614
|
+
* @return {object} processParticipantsGroup the permissions in this organization process
|
|
1615
|
+
* @return {object} stepsProperties the organization process steps properties
|
|
1616
|
+
* @return {string} _id the same organization id
|
|
1617
|
+
* @
|
|
1618
|
+
* @public
|
|
1619
|
+
* @async
|
|
1620
|
+
* @example
|
|
1621
|
+
*
|
|
1622
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
1623
|
+
* const api = new API();
|
|
1624
|
+
* const params = {
|
|
1625
|
+
* orgProcessId: '5dadd01dc4af3941d42f8c67',
|
|
1626
|
+
* orgId: '5edd11c46b6ce9729c2c297c',
|
|
1627
|
+
* }
|
|
1628
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1629
|
+
* const retSearchInfo = await api.user.process.getOrgProcessSearchInfo(params, session);
|
|
1630
|
+
*/
|
|
1631
|
+
async getOrgProcessSearchInfo(params, session) {
|
|
1632
|
+
const self = this;
|
|
1633
|
+
|
|
1634
|
+
try {
|
|
1635
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
1636
|
+
Joi__default["default"].assert(params.orgProcessId, Joi__default["default"].string().required());
|
|
1637
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required());
|
|
1638
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
1639
|
+
|
|
1640
|
+
const {orgProcessId, orgId} = params;
|
|
1641
|
+
const apiCall = self._client.get(`/organizations/${orgId}/orgprocess/${orgProcessId}/search/info`, self._setHeader(session));
|
|
1642
|
+
return self._returnData(await apiCall);
|
|
1643
|
+
} catch (ex) {
|
|
1644
|
+
throw ex;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Class for available tasks, permission user
|
|
1651
|
+
* @class
|
|
1652
|
+
*/
|
|
1653
|
+
class TaskAvailable {
|
|
1654
|
+
|
|
1655
|
+
constructor(options) {
|
|
1656
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
1657
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
1658
|
+
|
|
1659
|
+
const self = this;
|
|
1660
|
+
self.parent = options.parent;
|
|
1661
|
+
self._client = self.parent.dispatch.getClient();
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
1666
|
+
* @description Get the return data and check for errors
|
|
1667
|
+
* @param {object} retData Response HTTP
|
|
1668
|
+
* @return {*}
|
|
1669
|
+
* @private
|
|
1670
|
+
*/
|
|
1671
|
+
_returnData(retData, def = {}) {
|
|
1672
|
+
if (retData.status !== 200) {
|
|
1673
|
+
return Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
1674
|
+
} else {
|
|
1675
|
+
return ___default["default"].get(retData, 'data', def);
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1681
|
+
* @description Set header with new session
|
|
1682
|
+
* @param {string} session Session, token JWT
|
|
1683
|
+
* @return {object} header with new session
|
|
1684
|
+
* @private
|
|
1685
|
+
*/
|
|
1686
|
+
_setHeader(session) {
|
|
1687
|
+
return {
|
|
1688
|
+
headers: {
|
|
1689
|
+
authorization: session,
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1696
|
+
* @description Method to find available tasks for a user
|
|
1697
|
+
* @param {object} params Params to get task
|
|
1698
|
+
* @param {object} params.query Search process query
|
|
1699
|
+
* @param {object} params.orgId Organization id (_id database)
|
|
1700
|
+
* @param {string} session Session, token JWT
|
|
1701
|
+
* @returns {promise} returned data from the search
|
|
1702
|
+
* @returns {number} count the count of items searched
|
|
1703
|
+
* @returns {array<object>} items the items returned from search
|
|
1704
|
+
* @returns {number} page the page of the search (on pagination), zero indexed
|
|
1705
|
+
* @returns {number} perPage how many items per page
|
|
1706
|
+
* @public
|
|
1707
|
+
* @example
|
|
1708
|
+
*
|
|
1709
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
1710
|
+
* const api = new API();
|
|
1711
|
+
* const params = {
|
|
1712
|
+
* query: {"orgProcessId": {"value":"62c2d1cdfb5455c195d1baa1","oper":"=","type":"string"},"s":[{"historyBegin":{"order":"desc"}}],"i":1,"p":20},
|
|
1713
|
+
* orgId: '55e4a3bd6be6b45210833fae',
|
|
1714
|
+
* };
|
|
1715
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1716
|
+
* const retSearch = await api.user.task.available.find(params, session);
|
|
1717
|
+
*/
|
|
1718
|
+
async find(params, session) {
|
|
1719
|
+
const self = this;
|
|
1720
|
+
|
|
1721
|
+
try {
|
|
1722
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
1723
|
+
Joi__default["default"].assert(params.query, Joi__default["default"].object().required(), ' The query for the search');
|
|
1724
|
+
Joi__default["default"].assert(params.orgId, Joi__default["default"].string().required(), 'Organization id (_id database)');
|
|
1725
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
1726
|
+
|
|
1727
|
+
const {query, orgId} = params;
|
|
1728
|
+
const apiCall = self._client
|
|
1729
|
+
.post(`/organizations/${orgId}/users/tasks/groups/advsearch?query=${JSON.stringify(query)}`, self._setHeader(session));
|
|
1730
|
+
|
|
1731
|
+
return self._returnData(await apiCall);
|
|
1732
|
+
} catch (ex) {
|
|
1733
|
+
throw ex;
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
1739
|
+
* @description Method for a user to claim an available task
|
|
1740
|
+
* @param {object} params Params to get task
|
|
1741
|
+
* @param {object} params.taskId the task id to claim
|
|
1742
|
+
* @param {object} params.orgname Organization slug (short name of the orgnization)
|
|
1743
|
+
* @param {string} session Session, token JWT
|
|
1744
|
+
* @returns {promise} returned data from the method call
|
|
1745
|
+
* @returns {boolean} success true|false if the method was successful
|
|
1746
|
+
* @public
|
|
1747
|
+
* @example
|
|
1748
|
+
*
|
|
1749
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
1750
|
+
* const api = new API();
|
|
1751
|
+
* const params = {
|
|
1752
|
+
* taskId: '55e4a3bd6be6b45210833f67',
|
|
1753
|
+
* orgname: 'acme',
|
|
1754
|
+
* };
|
|
1755
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1756
|
+
* const success = await api.user.task.available.claim(params, session);
|
|
1757
|
+
*/
|
|
1758
|
+
async claim(params, session) {
|
|
1759
|
+
const self = this;
|
|
1760
|
+
|
|
1761
|
+
try {
|
|
1762
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
1763
|
+
Joi__default["default"].assert(params.taskId, Joi__default["default"].object().required(), 'The task id to claim');
|
|
1764
|
+
Joi__default["default"].assert(params.orgname, Joi__default["default"].string().required(), 'The slug of the organization');
|
|
1765
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
1766
|
+
|
|
1767
|
+
const {query, orgId} = params;
|
|
1768
|
+
const apiCall = self._client
|
|
1769
|
+
.put(`/organizations/${orgname}/users/tasks/${taskId}/claim`, self._setHeader(session));
|
|
1770
|
+
|
|
1771
|
+
return self._returnData(await apiCall);
|
|
1772
|
+
} catch (ex) {
|
|
1773
|
+
throw ex;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1603
1776
|
}
|
|
1604
1777
|
|
|
1605
1778
|
/**
|
|
@@ -1615,6 +1788,7 @@ class Task {
|
|
|
1615
1788
|
const self = this;
|
|
1616
1789
|
self.parent = options.parent;
|
|
1617
1790
|
self._client = self.parent.dispatch.getClient();
|
|
1791
|
+
self.available = new TaskAvailable(options);
|
|
1618
1792
|
}
|
|
1619
1793
|
|
|
1620
1794
|
/**
|
|
@@ -9792,6 +9966,30 @@ class AdminNotification {
|
|
|
9792
9966
|
};
|
|
9793
9967
|
}
|
|
9794
9968
|
|
|
9969
|
+
/**
|
|
9970
|
+
* @description Send real time notification
|
|
9971
|
+
* @param {object} params Params to send notification
|
|
9972
|
+
* @param {string} params.userIds Users to send notification
|
|
9973
|
+
* @param {object} params.message Object with data to send user
|
|
9974
|
+
* @param {object} session Session, token JWT
|
|
9975
|
+
* @returns {Promise<*>}
|
|
9976
|
+
*/
|
|
9977
|
+
async realTime(params, session) {
|
|
9978
|
+
const self = this;
|
|
9979
|
+
|
|
9980
|
+
try {
|
|
9981
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Object with params to add notifications');
|
|
9982
|
+
Joi__default["default"].assert(params.userIds, Joi__default["default"].array().required(), 'OrgId of the user SU');
|
|
9983
|
+
Joi__default["default"].assert(params.message, Joi__default["default"].object().required(), 'Object with data to send user');
|
|
9984
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session, token JWT');
|
|
9985
|
+
|
|
9986
|
+
const apiCall = self.client.post(`/admin/send/notifications`, params, self._setHeader(session));
|
|
9987
|
+
return self._returnData(await apiCall);
|
|
9988
|
+
} catch (ex) {
|
|
9989
|
+
throw ex;
|
|
9990
|
+
}
|
|
9991
|
+
}
|
|
9992
|
+
|
|
9795
9993
|
/**
|
|
9796
9994
|
* @author CloudBrasil <abernardo.br@gmail.com>
|
|
9797
9995
|
* @description Create notification
|