@stackfactor/client-api 1.0.0
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/LICENSE +201 -0
- package/index.js +22 -0
- package/lib/actionNotifications.js +243 -0
- package/lib/address.js +29 -0
- package/lib/axios.js +216 -0
- package/lib/config.js +77 -0
- package/lib/dashboard.js +75 -0
- package/lib/departmentTrainingPlans.js +163 -0
- package/lib/groups.js +314 -0
- package/lib/integration.js +337 -0
- package/lib/integrationConfiguration.js +94 -0
- package/lib/integrations/contentgenerator.js +79 -0
- package/lib/logger.js +61 -0
- package/lib/role.js +266 -0
- package/lib/roleTemplate.js +243 -0
- package/lib/skill.js +338 -0
- package/lib/skillAssessmentTestingSession.js +143 -0
- package/lib/skillAssessments.js +139 -0
- package/lib/skillTemplate.js +248 -0
- package/lib/teams.js +277 -0
- package/lib/templateDocument.js +131 -0
- package/lib/templatePhase.js +134 -0
- package/lib/templateRelease.js +98 -0
- package/lib/templates.js +159 -0
- package/lib/tenants.js +60 -0
- package/lib/trainingPlanTemplate.js +215 -0
- package/lib/trainingPlans.js +267 -0
- package/lib/userInformation.js +89 -0
- package/lib/users.js +622 -0
- package/lib/utils.js +27 -0
- package/package.json +24 -0
package/lib/axios.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import utils from "./utils";
|
|
3
|
+
|
|
4
|
+
const baseUrl = utils.getBaseUrl();
|
|
5
|
+
|
|
6
|
+
let instance = axios.create({
|
|
7
|
+
baseURL: baseUrl,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Server response type
|
|
12
|
+
*/
|
|
13
|
+
export const responseType = {
|
|
14
|
+
/**
|
|
15
|
+
* The requested resource corresponds to any one of a set of representations, each with its own specific location.
|
|
16
|
+
*/
|
|
17
|
+
MULTIPLE_CHOICES: 300,
|
|
18
|
+
/**
|
|
19
|
+
* The resource has moved permanently. Please refer to the documentation.
|
|
20
|
+
*/
|
|
21
|
+
MOVED_PERMANENTLY: 301,
|
|
22
|
+
/**
|
|
23
|
+
* The resource has moved temporarily. Please refer to the documentation.
|
|
24
|
+
*/
|
|
25
|
+
FOUND: 302,
|
|
26
|
+
/**
|
|
27
|
+
* The resource can be found under a different URI.
|
|
28
|
+
*/
|
|
29
|
+
SEE_OTHER: 303,
|
|
30
|
+
/**
|
|
31
|
+
* The resource is available and not modified.
|
|
32
|
+
*/
|
|
33
|
+
NOT_MODIFIED: 304,
|
|
34
|
+
/**
|
|
35
|
+
* The requested resource must be accessed through the proxy given by the Location field.
|
|
36
|
+
*/
|
|
37
|
+
USE_PROXY: 305,
|
|
38
|
+
/**
|
|
39
|
+
* The resource resides temporarily under a different URI.
|
|
40
|
+
*/
|
|
41
|
+
TEMPORARY_REDIRECT: 307,
|
|
42
|
+
/**
|
|
43
|
+
* Invalid syntax for this request was provided.
|
|
44
|
+
*/
|
|
45
|
+
BAD_REQUEST: 400,
|
|
46
|
+
/**
|
|
47
|
+
* You are unauthorized to access the requested resource. Please log in.
|
|
48
|
+
*/
|
|
49
|
+
UNAUTHORIZED: 401,
|
|
50
|
+
/**
|
|
51
|
+
* Your account is not authorized to access the requested resource.
|
|
52
|
+
*/
|
|
53
|
+
FORBIDDEN: 403,
|
|
54
|
+
/**
|
|
55
|
+
* We could not find the resource you requested. Please refer to the documentation for the list of resources.
|
|
56
|
+
*/
|
|
57
|
+
NOT_FOUND: 404,
|
|
58
|
+
/**
|
|
59
|
+
* This method type is not currently supported.
|
|
60
|
+
*/
|
|
61
|
+
METHOD_NOT_ALLOWED: 405,
|
|
62
|
+
/**
|
|
63
|
+
* Acceptance header is invalid for this endpoint resource.
|
|
64
|
+
*/
|
|
65
|
+
NOT_ACCEPTABLE: 406,
|
|
66
|
+
/**
|
|
67
|
+
* Authentication with proxy is required.
|
|
68
|
+
*/
|
|
69
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
70
|
+
/**
|
|
71
|
+
* Client did not produce a request within the time that the server was prepared to wait.
|
|
72
|
+
*/
|
|
73
|
+
REQUEST_TIMEOUT: 408,
|
|
74
|
+
/**
|
|
75
|
+
* The request could not be completed due to a conflict with the current state of the resource.
|
|
76
|
+
*/
|
|
77
|
+
CONFLICT: 409,
|
|
78
|
+
/**
|
|
79
|
+
* The requested resource is no longer available and has been permanently removed.
|
|
80
|
+
*/
|
|
81
|
+
GONE: 410,
|
|
82
|
+
/**
|
|
83
|
+
* Length of the content is required, please include it with the request.
|
|
84
|
+
*/
|
|
85
|
+
LENGTH_REQUIRED: 411,
|
|
86
|
+
/**
|
|
87
|
+
* The request did not match the pre-conditions of the requested resource.
|
|
88
|
+
*/
|
|
89
|
+
PRECONDITION_FAILED: 412,
|
|
90
|
+
/**
|
|
91
|
+
* The request entity is larger than the server is willing or able to process.
|
|
92
|
+
*/
|
|
93
|
+
REQUEST_ENTITY_TOO_LARGE: 413,
|
|
94
|
+
/**
|
|
95
|
+
* The request URI is longer than the server is willing to interpret.
|
|
96
|
+
*/
|
|
97
|
+
REQUEST_URI_TOO_LONG: 414,
|
|
98
|
+
/**
|
|
99
|
+
* The requested resource does not support the media type provided.
|
|
100
|
+
*/
|
|
101
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
102
|
+
/**
|
|
103
|
+
* The requested range for the resource is not available.
|
|
104
|
+
*/
|
|
105
|
+
REQUESTED_RANGE_NOT_SATISFIABLE: 416,
|
|
106
|
+
/**
|
|
107
|
+
* Unable to meet the expectation given in the Expect request header.
|
|
108
|
+
*/
|
|
109
|
+
EXPECTATION_FAILED: 417,
|
|
110
|
+
/**
|
|
111
|
+
* The requested resource is missing required arguments.
|
|
112
|
+
*/
|
|
113
|
+
MISSING_ARGUMENTS: 419,
|
|
114
|
+
/**
|
|
115
|
+
* The requested resource does not support one or more of the given parameters.
|
|
116
|
+
*/
|
|
117
|
+
INVALID_ARGUMENTS: 420,
|
|
118
|
+
/**
|
|
119
|
+
* The request was well-formed but was unable to be followed due to semantic errors.
|
|
120
|
+
*/
|
|
121
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
122
|
+
/**
|
|
123
|
+
* Unexpected internal server error.
|
|
124
|
+
*/
|
|
125
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
126
|
+
/**
|
|
127
|
+
* The requested resource is recognized but not implemented.
|
|
128
|
+
*/
|
|
129
|
+
NOT_IMPLEMENTED: 501,
|
|
130
|
+
/**
|
|
131
|
+
* Invalid response received when acting as a proxy or gateway.
|
|
132
|
+
*/
|
|
133
|
+
BAD_GATEWAY: 502,
|
|
134
|
+
/**
|
|
135
|
+
* The server is currently unavailable.
|
|
136
|
+
*/
|
|
137
|
+
SERVICE_UNAVAILABLE: 503,
|
|
138
|
+
/**
|
|
139
|
+
* Did not receive a timely response from upstream server while acting as a gateway or proxy.
|
|
140
|
+
*/
|
|
141
|
+
GATEWAY_TIMEOUT: 504,
|
|
142
|
+
/**
|
|
143
|
+
* The HTTP protocol version used in the request message is not supported.
|
|
144
|
+
*/
|
|
145
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
146
|
+
/**
|
|
147
|
+
* A failure occurred during initialization of services. API will be unavailable.
|
|
148
|
+
*/
|
|
149
|
+
INITIALIZATION_FAILURE: 550,
|
|
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
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
return error.message ? error.message : error.toString();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
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
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import axios from "./axios";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
axios: axios,
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get the specified configuration by Id. It returns a promise
|
|
8
|
+
*
|
|
9
|
+
* @param {String} id - the id of the configuration element
|
|
10
|
+
* @param {String} authToken - Authorization token
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
getConfigurationById(id, authToken) {
|
|
14
|
+
return new Promise(function (resolve, reject) {
|
|
15
|
+
const getConfigInformationRequest = axios.get(
|
|
16
|
+
`api/v1/configurations/configuration/id/${id}`,
|
|
17
|
+
{ headers: { authorization: authToken } }
|
|
18
|
+
);
|
|
19
|
+
getConfigInformationRequest
|
|
20
|
+
.then((response) => {
|
|
21
|
+
resolve(response.data);
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
reject(error);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the specified configuration by type. It returns a promise
|
|
31
|
+
*
|
|
32
|
+
* @param {String} type - the id of the configuration element
|
|
33
|
+
* @param {String} authToken - Authorization token
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
getConfigurationByType(type, authToken) {
|
|
37
|
+
return new Promise(function (resolve, reject) {
|
|
38
|
+
const getConfigInformationRequest = axios.get(
|
|
39
|
+
`api/v1/configurations/configuration/type/${type}`,
|
|
40
|
+
{ headers: { authorization: authToken } }
|
|
41
|
+
);
|
|
42
|
+
getConfigInformationRequest
|
|
43
|
+
.then((response) => {
|
|
44
|
+
resolve(response.data);
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
reject(error);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* Set the specified configuration by Id. It returns a promise
|
|
55
|
+
*
|
|
56
|
+
* @param {String} id - the id of the configuration element
|
|
57
|
+
* @param {Object} data - the object containing the updated configuration element
|
|
58
|
+
* @param {String} authToken - Authorization token
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
setConfigurationById(id, data, authToken) {
|
|
62
|
+
return new Promise(function (resolve, reject) {
|
|
63
|
+
const getConfigInformationRequest = axios.post(
|
|
64
|
+
`api/v1/configurations/configuration/${id}`,
|
|
65
|
+
{ data: data },
|
|
66
|
+
{ headers: { authorization: authToken } }
|
|
67
|
+
);
|
|
68
|
+
getConfigInformationRequest
|
|
69
|
+
.then((response) => {
|
|
70
|
+
resolve(response.data);
|
|
71
|
+
})
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
reject(error);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
};
|
package/lib/dashboard.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import axios from "./axios";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
axios: axios,
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Add a card to the dashboard
|
|
8
|
+
* @param {String} id - the id of the card to be added to the dashboard
|
|
9
|
+
* @param {Number} position - The position on the dashboard
|
|
10
|
+
* @param {Object} data - The card settings data
|
|
11
|
+
* @param {String} authToken - Authorization token
|
|
12
|
+
*/
|
|
13
|
+
addCardToDashboard(id, position, data, authToken) {
|
|
14
|
+
return new Promise(function (resolve, reject) {
|
|
15
|
+
const request = axios.put(
|
|
16
|
+
`/api/v1/dashboard/card`,
|
|
17
|
+
{
|
|
18
|
+
id: id,
|
|
19
|
+
position: position,
|
|
20
|
+
data: data ? data : {},
|
|
21
|
+
},
|
|
22
|
+
{ headers: { authorization: authToken } }
|
|
23
|
+
);
|
|
24
|
+
request
|
|
25
|
+
.then((response) => {
|
|
26
|
+
resolve(response.data);
|
|
27
|
+
})
|
|
28
|
+
.catch((error) => {
|
|
29
|
+
reject(error);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the list of the cards from the dashboard
|
|
36
|
+
* @param {String} authToken - Authorization token
|
|
37
|
+
*/
|
|
38
|
+
getDashboardCardsList(authToken) {
|
|
39
|
+
return new Promise(function (resolve, reject) {
|
|
40
|
+
const request = axios.get(`/api/v1/dashboard/card`, {
|
|
41
|
+
headers: { authorization: authToken },
|
|
42
|
+
});
|
|
43
|
+
request
|
|
44
|
+
.then((response) => {
|
|
45
|
+
resolve(response.data);
|
|
46
|
+
})
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
reject(error);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Remove a card from the dashboard
|
|
55
|
+
* @param {String} id - the id of the configuration element
|
|
56
|
+
* @param {String} authToken - Authorization token
|
|
57
|
+
*/
|
|
58
|
+
removeCardFromDashboard(id, authToken) {
|
|
59
|
+
return new Promise(function (resolve, reject) {
|
|
60
|
+
const request = axios.delete(`/api/v1/dashboard/card`, {
|
|
61
|
+
headers: { authorization: authToken },
|
|
62
|
+
data: {
|
|
63
|
+
id: id,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
request
|
|
67
|
+
.then((response) => {
|
|
68
|
+
resolve(response.data);
|
|
69
|
+
})
|
|
70
|
+
.catch((error) => {
|
|
71
|
+
reject(error);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import axios from "./axios";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
axios: axios,
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create training plan template and set information
|
|
8
|
+
* @param {String} name
|
|
9
|
+
* @param {String} summary
|
|
10
|
+
* @param {Array<Object>} activities
|
|
11
|
+
* @param {String} token Authorization token
|
|
12
|
+
*/
|
|
13
|
+
createDepartmentTrainingPlan(name, summary, skill, activities, token) {
|
|
14
|
+
return new Promise(function (resolve, reject) {
|
|
15
|
+
const requestData = {
|
|
16
|
+
name: name ? name : "",
|
|
17
|
+
summary: summary ? summary : "",
|
|
18
|
+
skill: skill ? skill : "",
|
|
19
|
+
activities: activities ? activities : [],
|
|
20
|
+
};
|
|
21
|
+
let confirmationRequest = axios.put(
|
|
22
|
+
"api/v1/departmentTrainingPlans",
|
|
23
|
+
requestData,
|
|
24
|
+
{
|
|
25
|
+
headers: { authorization: token },
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
confirmationRequest
|
|
29
|
+
.then((response) => {
|
|
30
|
+
resolve(response.data);
|
|
31
|
+
})
|
|
32
|
+
.catch((error) => {
|
|
33
|
+
reject(error);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Delete department training plan
|
|
40
|
+
* @param {String} id The id of the template to be deleted
|
|
41
|
+
* @param {String} token Authorization token
|
|
42
|
+
*/
|
|
43
|
+
deleteDepartmentTrainingPlan(id, token) {
|
|
44
|
+
return new Promise(function (resolve, reject) {
|
|
45
|
+
const request = axios.delete(`api/v1/departmenttrainingplans/`, {
|
|
46
|
+
headers: { authorization: token },
|
|
47
|
+
data: {
|
|
48
|
+
id: id,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
request
|
|
52
|
+
.then((response) => {
|
|
53
|
+
resolve(response.data);
|
|
54
|
+
})
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
reject(error);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get department traing plan information
|
|
63
|
+
* @param {number} id The id of the plan
|
|
64
|
+
* @param {String} token Authorization token
|
|
65
|
+
*/
|
|
66
|
+
getDepartmentTrainingPlanInformationById(id, version, token) {
|
|
67
|
+
return new Promise(function (resolve, reject) {
|
|
68
|
+
let confirmationRequest = axios.get(
|
|
69
|
+
`api/v1/departmenttrainingplans/${id}/${version}`,
|
|
70
|
+
{
|
|
71
|
+
headers: { authorization: token },
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
confirmationRequest
|
|
75
|
+
.then((response) => {
|
|
76
|
+
resolve(response.data);
|
|
77
|
+
})
|
|
78
|
+
.catch((error) => {
|
|
79
|
+
reject(error);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get department training plan list
|
|
86
|
+
* @param {Object} filter The filter used to select the plan
|
|
87
|
+
* @param {String} token Authorization token
|
|
88
|
+
*/
|
|
89
|
+
getDepartmentTrainingPlanList(filter, version, token) {
|
|
90
|
+
return new Promise(function (resolve, reject) {
|
|
91
|
+
const requestData = {
|
|
92
|
+
filter: filter ? filter : "",
|
|
93
|
+
version: version,
|
|
94
|
+
};
|
|
95
|
+
let confirmationRequest = axios.post(
|
|
96
|
+
`api/v1/departmenttrainingplans`,
|
|
97
|
+
requestData,
|
|
98
|
+
{
|
|
99
|
+
headers: { authorization: token },
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
confirmationRequest
|
|
103
|
+
.then((response) => {
|
|
104
|
+
resolve(response.data);
|
|
105
|
+
})
|
|
106
|
+
.catch((error) => {
|
|
107
|
+
reject(error);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Publish department training plan
|
|
114
|
+
* @param {number} id The id of the plan to be published
|
|
115
|
+
* @param {String} token Authorization token
|
|
116
|
+
*/
|
|
117
|
+
publishDepartmentTrainingPlan(id, token) {
|
|
118
|
+
return new Promise(function (resolve, reject) {
|
|
119
|
+
let confirmationRequest = axios.post(
|
|
120
|
+
`api/v1/departmenttrainingplans/publish/${id}`,
|
|
121
|
+
{},
|
|
122
|
+
{
|
|
123
|
+
headers: { authorization: token },
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
confirmationRequest
|
|
127
|
+
.then((response) => {
|
|
128
|
+
resolve(response.data);
|
|
129
|
+
})
|
|
130
|
+
.catch((error) => {
|
|
131
|
+
reject(error);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Set department training plan profile information
|
|
138
|
+
* @param {String} id The id of the plan to be updated
|
|
139
|
+
* @param {Object} data Data used to update the plan
|
|
140
|
+
* @param {String} token Authorization token
|
|
141
|
+
*/
|
|
142
|
+
setDepartmentTrainingPlanInformation(id, data, token) {
|
|
143
|
+
return new Promise(function (resolve, reject) {
|
|
144
|
+
const requestData = {
|
|
145
|
+
data: data,
|
|
146
|
+
};
|
|
147
|
+
let confirmationRequest = axios.post(
|
|
148
|
+
`api/v1/departmenttrainingplans/${id}`,
|
|
149
|
+
requestData,
|
|
150
|
+
{
|
|
151
|
+
headers: { authorization: token },
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
confirmationRequest
|
|
155
|
+
.then((response) => {
|
|
156
|
+
resolve(response.data);
|
|
157
|
+
})
|
|
158
|
+
.catch((error) => {
|
|
159
|
+
reject(error);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
};
|