@stackfactor/client-api 1.0.1 → 1.0.3
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/index.js +22 -22
- package/lib/actionNotifications.js +16 -19
- package/lib/address.js +3 -3
- package/lib/axios.js +66 -62
- package/lib/config.js +5 -12
- package/lib/dashboard.js +5 -5
- package/lib/departmentTrainingPlans.js +9 -9
- package/lib/groups.js +19 -23
- package/lib/integration.js +24 -20
- package/lib/integrationConfiguration.js +5 -5
- package/lib/integrations/contentgenerator.js +4 -5
- package/lib/logger.js +6 -6
- package/lib/role.js +14 -14
- package/lib/roleTemplate.js +11 -11
- package/lib/skill.js +16 -17
- package/lib/skillAssessmentTestingSession.js +7 -7
- package/lib/skillAssessments.js +7 -7
- package/lib/skillTemplate.js +11 -11
- package/lib/teams.js +15 -18
- package/lib/templateDocument.js +6 -14
- package/lib/templatePhase.js +5 -13
- package/lib/templateRelease.js +4 -10
- package/lib/templates.js +8 -19
- package/lib/tenants.js +4 -7
- package/lib/trainingPlanTemplate.js +10 -10
- package/lib/trainingPlans.js +12 -12
- package/lib/userInformation.js +4 -4
- package/lib/users.js +34 -44
- package/lib/utils.js +1 -5
- package/package.json +9 -2
package/index.js
CHANGED
|
@@ -22,26 +22,26 @@ const userInformation = require("./lib/userInformation");
|
|
|
22
22
|
const users = require("./lib/users");
|
|
23
23
|
|
|
24
24
|
module.exports = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
actionNotifications,
|
|
26
|
+
address,
|
|
27
|
+
config,
|
|
28
|
+
integration,
|
|
29
|
+
integrationsConfiguration,
|
|
30
|
+
departmentTraiingPlans,
|
|
31
|
+
groups,
|
|
32
|
+
role,
|
|
33
|
+
roleTemplate,
|
|
34
|
+
skill,
|
|
35
|
+
skillAssessments,
|
|
36
|
+
skillTemplate,
|
|
37
|
+
teams,
|
|
38
|
+
templateDocument,
|
|
39
|
+
templatePhase,
|
|
40
|
+
templateRelease,
|
|
41
|
+
templates,
|
|
42
|
+
tenants,
|
|
43
|
+
trainingPlanTemplate,
|
|
44
|
+
trainingPlans,
|
|
45
|
+
userInformation,
|
|
46
|
+
users,
|
|
47
47
|
};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
// Notification sepcific requests
|
|
3
|
-
//
|
|
4
|
-
import axios from "./axios";
|
|
1
|
+
const { axios } = require("./axios");
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
module.exports = {
|
|
7
4
|
axios: axios,
|
|
8
5
|
|
|
9
6
|
/**
|
|
10
7
|
* Get all permissions
|
|
11
8
|
* @param {String} authToken The authentication token
|
|
12
9
|
*/
|
|
13
|
-
getAllUserNotifications(authToken) {
|
|
10
|
+
getAllUserNotifications: (authToken) => {
|
|
14
11
|
return new Promise(function (resolve, reject) {
|
|
15
12
|
const request = axios.get(`api/v1/actionnotifications`, {
|
|
16
13
|
headers: { authorization: authToken },
|
|
@@ -27,11 +24,11 @@ export default {
|
|
|
27
24
|
|
|
28
25
|
/**
|
|
29
26
|
* Mark notifications as open or viewed
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
27
|
+
* @param {Array<String>} ids The id of the notifications to be marked
|
|
28
|
+
* @param {String} status The new status
|
|
29
|
+
* @param {String} authToken The authentication token
|
|
33
30
|
*/
|
|
34
|
-
markNotifications(ids, status, authToken) {
|
|
31
|
+
markNotifications: (ids, status, authToken) => {
|
|
35
32
|
return new Promise(function (resolve, reject) {
|
|
36
33
|
const request = axios.put(
|
|
37
34
|
`api/v1/actionnotifications/mark`,
|
|
@@ -58,7 +55,7 @@ export default {
|
|
|
58
55
|
* @param {String} comment The comment to be saved in the notification
|
|
59
56
|
* @param {String} authToken The authentication token
|
|
60
57
|
*/
|
|
61
|
-
processNotification(id, action, comment, authToken) {
|
|
58
|
+
processNotification: (id, action, comment, authToken) => {
|
|
62
59
|
return new Promise(function (resolve, reject) {
|
|
63
60
|
const request = axios.put(
|
|
64
61
|
`api/v1/actionnotifications/process`,
|
|
@@ -81,9 +78,9 @@ export default {
|
|
|
81
78
|
|
|
82
79
|
/**
|
|
83
80
|
* Get groups for current tenant
|
|
84
|
-
* @param {
|
|
81
|
+
* @param {String} authToken The authentication token
|
|
85
82
|
*/
|
|
86
|
-
getGroups(authToken) {
|
|
83
|
+
getGroups: (authToken) => {
|
|
87
84
|
return new Promise(function (resolve, reject) {
|
|
88
85
|
const request = axios.get(`api/v1/groups/`, {
|
|
89
86
|
headers: { authorization: authToken },
|
|
@@ -100,9 +97,9 @@ export default {
|
|
|
100
97
|
|
|
101
98
|
/**
|
|
102
99
|
* Get current user permissions
|
|
103
|
-
* @param {
|
|
100
|
+
* @param {String} authToken The authentication token
|
|
104
101
|
*/
|
|
105
|
-
getUserPermissions(authToken) {
|
|
102
|
+
getUserPermissions: (authToken) => {
|
|
106
103
|
return new Promise(function (resolve, reject) {
|
|
107
104
|
const request = axios.get(`api/v1/groups/users/getuserpermissions`, {
|
|
108
105
|
headers: { authorization: authToken },
|
|
@@ -143,7 +140,7 @@ export default {
|
|
|
143
140
|
* @param {Array<String>} permissions The permissions to be removed from the group
|
|
144
141
|
* @param {String} authToken The authentication token
|
|
145
142
|
*/
|
|
146
|
-
removePermissionsFromGroup(groupId, permissions, authToken) {
|
|
143
|
+
removePermissionsFromGroup: (groupId, permissions, authToken) => {
|
|
147
144
|
return new Promise(function (resolve, reject) {
|
|
148
145
|
const request = axios.post(
|
|
149
146
|
`api/v1/groups/permissions/remove/`,
|
|
@@ -169,7 +166,7 @@ export default {
|
|
|
169
166
|
* @param {Array<String>} users The users to be removed from the group
|
|
170
167
|
* @param {String} authToken The authentication token
|
|
171
168
|
*/
|
|
172
|
-
removeUsersFromGroup(groupId, users, authToken) {
|
|
169
|
+
removeUsersFromGroup: (groupId, users, authToken) => {
|
|
173
170
|
return new Promise(function (resolve, reject) {
|
|
174
171
|
const request = axios.post(
|
|
175
172
|
`api/v1/groups/users/remove/`,
|
|
@@ -194,7 +191,7 @@ export default {
|
|
|
194
191
|
* @param {String} groupId The group Id
|
|
195
192
|
* @param {String} authToken The authentication token
|
|
196
193
|
*/
|
|
197
|
-
setDefault(groupId, authToken) {
|
|
194
|
+
setDefault: (groupId, authToken) => {
|
|
198
195
|
return new Promise(function (resolve, reject) {
|
|
199
196
|
const request = axios.put(
|
|
200
197
|
`api/v1/groups/setDefault/`,
|
|
@@ -220,7 +217,7 @@ export default {
|
|
|
220
217
|
* @param {string} description The updated description of the group
|
|
221
218
|
* @param {String} authToken The authentication token
|
|
222
219
|
*/
|
|
223
|
-
updateGroup(groupId, name, description, authToken) {
|
|
220
|
+
updateGroup: (groupId, name, description, authToken) => {
|
|
224
221
|
return new Promise(function (resolve, reject) {
|
|
225
222
|
const request = axios.patch(
|
|
226
223
|
`api/v1/groups/group/`,
|
package/lib/address.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const { axios } = require("./axios");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module.exports = {
|
|
4
4
|
axios: axios,
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
* @param {String} authToken - Authorization token
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
autoComplete(input, authToken) {
|
|
13
|
+
autoComplete: (input, authToken) => {
|
|
14
14
|
return new Promise(function (resolve, reject) {
|
|
15
15
|
const getAddressesRequest = axios.post(
|
|
16
16
|
`api/v1/address/autocomplete/`,
|
package/lib/axios.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
const utils = require("./utils");
|
|
3
3
|
|
|
4
4
|
const baseUrl = utils.getBaseUrl();
|
|
5
5
|
|
|
@@ -7,10 +7,7 @@ let instance = axios.create({
|
|
|
7
7
|
baseURL: baseUrl,
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
* Server response type
|
|
12
|
-
*/
|
|
13
|
-
export const responseType = {
|
|
10
|
+
const responseType = {
|
|
14
11
|
/**
|
|
15
12
|
* The requested resource corresponds to any one of a set of representations, each with its own specific location.
|
|
16
13
|
*/
|
|
@@ -150,67 +147,74 @@ export const responseType = {
|
|
|
150
147
|
};
|
|
151
148
|
|
|
152
149
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @param {Object} error
|
|
150
|
+
* Server response type
|
|
155
151
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
module.exports = {
|
|
153
|
+
axios: instance,
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns the error as a string
|
|
157
|
+
* @param {Object} error
|
|
158
|
+
*/
|
|
159
|
+
errorToString: (error) => {
|
|
160
|
+
if (error != null) {
|
|
161
|
+
if (error?.response?.data) {
|
|
162
|
+
let asString = "";
|
|
163
|
+
if (Array.isArray(error.response.data.errors)) {
|
|
164
|
+
error.response.data.errors.forEach((item, index) => {
|
|
165
|
+
asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
|
|
166
|
+
item.param
|
|
167
|
+
} ${item.value ? `value ${item.value.toString()}` : ""}`;
|
|
168
|
+
});
|
|
169
|
+
return asString;
|
|
170
|
+
} else if (error.response.data.error) {
|
|
171
|
+
return error.response.data.error.toString();
|
|
172
|
+
} else if (error.response.statusText) {
|
|
173
|
+
return error.response.statusText.toString();
|
|
174
|
+
} else {
|
|
175
|
+
return error.response.data.toString();
|
|
176
|
+
}
|
|
171
177
|
} else {
|
|
172
|
-
return error.
|
|
178
|
+
return error.message ? error.message : JSON.stringify(error.toString());
|
|
173
179
|
}
|
|
174
|
-
} else {
|
|
175
|
-
return error.message ? error.message : error.toString();
|
|
176
180
|
}
|
|
177
|
-
}
|
|
178
|
-
};
|
|
181
|
+
},
|
|
179
182
|
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
183
|
+
/**
|
|
184
|
+
* Returns the code of the error as a number
|
|
185
|
+
* @param {Object} error
|
|
186
|
+
* @returns {Number} The error code
|
|
187
|
+
*/
|
|
188
|
+
getErrorType: (error) => {
|
|
189
|
+
if (error?.response?.status) {
|
|
190
|
+
return error.response.status;
|
|
191
|
+
} else return responseType.SERVICE_UNAVAILABLE;
|
|
192
|
+
},
|
|
190
193
|
|
|
191
|
-
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
194
|
+
/**
|
|
195
|
+
* Return the error information to include just the status and the message
|
|
196
|
+
* @param {*} error
|
|
197
|
+
* @returns Object
|
|
198
|
+
*/
|
|
199
|
+
getErrorInformation: (error) => {
|
|
200
|
+
return {
|
|
201
|
+
status: getErrorType(error),
|
|
202
|
+
message: errorToString(error),
|
|
203
|
+
};
|
|
204
|
+
},
|
|
202
205
|
|
|
203
|
-
|
|
204
|
-
* Returns true if an exception should be handled to the business and presentation layer
|
|
205
|
-
* @param {*} returnAllExceptions - If set true all exceptions will be passed
|
|
206
|
-
* @param {*} error - The error returned by the server
|
|
207
|
-
*/
|
|
208
|
-
export const shouldReturnError = (returnAllExceptions, error) => {
|
|
209
|
-
if (getErrorType(error) === responseType.UNAUTHORIZED) {
|
|
210
|
-
return returnAllExceptions;
|
|
211
|
-
} else {
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
206
|
+
responseType: responseType,
|
|
215
207
|
|
|
216
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Returns true if an exception should be handled to the business and presentation layer
|
|
210
|
+
* @param {*} returnAllExceptions - If set true all exceptions will be passed
|
|
211
|
+
* @param {*} error - The error returned by the server
|
|
212
|
+
*/
|
|
213
|
+
shouldReturnError: (returnAllExceptions, error) => {
|
|
214
|
+
if (getErrorType(error) === responseType.UNAUTHORIZED) {
|
|
215
|
+
return returnAllExceptions;
|
|
216
|
+
} else {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
};
|
package/lib/config.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
const { axios } = require("./axios");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module.exports = {
|
|
4
4
|
axios: axios,
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the specified configuration by Id. It returns a promise
|
|
8
|
-
*
|
|
9
8
|
* @param {String} id - the id of the configuration element
|
|
10
9
|
* @param {String} authToken - Authorization token
|
|
11
|
-
*
|
|
12
10
|
*/
|
|
13
|
-
getConfigurationById(id, authToken) {
|
|
11
|
+
getConfigurationById: (id, authToken) => {
|
|
14
12
|
return new Promise(function (resolve, reject) {
|
|
15
13
|
const getConfigInformationRequest = axios.get(
|
|
16
14
|
`api/v1/configurations/configuration/id/${id}`,
|
|
@@ -28,12 +26,10 @@ export default {
|
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Get the specified configuration by type. It returns a promise
|
|
31
|
-
*
|
|
32
29
|
* @param {String} type - the id of the configuration element
|
|
33
30
|
* @param {String} authToken - Authorization token
|
|
34
|
-
*
|
|
35
31
|
*/
|
|
36
|
-
getConfigurationByType(type, authToken) {
|
|
32
|
+
getConfigurationByType: (type, authToken) => {
|
|
37
33
|
return new Promise(function (resolve, reject) {
|
|
38
34
|
const getConfigInformationRequest = axios.get(
|
|
39
35
|
`api/v1/configurations/configuration/type/${type}`,
|
|
@@ -50,15 +46,12 @@ export default {
|
|
|
50
46
|
},
|
|
51
47
|
|
|
52
48
|
/**
|
|
53
|
-
*
|
|
54
49
|
* Set the specified configuration by Id. It returns a promise
|
|
55
|
-
*
|
|
56
50
|
* @param {String} id - the id of the configuration element
|
|
57
51
|
* @param {Object} data - the object containing the updated configuration element
|
|
58
52
|
* @param {String} authToken - Authorization token
|
|
59
|
-
*
|
|
60
53
|
*/
|
|
61
|
-
setConfigurationById(id, data, authToken) {
|
|
54
|
+
setConfigurationById: (id, data, authToken) => {
|
|
62
55
|
return new Promise(function (resolve, reject) {
|
|
63
56
|
const getConfigInformationRequest = axios.post(
|
|
64
57
|
`api/v1/configurations/configuration/${id}`,
|
package/lib/dashboard.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const { axios } = require("./axios");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module.exports = {
|
|
4
4
|
axios: axios,
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
* @param {Object} data - The card settings data
|
|
11
11
|
* @param {String} authToken - Authorization token
|
|
12
12
|
*/
|
|
13
|
-
addCardToDashboard(id, position, data, authToken) {
|
|
13
|
+
addCardToDashboard: (id, position, data, authToken) => {
|
|
14
14
|
return new Promise(function (resolve, reject) {
|
|
15
15
|
const request = axios.put(
|
|
16
16
|
`/api/v1/dashboard/card`,
|
|
@@ -35,7 +35,7 @@ export default {
|
|
|
35
35
|
* Get the list of the cards from the dashboard
|
|
36
36
|
* @param {String} authToken - Authorization token
|
|
37
37
|
*/
|
|
38
|
-
getDashboardCardsList(authToken) {
|
|
38
|
+
getDashboardCardsList: (authToken) => {
|
|
39
39
|
return new Promise(function (resolve, reject) {
|
|
40
40
|
const request = axios.get(`/api/v1/dashboard/card`, {
|
|
41
41
|
headers: { authorization: authToken },
|
|
@@ -55,7 +55,7 @@ export default {
|
|
|
55
55
|
* @param {String} id - the id of the configuration element
|
|
56
56
|
* @param {String} authToken - Authorization token
|
|
57
57
|
*/
|
|
58
|
-
removeCardFromDashboard(id, authToken) {
|
|
58
|
+
removeCardFromDashboard: (id, authToken) => {
|
|
59
59
|
return new Promise(function (resolve, reject) {
|
|
60
60
|
const request = axios.delete(`/api/v1/dashboard/card`, {
|
|
61
61
|
headers: { authorization: authToken },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const { axios } = require("./axios");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module.exports = {
|
|
4
4
|
axios: axios,
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
* @param {Array<Object>} activities
|
|
11
11
|
* @param {String} token Authorization token
|
|
12
12
|
*/
|
|
13
|
-
createDepartmentTrainingPlan(name, summary, skill, activities, token) {
|
|
13
|
+
createDepartmentTrainingPlan: (name, summary, skill, activities, token) => {
|
|
14
14
|
return new Promise(function (resolve, reject) {
|
|
15
15
|
const requestData = {
|
|
16
16
|
name: name ? name : "",
|
|
@@ -40,7 +40,7 @@ export default {
|
|
|
40
40
|
* @param {String} id The id of the template to be deleted
|
|
41
41
|
* @param {String} token Authorization token
|
|
42
42
|
*/
|
|
43
|
-
deleteDepartmentTrainingPlan(id, token) {
|
|
43
|
+
deleteDepartmentTrainingPlan: (id, token) => {
|
|
44
44
|
return new Promise(function (resolve, reject) {
|
|
45
45
|
const request = axios.delete(`api/v1/departmenttrainingplans/`, {
|
|
46
46
|
headers: { authorization: token },
|
|
@@ -60,10 +60,10 @@ export default {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Get department traing plan information
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {Number} id The id of the plan
|
|
64
64
|
* @param {String} token Authorization token
|
|
65
65
|
*/
|
|
66
|
-
getDepartmentTrainingPlanInformationById(id, version, token) {
|
|
66
|
+
getDepartmentTrainingPlanInformationById: (id, version, token) => {
|
|
67
67
|
return new Promise(function (resolve, reject) {
|
|
68
68
|
let confirmationRequest = axios.get(
|
|
69
69
|
`api/v1/departmenttrainingplans/${id}/${version}`,
|
|
@@ -86,7 +86,7 @@ export default {
|
|
|
86
86
|
* @param {Object} filter The filter used to select the plan
|
|
87
87
|
* @param {String} token Authorization token
|
|
88
88
|
*/
|
|
89
|
-
getDepartmentTrainingPlanList(filter, version, token) {
|
|
89
|
+
getDepartmentTrainingPlanList: (filter, version, token) => {
|
|
90
90
|
return new Promise(function (resolve, reject) {
|
|
91
91
|
const requestData = {
|
|
92
92
|
filter: filter ? filter : "",
|
|
@@ -114,7 +114,7 @@ export default {
|
|
|
114
114
|
* @param {number} id The id of the plan to be published
|
|
115
115
|
* @param {String} token Authorization token
|
|
116
116
|
*/
|
|
117
|
-
publishDepartmentTrainingPlan(id, token) {
|
|
117
|
+
publishDepartmentTrainingPlan: (id, token) => {
|
|
118
118
|
return new Promise(function (resolve, reject) {
|
|
119
119
|
let confirmationRequest = axios.post(
|
|
120
120
|
`api/v1/departmenttrainingplans/publish/${id}`,
|
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
* @param {Object} data Data used to update the plan
|
|
140
140
|
* @param {String} token Authorization token
|
|
141
141
|
*/
|
|
142
|
-
setDepartmentTrainingPlanInformation(id, data, token) {
|
|
142
|
+
setDepartmentTrainingPlanInformation: (id, data, token) => {
|
|
143
143
|
return new Promise(function (resolve, reject) {
|
|
144
144
|
const requestData = {
|
|
145
145
|
data: data,
|
package/lib/groups.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
// Group sepcific requests
|
|
3
|
-
//
|
|
4
|
-
import axios from "./axios";
|
|
1
|
+
const { axios } = require("./axios");
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
module.exports = {
|
|
7
4
|
axios: axios,
|
|
8
5
|
|
|
9
6
|
/**
|
|
@@ -12,7 +9,7 @@ export default {
|
|
|
12
9
|
* @param {Array<String>} permissions The permissions to be added
|
|
13
10
|
* @param {String} authToken - Authentication token
|
|
14
11
|
*/
|
|
15
|
-
addPermissionsToGroup(groupId, permissions, authToken) {
|
|
12
|
+
addPermissionsToGroup: (groupId, permissions, authToken) => {
|
|
16
13
|
return new Promise(function (resolve, reject) {
|
|
17
14
|
const request = axios.post(
|
|
18
15
|
`api/v1/groups/permissions/add`,
|
|
@@ -38,7 +35,7 @@ export default {
|
|
|
38
35
|
* @param {Array<String>} users The users to be added
|
|
39
36
|
* @param {String} authToken - Authentication token
|
|
40
37
|
*/
|
|
41
|
-
addUsersToGroup(groupId, users, authToken) {
|
|
38
|
+
addUsersToGroup: (groupId, users, authToken) => {
|
|
42
39
|
return new Promise(function (resolve, reject) {
|
|
43
40
|
const request = axios.post(
|
|
44
41
|
`api/v1/groups/users/add`,
|
|
@@ -64,7 +61,7 @@ export default {
|
|
|
64
61
|
* @param {String} description The description of the group
|
|
65
62
|
* @param {String} authToken The authorization token
|
|
66
63
|
*/
|
|
67
|
-
createGroup(name, description, authToken) {
|
|
64
|
+
createGroup: (name, description, authToken) => {
|
|
68
65
|
return new Promise(function (resolve, reject) {
|
|
69
66
|
const request = axios.post(
|
|
70
67
|
`api/v1/groups/group`,
|
|
@@ -90,7 +87,7 @@ export default {
|
|
|
90
87
|
* @param {String} defaultGroupId The default group all the users will be moved to
|
|
91
88
|
* @param {String} authToken The authentication token
|
|
92
89
|
*/
|
|
93
|
-
deleteGroup(groupId, defaultGroupId, authToken) {
|
|
90
|
+
deleteGroup: (groupId, defaultGroupId, authToken) => {
|
|
94
91
|
return new Promise(function (resolve, reject) {
|
|
95
92
|
const request = axios.delete(`api/v1/groups/delete`, {
|
|
96
93
|
headers: { authorization: authToken },
|
|
@@ -111,10 +108,9 @@ export default {
|
|
|
111
108
|
|
|
112
109
|
/**
|
|
113
110
|
* Get all permissions
|
|
114
|
-
*
|
|
115
111
|
* @param {String} authToken The authentication token
|
|
116
112
|
*/
|
|
117
|
-
getAllPermissions(authToken) {
|
|
113
|
+
getAllPermissions: (authToken) => {
|
|
118
114
|
return new Promise(function (resolve, reject) {
|
|
119
115
|
const request = axios.get(`api/v1/groups/permissions/getAllPermissions`, {
|
|
120
116
|
headers: { authorization: authToken },
|
|
@@ -131,10 +127,10 @@ export default {
|
|
|
131
127
|
|
|
132
128
|
/**
|
|
133
129
|
* Get group by Id
|
|
134
|
-
* @param {
|
|
130
|
+
* @param {String} groupId The group Id
|
|
135
131
|
* @param {String} authToken The authentication token
|
|
136
132
|
*/
|
|
137
|
-
getGroupById(groupId, authToken) {
|
|
133
|
+
getGroupById: (groupId, authToken) => {
|
|
138
134
|
return new Promise(function (resolve, reject) {
|
|
139
135
|
const request = axios.get(`api/v1/groups/group/${groupId}`, {
|
|
140
136
|
headers: { authorization: authToken },
|
|
@@ -151,9 +147,9 @@ export default {
|
|
|
151
147
|
|
|
152
148
|
/**
|
|
153
149
|
* Get groups for current tenant
|
|
154
|
-
* @param {
|
|
150
|
+
* @param {String} authToken The authentication token
|
|
155
151
|
*/
|
|
156
|
-
getGroups(authToken) {
|
|
152
|
+
getGroups: (authToken) => {
|
|
157
153
|
return new Promise(function (resolve, reject) {
|
|
158
154
|
const request = axios.get(`api/v1/groups/`, {
|
|
159
155
|
headers: { authorization: authToken },
|
|
@@ -170,9 +166,9 @@ export default {
|
|
|
170
166
|
|
|
171
167
|
/**
|
|
172
168
|
* Get current user permissions
|
|
173
|
-
* @param {
|
|
169
|
+
* @param {String} authToken The authentication token
|
|
174
170
|
*/
|
|
175
|
-
getUserPermissions(authToken) {
|
|
171
|
+
getUserPermissions: (authToken) => {
|
|
176
172
|
return new Promise(function (resolve, reject) {
|
|
177
173
|
const request = axios.get(`api/v1/groups/users/getuserpermissions`, {
|
|
178
174
|
headers: { authorization: authToken },
|
|
@@ -214,7 +210,7 @@ export default {
|
|
|
214
210
|
* @param {Array<String>} permissions The permissions to be removed from the group
|
|
215
211
|
* @param {String} authToken The authentication token
|
|
216
212
|
*/
|
|
217
|
-
removePermissionsFromGroup(groupId, permissions, authToken) {
|
|
213
|
+
removePermissionsFromGroup: (groupId, permissions, authToken) => {
|
|
218
214
|
return new Promise(function (resolve, reject) {
|
|
219
215
|
const request = axios.post(
|
|
220
216
|
`api/v1/groups/permissions/remove/`,
|
|
@@ -240,7 +236,7 @@ export default {
|
|
|
240
236
|
* @param {Array<String>} users The users to be removed from the group
|
|
241
237
|
* @param {String} authToken The authentication token
|
|
242
238
|
*/
|
|
243
|
-
removeUsersFromGroup(groupId, users, authToken) {
|
|
239
|
+
removeUsersFromGroup: (groupId, users, authToken) => {
|
|
244
240
|
return new Promise(function (resolve, reject) {
|
|
245
241
|
const request = axios.post(
|
|
246
242
|
`api/v1/groups/users/remove/`,
|
|
@@ -265,7 +261,7 @@ export default {
|
|
|
265
261
|
* @param {String} groupId The group Id
|
|
266
262
|
* @param {String} authToken The authentication token
|
|
267
263
|
*/
|
|
268
|
-
setDefault(groupId, authToken) {
|
|
264
|
+
setDefault: (groupId, authToken) => {
|
|
269
265
|
return new Promise(function (resolve, reject) {
|
|
270
266
|
const request = axios.put(
|
|
271
267
|
`api/v1/groups/setDefault/`,
|
|
@@ -287,11 +283,11 @@ export default {
|
|
|
287
283
|
/**
|
|
288
284
|
* Update group
|
|
289
285
|
* @param {String} groupId The group Id
|
|
290
|
-
* @param {
|
|
291
|
-
* @param {
|
|
286
|
+
* @param {String} name The updated name of the group
|
|
287
|
+
* @param {String} description The updated description of the group
|
|
292
288
|
* @param {String} authToken The authentication token
|
|
293
289
|
*/
|
|
294
|
-
updateGroup(groupId, name, description, authToken) {
|
|
290
|
+
updateGroup: (groupId, name, description, authToken) => {
|
|
295
291
|
return new Promise(function (resolve, reject) {
|
|
296
292
|
const request = axios.patch(
|
|
297
293
|
`api/v1/groups/group/`,
|