@stackfactor/client-api 1.0.1 → 1.0.2
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 +196 -196
- 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 +6 -6
- 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 +33 -43
- 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
|
|
|
@@ -10,207 +10,207 @@ let instance = axios.create({
|
|
|
10
10
|
/**
|
|
11
11
|
* Server response type
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
13
|
+
module.exports = {
|
|
14
|
+
responseType: {
|
|
15
|
+
/**
|
|
16
|
+
* The requested resource corresponds to any one of a set of representations, each with its own specific location.
|
|
17
|
+
*/
|
|
18
|
+
MULTIPLE_CHOICES: 300,
|
|
19
|
+
/**
|
|
20
|
+
* The resource has moved permanently. Please refer to the documentation.
|
|
21
|
+
*/
|
|
22
|
+
MOVED_PERMANENTLY: 301,
|
|
23
|
+
/**
|
|
24
|
+
* The resource has moved temporarily. Please refer to the documentation.
|
|
25
|
+
*/
|
|
26
|
+
FOUND: 302,
|
|
27
|
+
/**
|
|
28
|
+
* The resource can be found under a different URI.
|
|
29
|
+
*/
|
|
30
|
+
SEE_OTHER: 303,
|
|
31
|
+
/**
|
|
32
|
+
* The resource is available and not modified.
|
|
33
|
+
*/
|
|
34
|
+
NOT_MODIFIED: 304,
|
|
35
|
+
/**
|
|
36
|
+
* The requested resource must be accessed through the proxy given by the Location field.
|
|
37
|
+
*/
|
|
38
|
+
USE_PROXY: 305,
|
|
39
|
+
/**
|
|
40
|
+
* The resource resides temporarily under a different URI.
|
|
41
|
+
*/
|
|
42
|
+
TEMPORARY_REDIRECT: 307,
|
|
43
|
+
/**
|
|
44
|
+
* Invalid syntax for this request was provided.
|
|
45
|
+
*/
|
|
46
|
+
BAD_REQUEST: 400,
|
|
47
|
+
/**
|
|
48
|
+
* You are unauthorized to access the requested resource. Please log in.
|
|
49
|
+
*/
|
|
50
|
+
UNAUTHORIZED: 401,
|
|
51
|
+
/**
|
|
52
|
+
* Your account is not authorized to access the requested resource.
|
|
53
|
+
*/
|
|
54
|
+
FORBIDDEN: 403,
|
|
55
|
+
/**
|
|
56
|
+
* We could not find the resource you requested. Please refer to the documentation for the list of resources.
|
|
57
|
+
*/
|
|
58
|
+
NOT_FOUND: 404,
|
|
59
|
+
/**
|
|
60
|
+
* This method type is not currently supported.
|
|
61
|
+
*/
|
|
62
|
+
METHOD_NOT_ALLOWED: 405,
|
|
63
|
+
/**
|
|
64
|
+
* Acceptance header is invalid for this endpoint resource.
|
|
65
|
+
*/
|
|
66
|
+
NOT_ACCEPTABLE: 406,
|
|
67
|
+
/**
|
|
68
|
+
* Authentication with proxy is required.
|
|
69
|
+
*/
|
|
70
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
71
|
+
/**
|
|
72
|
+
* Client did not produce a request within the time that the server was prepared to wait.
|
|
73
|
+
*/
|
|
74
|
+
REQUEST_TIMEOUT: 408,
|
|
75
|
+
/**
|
|
76
|
+
* The request could not be completed due to a conflict with the current state of the resource.
|
|
77
|
+
*/
|
|
78
|
+
CONFLICT: 409,
|
|
79
|
+
/**
|
|
80
|
+
* The requested resource is no longer available and has been permanently removed.
|
|
81
|
+
*/
|
|
82
|
+
GONE: 410,
|
|
83
|
+
/**
|
|
84
|
+
* Length of the content is required, please include it with the request.
|
|
85
|
+
*/
|
|
86
|
+
LENGTH_REQUIRED: 411,
|
|
87
|
+
/**
|
|
88
|
+
* The request did not match the pre-conditions of the requested resource.
|
|
89
|
+
*/
|
|
90
|
+
PRECONDITION_FAILED: 412,
|
|
91
|
+
/**
|
|
92
|
+
* The request entity is larger than the server is willing or able to process.
|
|
93
|
+
*/
|
|
94
|
+
REQUEST_ENTITY_TOO_LARGE: 413,
|
|
95
|
+
/**
|
|
96
|
+
* The request URI is longer than the server is willing to interpret.
|
|
97
|
+
*/
|
|
98
|
+
REQUEST_URI_TOO_LONG: 414,
|
|
99
|
+
/**
|
|
100
|
+
* The requested resource does not support the media type provided.
|
|
101
|
+
*/
|
|
102
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
103
|
+
/**
|
|
104
|
+
* The requested range for the resource is not available.
|
|
105
|
+
*/
|
|
106
|
+
REQUESTED_RANGE_NOT_SATISFIABLE: 416,
|
|
107
|
+
/**
|
|
108
|
+
* Unable to meet the expectation given in the Expect request header.
|
|
109
|
+
*/
|
|
110
|
+
EXPECTATION_FAILED: 417,
|
|
111
|
+
/**
|
|
112
|
+
* The requested resource is missing required arguments.
|
|
113
|
+
*/
|
|
114
|
+
MISSING_ARGUMENTS: 419,
|
|
115
|
+
/**
|
|
116
|
+
* The requested resource does not support one or more of the given parameters.
|
|
117
|
+
*/
|
|
118
|
+
INVALID_ARGUMENTS: 420,
|
|
119
|
+
/**
|
|
120
|
+
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
121
|
+
*/
|
|
122
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
123
|
+
/**
|
|
124
|
+
* Unexpected internal server error.
|
|
125
|
+
*/
|
|
126
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
127
|
+
/**
|
|
128
|
+
* The requested resource is recognized but not implemented.
|
|
129
|
+
*/
|
|
130
|
+
NOT_IMPLEMENTED: 501,
|
|
131
|
+
/**
|
|
132
|
+
* Invalid response received when acting as a proxy or gateway.
|
|
133
|
+
*/
|
|
134
|
+
BAD_GATEWAY: 502,
|
|
135
|
+
/**
|
|
136
|
+
* The server is currently unavailable.
|
|
137
|
+
*/
|
|
138
|
+
SERVICE_UNAVAILABLE: 503,
|
|
139
|
+
/**
|
|
140
|
+
* Did not receive a timely response from upstream server while acting as a gateway or proxy.
|
|
141
|
+
*/
|
|
142
|
+
GATEWAY_TIMEOUT: 504,
|
|
143
|
+
/**
|
|
144
|
+
* The HTTP protocol version used in the request message is not supported.
|
|
145
|
+
*/
|
|
146
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
147
|
+
/**
|
|
148
|
+
* A failure occurred during initialization of services. API will be unavailable.
|
|
149
|
+
*/
|
|
150
|
+
INITIALIZATION_FAILURE: 550,
|
|
151
|
+
},
|
|
152
|
+
|
|
134
153
|
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
154
|
+
* Returns the error as a string
|
|
155
|
+
* @param {Object} error
|
|
156
|
+
*/
|
|
157
|
+
errorToString: (error) => {
|
|
158
|
+
if (error != null) {
|
|
159
|
+
if (error?.response?.data) {
|
|
160
|
+
let asString = "";
|
|
161
|
+
if (Array.isArray(error.response.data.errors)) {
|
|
162
|
+
error.response.data.errors.forEach((item, index) => {
|
|
163
|
+
asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
|
|
164
|
+
item.param
|
|
165
|
+
} ${item.value ? `value ${item.value.toString()}` : ""}`;
|
|
166
|
+
});
|
|
167
|
+
return asString;
|
|
168
|
+
} else if (error.response.data.error) {
|
|
169
|
+
return error.response.data.error.toString();
|
|
170
|
+
} else if (error.response.statusText) {
|
|
171
|
+
return error.response.statusText.toString();
|
|
172
|
+
} else {
|
|
173
|
+
return error.response.data.toString();
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
return error.message ? error.message : JSON.stringify(error.toString());
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
|
|
138
181
|
/**
|
|
139
|
-
*
|
|
182
|
+
* Returns the code of the error as a number
|
|
183
|
+
* @param {Object} error
|
|
184
|
+
* @returns {Number} The error code
|
|
140
185
|
*/
|
|
141
|
-
|
|
186
|
+
getErrorType: (error) => {
|
|
187
|
+
if (error?.response?.status) {
|
|
188
|
+
return error.response.status;
|
|
189
|
+
} else return responseType.SERVICE_UNAVAILABLE;
|
|
190
|
+
},
|
|
191
|
+
|
|
142
192
|
/**
|
|
143
|
-
*
|
|
193
|
+
* Return the error information to include just the status and the message
|
|
194
|
+
* @param {*} error
|
|
195
|
+
* @returns Object
|
|
144
196
|
*/
|
|
145
|
-
|
|
197
|
+
getErrorInformation: (error) => {
|
|
198
|
+
return {
|
|
199
|
+
status: getErrorType(error),
|
|
200
|
+
message: errorToString(error),
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
|
|
146
204
|
/**
|
|
147
|
-
*
|
|
205
|
+
* Returns true if an exception should be handled to the business and presentation layer
|
|
206
|
+
* @param {*} returnAllExceptions - If set true all exceptions will be passed
|
|
207
|
+
* @param {*} error - The error returned by the server
|
|
148
208
|
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Returns the error as a string
|
|
154
|
-
* @param {Object} error
|
|
155
|
-
*/
|
|
156
|
-
export const errorToString = (error) => {
|
|
157
|
-
if (error != null) {
|
|
158
|
-
if (error?.response?.data) {
|
|
159
|
-
let asString = "";
|
|
160
|
-
if (Array.isArray(error.response.data.errors)) {
|
|
161
|
-
error.response.data.errors.forEach((item, index) => {
|
|
162
|
-
asString += `${index > 0 ? ", " : ""} ${item.msg} param ${
|
|
163
|
-
item.param
|
|
164
|
-
} ${item.value ? `value ${item.value.toString()}` : ""}`;
|
|
165
|
-
});
|
|
166
|
-
return asString;
|
|
167
|
-
} else if (error.response.data.error) {
|
|
168
|
-
return error.response.data.error.toString();
|
|
169
|
-
} else if (error.response.statusText) {
|
|
170
|
-
return error.response.statusText.toString();
|
|
171
|
-
} else {
|
|
172
|
-
return error.response.data.toString();
|
|
173
|
-
}
|
|
209
|
+
shouldReturnError: (returnAllExceptions, error) => {
|
|
210
|
+
if (getErrorType(error) === responseType.UNAUTHORIZED) {
|
|
211
|
+
return returnAllExceptions;
|
|
174
212
|
} else {
|
|
175
|
-
return
|
|
213
|
+
return true;
|
|
176
214
|
}
|
|
177
|
-
}
|
|
215
|
+
},
|
|
178
216
|
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Returns the code of the error as a number
|
|
182
|
-
* @param {Object} error
|
|
183
|
-
* @returns {Number} The error code
|
|
184
|
-
*/
|
|
185
|
-
export const getErrorType = (error) => {
|
|
186
|
-
if (error?.response?.status) {
|
|
187
|
-
return error.response.status;
|
|
188
|
-
} else return responseType.SERVICE_UNAVAILABLE;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Return the error information to include just the status and the message
|
|
193
|
-
* @param {*} error
|
|
194
|
-
* @returns Object
|
|
195
|
-
*/
|
|
196
|
-
export const getErrorInformation = (error) => {
|
|
197
|
-
return {
|
|
198
|
-
status: getErrorType(error),
|
|
199
|
-
message: errorToString(error),
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
|
|
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
|
-
};
|
|
215
|
-
|
|
216
|
-
export default instance;
|
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 },
|