@stackfactor/client-api 1.1.128 → 1.1.130

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.
Files changed (40) hide show
  1. package/exports.ts +85 -0
  2. package/index.ts +1 -0
  3. package/lib/{actionNotifications.js → actionNotifications.ts} +18 -6
  4. package/lib/{address.js → address.ts} +3 -2
  5. package/lib/{aiAssistant.js → aiAssistant.ts} +58 -25
  6. package/lib/{avatar.js → avatar.ts} +10 -4
  7. package/lib/axiosClient.ts +92 -0
  8. package/lib/{config.js → config.ts} +19 -6
  9. package/lib/{constants.js → constants.ts} +6 -41
  10. package/lib/{dashboard.js → dashboard.ts} +17 -7
  11. package/lib/{departmentTrainingPlans.js → departmentTrainingPlans.ts} +57 -23
  12. package/lib/{groups.js → groups.ts} +67 -26
  13. package/lib/{integration.js → integration.ts} +100 -43
  14. package/lib/{integrationConfiguration.js → integrationConfiguration.ts} +25 -8
  15. package/lib/integrations/{contentGenerator.js → contentGenerator.ts} +38 -18
  16. package/lib/{learningContent.js → learningContent.ts} +127 -66
  17. package/lib/{learningPath.js → learningPath.ts} +56 -29
  18. package/lib/{logger.js → logger.ts} +17 -5
  19. package/lib/{microSkillsQuizes.js → microSkillsQuizes.ts} +15 -6
  20. package/lib/{quotas.js → quotas.ts} +10 -5
  21. package/lib/{role.js → role.ts} +114 -66
  22. package/lib/{roleTemplate.js → roleTemplate.ts} +63 -28
  23. package/lib/{security.js → security.ts} +14 -10
  24. package/lib/{skill.js → skill.ts} +119 -82
  25. package/lib/{skillAssessments.js → skillAssessmentTestingSession.ts} +39 -17
  26. package/lib/skillAssessments.ts +192 -0
  27. package/lib/{skillTemplate.js → skillTemplate.ts} +70 -39
  28. package/lib/{talentTransfromation.js → talentTransfromation.ts} +21 -15
  29. package/lib/{teams.js → teams.ts} +71 -27
  30. package/lib/{tenants.js → tenants.ts} +16 -7
  31. package/lib/{trainingPlans.js → trainingPlans.ts} +96 -59
  32. package/lib/{trainingPlansProficiencyLevels.js → trainingPlansProficiencyLevels.ts} +29 -23
  33. package/lib/{userInformation.js → userInformation.ts} +25 -12
  34. package/lib/{users.js → users.ts} +172 -154
  35. package/lib/{utils.js → utils.ts} +6 -6
  36. package/package.json +8 -6
  37. package/exports.js +0 -85
  38. package/index.js +0 -1
  39. package/lib/axiosClient.js +0 -82
  40. package/lib/skillAssessmentTestingSession.js +0 -147
@@ -4,10 +4,10 @@ import { client } from "./axiosClient.js";
4
4
  * Create skill and set information
5
5
  * @param {Object} data
6
6
  * @param {String} token Authorization token
7
- * @returns {Promise}
7
+ * @returns {Promise<Object>}
8
8
  */
9
- const createSkill = (data, token) => {
10
- return new Promise(function (resolve, reject) {
9
+ const createSkill = (data: object, token: string): Promise<object> => {
10
+ return new Promise((resolve, reject) => {
11
11
  let confirmationRequest = client.put(
12
12
  "api/v1/skills",
13
13
  { data: data },
@@ -27,12 +27,15 @@ const createSkill = (data, token) => {
27
27
 
28
28
  /**
29
29
  * Create skills from templates
30
- * @param {Array<String>} templateIds,
30
+ * @param {Array<String>} templateIds
31
31
  * @param {String} token Authorization token
32
- * @returns {Promise}
32
+ * @returns {Promise<Object>}
33
33
  */
34
- const createSkillsFromTemplates = (templateIds, token) => {
35
- return new Promise(function (resolve, reject) {
34
+ const createSkillsFromTemplates = (
35
+ templateIds: string[],
36
+ token: string
37
+ ): Promise<object> => {
38
+ return new Promise((resolve, reject) => {
36
39
  const requestData = {
37
40
  templateIds: templateIds,
38
41
  };
@@ -58,17 +61,20 @@ const createSkillsFromTemplates = (templateIds, token) => {
58
61
  * @param {String} id The id of the skill to be deleted
59
62
  * @param {String} comments The comments included with the deletion
60
63
  * @param {String} token Authorization token
61
- * @returns {Promise}
64
+ * @returns {Promise<Object>}
62
65
  */
63
- const deleteSkill = (id, comments, token) => {
64
- return new Promise(function (resolve, reject) {
65
- const data = {
66
+ const deleteSkill = (
67
+ id: string,
68
+ comments: string,
69
+ token: string
70
+ ): Promise<object> => {
71
+ return new Promise((resolve, reject) => {
72
+ const data: { id: string; comments?: string } = {
66
73
  id: id,
67
74
  };
68
75
  if (comments) data.comments = comments;
69
76
  const request = client.delete(`api/v1/skills/`, {
70
77
  headers: { authorization: token },
71
-
72
78
  data: data,
73
79
  });
74
80
  request
@@ -83,16 +89,15 @@ const deleteSkill = (id, comments, token) => {
83
89
 
84
90
  /**
85
91
  * Discard the skill draft changes
86
- * @param {String} id The id of the skill to be deleted
92
+ * @param {String} id The id of the skill to be discarded
87
93
  * @param {String} token Authorization token
88
- * @returns {Promise}
94
+ * @returns {Promise<Object>}
89
95
  */
90
- const discardSkillChanges = (id, token) => {
91
- return new Promise(function (resolve, reject) {
96
+ const discardSkillChanges = (id: string, token: string): Promise<object> => {
97
+ return new Promise((resolve, reject) => {
92
98
  const data = {};
93
99
  const request = client.get(`api/v1/skills/discard/${id}`, {
94
100
  headers: { authorization: token },
95
-
96
101
  data: data,
97
102
  });
98
103
  request
@@ -107,16 +112,15 @@ const discardSkillChanges = (id, token) => {
107
112
 
108
113
  /**
109
114
  * Get the list of imported skill templates
110
- * @param {String} token
111
- * @returns {Promise}
115
+ * @param {String} token Authorization token
116
+ * @returns {Promise<Object>}
112
117
  */
113
- const getImportedSkillTemplates = (token) => {
114
- return new Promise(function (resolve, reject) {
118
+ const getImportedSkillTemplates = (token: string): Promise<object> => {
119
+ return new Promise((resolve, reject) => {
115
120
  const request = client.get(`api/v1/skills/getimportedskilltemplates`, {
116
121
  headers: { authorization: token },
117
122
  });
118
123
  request
119
-
120
124
  .then((response) => {
121
125
  resolve(response.data);
122
126
  })
@@ -129,12 +133,16 @@ const getImportedSkillTemplates = (token) => {
129
133
  /**
130
134
  * Get the skill related roles
131
135
  * @param {String} id
132
- * @param {String} token
136
+ * @param {String} token Authorization token
133
137
  * @param {Boolean} includeRoleInformation
134
- * @returns {Promise}
138
+ * @returns {Promise<Object>}
135
139
  */
136
- const getSkillRelatedRoles = (id, token, includeRoleInformation = false) => {
137
- return new Promise(function (resolve, reject) {
140
+ const getSkillRelatedRoles = (
141
+ id: string,
142
+ token: string,
143
+ includeRoleInformation = false
144
+ ): Promise<object> => {
145
+ return new Promise((resolve, reject) => {
138
146
  let confirmationRequest = client.get(
139
147
  `api/v1/skills/getskillrelatedroles/${id}/${includeRoleInformation}`,
140
148
  {
@@ -154,11 +162,14 @@ const getSkillRelatedRoles = (id, token, includeRoleInformation = false) => {
154
162
  /**
155
163
  * Get skill required assessment type
156
164
  * @param {String} id
157
- * @param {String} token
158
- * @returns {Promise}
165
+ * @param {String} token Authorization token
166
+ * @returns {Promise<Object>}
159
167
  */
160
- const getSkillRequiredAssessmentType = (id, token) => {
161
- return new Promise(function (resolve, reject) {
168
+ const getSkillRequiredAssessmentType = (
169
+ id: string,
170
+ token: string
171
+ ): Promise<object> => {
172
+ return new Promise((resolve, reject) => {
162
173
  let confirmationRequest = client.get(
163
174
  `api/v1/skills/getrequiredassessmenttype/${id}`,
164
175
  {
@@ -176,20 +187,20 @@ const getSkillRequiredAssessmentType = (id, token) => {
176
187
  };
177
188
 
178
189
  /**
179
- * Get skill skill information
190
+ * Get skill information
180
191
  * @param {String} id The id of the skill
181
192
  * @param {String} version The version of the skill
182
193
  * @param {Boolean} returnNullIfVersionNotFound When true it will return null if the version is not found
183
194
  * @param {String} token Authorization token
184
- * @returns {Promise}
195
+ * @returns {Promise<Object>}
185
196
  */
186
197
  const getSkillInformationById = (
187
- id,
188
- version,
189
- returnNullIfVersionNotFound,
190
- token
191
- ) => {
192
- return new Promise(function (resolve, reject) {
198
+ id: string,
199
+ version: string,
200
+ returnNullIfVersionNotFound: boolean,
201
+ token: string
202
+ ): Promise<object> => {
203
+ return new Promise((resolve, reject) => {
193
204
  let confirmationRequest = client.get(
194
205
  `api/v1/skills/skill/${id}/${version}/${returnNullIfVersionNotFound}`,
195
206
  {
@@ -214,22 +225,23 @@ const getSkillInformationById = (
214
225
  * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
215
226
  * @param {Boolean} namesOnly Return only the names of the skills
216
227
  * @param {String} token Authorization token
217
- * @returns {Promise}
228
+ * @returns {Promise<Object>}
218
229
  */
219
230
  const getSkillList = (
220
- filter,
221
- version,
222
- includeDeleted,
223
- returnDefaultIfVersionNotAvailable,
224
- namesOnly,
225
- token
226
- ) => {
227
- return new Promise(function (resolve, reject) {
231
+ filter: string[],
232
+ version: string,
233
+ includeDeleted: boolean,
234
+ returnDefaultIfVersionNotAvailable: boolean,
235
+ namesOnly: boolean,
236
+ token: string
237
+ ): Promise<object> => {
238
+ return new Promise((resolve, reject) => {
228
239
  const requestData = {
229
240
  includeDeleted: includeDeleted,
230
241
  namesOnly: namesOnly,
231
242
  returnDefaultIfVersionNotAvailable: returnDefaultIfVersionNotAvailable,
232
243
  version: version,
244
+ filter: filter,
233
245
  };
234
246
  if (filter) requestData.filter = filter;
235
247
  let confirmationRequest = client.post(`api/v1/skills`, requestData, {
@@ -251,15 +263,15 @@ const getSkillList = (
251
263
  * @param {Number} maxDepth How many levels down in the organization the skills will be loaded
252
264
  * @param {Boolean} returnNullIfVersionNotFound Return null if the version is not found
253
265
  * @param {String} token Authorization token
254
- * @returns {Promise}
266
+ * @returns {Promise<Object>}
255
267
  */
256
268
  const getTeamSkillsById = (
257
- teamId,
258
- maxDepth,
259
- returnNullIfVersionNotFound,
260
- token
261
- ) => {
262
- return new Promise(function (resolve, reject) {
269
+ teamId: string,
270
+ maxDepth: number,
271
+ returnNullIfVersionNotFound: boolean,
272
+ token: string
273
+ ): Promise<object> => {
274
+ return new Promise((resolve, reject) => {
263
275
  let confirmationRequest = client.get(
264
276
  `api/v1/skills/getteambyid/${teamId}/${maxDepth}/${returnNullIfVersionNotFound}`,
265
277
  {
@@ -280,10 +292,13 @@ const getTeamSkillsById = (
280
292
  * Get current user team skills
281
293
  * @param {Number} maxDepth How many levels down in the organization the skills will be loaded
282
294
  * @param {String} token Authorization token
283
- * @returns {Promise}
295
+ * @returns {Promise<Object>}
284
296
  */
285
- const getCurrentUserTeamSkills = (maxDepth, token) => {
286
- return new Promise(function (resolve, reject) {
297
+ const getCurrentUserTeamSkills = (
298
+ maxDepth: number,
299
+ token: string
300
+ ): Promise<object> => {
301
+ return new Promise((resolve, reject) => {
287
302
  let confirmationRequest = client.get(
288
303
  `api/v1/skills/getcurrentuserteam/${maxDepth}`,
289
304
  {
@@ -303,11 +318,14 @@ const getCurrentUserTeamSkills = (maxDepth, token) => {
303
318
  /**
304
319
  * Get skill template updates
305
320
  * @param {String} id The skill id
306
- * @param {String} token
307
- * @returns {Promise}
321
+ * @param {String} token Authorization token
322
+ * @returns {Promise<Object>}
308
323
  */
309
- const getSkillTemplateUpdates = (id, token) => {
310
- return new Promise(function (resolve, reject) {
324
+ const getSkillTemplateUpdates = (
325
+ id: string,
326
+ token: string
327
+ ): Promise<object> => {
328
+ return new Promise((resolve, reject) => {
311
329
  let confirmationRequest = client.get(
312
330
  `api/v1/skills/getskilltemplateupdates/${id}`,
313
331
  {
@@ -328,11 +346,15 @@ const getSkillTemplateUpdates = (id, token) => {
328
346
  * Import skill templates
329
347
  * @param {Array<String>} data The list of role templates to be imported
330
348
  * @param {Boolean} publish If true the imported templates will be published
331
- * @param {String} token
332
- * @returns {Promise}
349
+ * @param {String} token Authorization token
350
+ * @returns {Promise<Object>}
333
351
  */
334
- const importSkillTemplates = (data, publish, token) => {
335
- return new Promise(function (resolve, reject) {
352
+ const importSkillTemplates = (
353
+ data: string[],
354
+ publish: boolean,
355
+ token: string
356
+ ): Promise<object> => {
357
+ return new Promise((resolve, reject) => {
336
358
  const requestData = {
337
359
  data: data,
338
360
  publish: publish,
@@ -345,7 +367,6 @@ const importSkillTemplates = (data, publish, token) => {
345
367
  }
346
368
  );
347
369
  confirmationRequest
348
-
349
370
  .then((response) => {
350
371
  resolve(response.data);
351
372
  })
@@ -360,11 +381,15 @@ const importSkillTemplates = (data, publish, token) => {
360
381
  * @param {String} id The id of the skill to be published
361
382
  * @param {String} comments The comments to be include with the request
362
383
  * @param {String} token Authorization token
363
- * @returns {Promise}
384
+ * @returns {Promise<Object>}
364
385
  */
365
- const publishSkill = (id, comments, token) => {
366
- return new Promise(function (resolve, reject) {
367
- let data = {};
386
+ const publishSkill = (
387
+ id: string,
388
+ comments: string,
389
+ token: string
390
+ ): Promise<object> => {
391
+ return new Promise((resolve, reject) => {
392
+ let data: { comments?: string } = {};
368
393
  if (comments) data.comments = comments;
369
394
  let confirmationRequest = client.post(`api/v1/skills/publish/${id}`, data, {
370
395
  headers: { authorization: token },
@@ -384,10 +409,14 @@ const publishSkill = (id, comments, token) => {
384
409
  * @param {String} id The id of the skill to be updated
385
410
  * @param {Object} data Data used to update the skill
386
411
  * @param {String} token Authorization token
387
- * @returns {Promise}
412
+ * @returns {Promise<Object>}
388
413
  */
389
- const setSkillInformation = (id, data, token) => {
390
- return new Promise(function (resolve, reject) {
414
+ const setSkillInformation = (
415
+ id: string,
416
+ data: object,
417
+ token: string
418
+ ): Promise<object> => {
419
+ return new Promise((resolve, reject) => {
391
420
  const requestData = {
392
421
  data: data,
393
422
  id: id,
@@ -414,10 +443,14 @@ const setSkillInformation = (id, data, token) => {
414
443
  * @param {String} id The id of the skill to be updated
415
444
  * @param {Object} data Data used to update the skill
416
445
  * @param {String} token Authorization token
417
- * @returns {Promise}
446
+ * @returns {Promise<Object>}
418
447
  */
419
- const setSkillInformationFromTemplate = (id, data, token) => {
420
- return new Promise(function (resolve, reject) {
448
+ const setSkillInformationFromTemplate = (
449
+ id: string,
450
+ data: object,
451
+ token: string
452
+ ): Promise<object> => {
453
+ return new Promise((resolve, reject) => {
421
454
  const requestData = {
422
455
  data: data,
423
456
  id: id,
@@ -443,10 +476,10 @@ const setSkillInformationFromTemplate = (id, data, token) => {
443
476
  * Validate skill information
444
477
  * @param {String} id The id of the skill to be updated
445
478
  * @param {String} token Authorization token
446
- * @returns {Promise}
479
+ * @returns {Promise<Object>}
447
480
  */
448
- const validateSkill = (id, token) => {
449
- return new Promise(function (resolve, reject) {
481
+ const validateSkill = (id: string, token: string): Promise<object> => {
482
+ return new Promise((resolve, reject) => {
450
483
  const requestData = {
451
484
  id: id,
452
485
  };
@@ -472,10 +505,14 @@ const validateSkill = (id, token) => {
472
505
  * @param {String} id The id of the skill to be updated
473
506
  * @param {Boolean} watch Set to true or false
474
507
  * @param {String} token Authorization token
475
- * @returns {Promise}
508
+ * @returns {Promise<Object>}
476
509
  */
477
- const watchSkill = (id, watch, token) => {
478
- return new Promise(function (resolve, reject) {
510
+ const watchSkill = (
511
+ id: string,
512
+ watch: boolean,
513
+ token: string
514
+ ): Promise<object> => {
515
+ return new Promise((resolve, reject) => {
479
516
  const requestData = {
480
517
  id: id,
481
518
  watch: watch,
@@ -6,9 +6,15 @@ import { client } from "./axiosClient.js";
6
6
  * @param {Object} data
7
7
  * @param {String} comments
8
8
  * @param {String} token Authorization token
9
+ * @returns {Promise<Object>}
9
10
  */
10
- const addEntry = (id, data, comments, token) => {
11
- return new Promise(function (resolve, reject) {
11
+ const addEntry = (
12
+ id: string,
13
+ data: object,
14
+ comments: string,
15
+ token: string
16
+ ): Promise<object> => {
17
+ return new Promise((resolve, reject) => {
12
18
  const requestData = {
13
19
  comments: comments,
14
20
  data: data,
@@ -37,9 +43,15 @@ const addEntry = (id, data, comments, token) => {
37
43
  * @param {String} comments
38
44
  * @param {String} userId
39
45
  * @param {String} token Authorization token
46
+ * @returns {Promise<Object>}
40
47
  */
41
- const create = (data, comments, userId, token) => {
42
- return new Promise(function (resolve, reject) {
48
+ const create = (
49
+ data: object,
50
+ comments: string,
51
+ userId: string,
52
+ token: string
53
+ ): Promise<object> => {
54
+ return new Promise((resolve, reject) => {
43
55
  const requestData = {
44
56
  comments: comments,
45
57
  data: data,
@@ -67,16 +79,20 @@ const create = (data, comments, userId, token) => {
67
79
  * @param {number} id The id of the skill to be deleted
68
80
  * @param {String} comments The comments included with the deletion
69
81
  * @param {String} token Authorization token
82
+ * @returns {Promise<Object>}
70
83
  */
71
- const deleteSkillAssessment = (id, comments, token) => {
72
- return new Promise(function (resolve, reject) {
73
- const data = {
84
+ const deleteSkillAssessment = (
85
+ id: number,
86
+ comments: string,
87
+ token: string
88
+ ): Promise<object> => {
89
+ return new Promise((resolve, reject) => {
90
+ const data: { id: number, comments?: string } = {
74
91
  id: id,
75
92
  };
76
93
  if (comments) data.comments = comments;
77
94
  const request = client.delete(`api/v1/skillassessments`, {
78
95
  headers: { authorization: token },
79
-
80
96
  data: data,
81
97
  });
82
98
  request
@@ -93,9 +109,10 @@ const deleteSkillAssessment = (id, comments, token) => {
93
109
  * Get skill assessment by id
94
110
  * @param {String} id
95
111
  * @param {String} token
112
+ * @returns {Promise<Object>}
96
113
  */
97
- const getById = (id, token) => {
98
- return new Promise(function (resolve, reject) {
114
+ const getById = (id: string, token: string): Promise<object> => {
115
+ return new Promise((resolve, reject) => {
99
116
  let confirmationRequest = client.get(`api/v1/skillassessments/${id}`, {
100
117
  headers: { authorization: token },
101
118
  });
@@ -114,10 +131,14 @@ const getById = (id, token) => {
114
131
  * @param {String} userId
115
132
  * @param {String} skillId
116
133
  * @param {String} token
117
- * @returns {Promise<Object>} The skill assessment
134
+ * @returns {Promise<Object>} The skill assessment
118
135
  */
119
- const getByUserAndSkill = (userId, skillId, token) => {
120
- return new Promise(function (resolve, reject) {
136
+ const getByUserAndSkill = (
137
+ userId: string,
138
+ skillId: string,
139
+ token: string
140
+ ): Promise<object> => {
141
+ return new Promise((resolve, reject) => {
121
142
  let confirmationRequest = client.get(
122
143
  `api/v1/skillassessments/getbyuserandskill/${userId}/${skillId}`,
123
144
  {
@@ -136,12 +157,13 @@ const getByUserAndSkill = (userId, skillId, token) => {
136
157
 
137
158
  /**
138
159
  * Get list
139
- * @param {Object} userId The user used to select the skill
160
+ * @param {String} userId The user used to select the skill
140
161
  * @param {String} token Authorization token
162
+ * @returns {Promise<Object>}
141
163
  */
142
- const getList = (userId, token) => {
143
- return new Promise(function (resolve, reject) {
144
- const requestData = {};
164
+ const getList = (userId: string, token: string): Promise<object> => {
165
+ return new Promise((resolve, reject) => {
166
+ const requestData: { userId?: string } = {};
145
167
  if (userId) requestData.userId = userId;
146
168
  let confirmationRequest = client.post(
147
169
  `api/v1/skillassessments`,
@@ -0,0 +1,192 @@
1
+ import { client } from "./axiosClient.js";
2
+
3
+ /**
4
+ * Add new entry skill assessment
5
+ * @param {String} id
6
+ * @param {Object} data
7
+ * @param {String} comments
8
+ * @param {String} token Authorization token
9
+ * @returns {Promise<Object>}
10
+ */
11
+ const addEntry = (
12
+ id: string,
13
+ data: object,
14
+ comments: string,
15
+ token: string
16
+ ): Promise<object> => {
17
+ return new Promise((resolve, reject) => {
18
+ const requestData = {
19
+ comments: comments,
20
+ data: data,
21
+ id: id,
22
+ };
23
+ let confirmationRequest = client.put(
24
+ "api/v1/skillassessments/addentry",
25
+ requestData,
26
+ {
27
+ headers: { authorization: token },
28
+ }
29
+ );
30
+ confirmationRequest
31
+ .then((response) => {
32
+ resolve(response.data);
33
+ })
34
+ .catch((error) => {
35
+ reject(error);
36
+ });
37
+ });
38
+ };
39
+
40
+ /**
41
+ * Create skill assessment
42
+ * @param {Object} data
43
+ * @param {String} comments
44
+ * @param {String} userId
45
+ * @param {String} token Authorization token
46
+ * @returns {Promise<Object>}
47
+ */
48
+ const create = (
49
+ data: object,
50
+ comments: string,
51
+ userId: string,
52
+ token: string
53
+ ): Promise<object> => {
54
+ return new Promise((resolve, reject) => {
55
+ const requestData = {
56
+ comments: comments,
57
+ data: data,
58
+ userId: userId,
59
+ };
60
+ let confirmationRequest = client.put(
61
+ "api/v1/skillassessments/",
62
+ requestData,
63
+ {
64
+ headers: { authorization: token },
65
+ }
66
+ );
67
+ confirmationRequest
68
+ .then((response) => {
69
+ resolve(response.data);
70
+ })
71
+ .catch((error) => {
72
+ reject(error);
73
+ });
74
+ });
75
+ };
76
+
77
+ /**
78
+ * Delete skill assessment
79
+ * @param {number} id The id of the skill to be deleted
80
+ * @param {String} comments The comments included with the deletion
81
+ * @param {String} token Authorization token
82
+ * @returns {Promise<Object>}
83
+ */
84
+ const deleteSkillAssessment = (
85
+ id: number,
86
+ comments: string,
87
+ token: string
88
+ ): Promise<object> => {
89
+ return new Promise((resolve, reject) => {
90
+ const data: { id: number, comments?: string } = {
91
+ id: id,
92
+ };
93
+ if (comments) data.comments = comments;
94
+ const request = client.delete(`api/v1/skillassessments`, {
95
+ headers: { authorization: token },
96
+ data: data,
97
+ });
98
+ request
99
+ .then((response) => {
100
+ resolve(response.data);
101
+ })
102
+ .catch((error) => {
103
+ reject(error);
104
+ });
105
+ });
106
+ };
107
+
108
+ /**
109
+ * Get skill assessment by id
110
+ * @param {String} id
111
+ * @param {String} token
112
+ * @returns {Promise<Object>}
113
+ */
114
+ const getById = (id: string, token: string): Promise<object> => {
115
+ return new Promise((resolve, reject) => {
116
+ let confirmationRequest = client.get(`api/v1/skillassessments/${id}`, {
117
+ headers: { authorization: token },
118
+ });
119
+ confirmationRequest
120
+ .then((response) => {
121
+ resolve(response.data);
122
+ })
123
+ .catch((error) => {
124
+ reject(error);
125
+ });
126
+ });
127
+ };
128
+
129
+ /**
130
+ * Get skill assessment by user and skill
131
+ * @param {String} userId
132
+ * @param {String} skillId
133
+ * @param {String} token
134
+ * @returns {Promise<Object>} The skill assessment
135
+ */
136
+ const getByUserAndSkill = (
137
+ userId: string,
138
+ skillId: string,
139
+ token: string
140
+ ): Promise<object> => {
141
+ return new Promise((resolve, reject) => {
142
+ let confirmationRequest = client.get(
143
+ `api/v1/skillassessments/getbyuserandskill/${userId}/${skillId}`,
144
+ {
145
+ headers: { authorization: token },
146
+ }
147
+ );
148
+ confirmationRequest
149
+ .then((response) => {
150
+ resolve(response.data);
151
+ })
152
+ .catch((error) => {
153
+ reject(error);
154
+ });
155
+ });
156
+ };
157
+
158
+ /**
159
+ * Get list
160
+ * @param {String} userId The user used to select the skill
161
+ * @param {String} token Authorization token
162
+ * @returns {Promise<Object>}
163
+ */
164
+ const getList = (userId: string, token: string): Promise<object> => {
165
+ return new Promise((resolve, reject) => {
166
+ const requestData: { userId?: string } = {};
167
+ if (userId) requestData.userId = userId;
168
+ let confirmationRequest = client.post(
169
+ `api/v1/skillassessments`,
170
+ requestData,
171
+ {
172
+ headers: { authorization: token },
173
+ }
174
+ );
175
+ confirmationRequest
176
+ .then((response) => {
177
+ resolve(response.data);
178
+ })
179
+ .catch((error) => {
180
+ reject(error);
181
+ });
182
+ });
183
+ };
184
+
185
+ export default {
186
+ addEntry,
187
+ create,
188
+ deleteSkillAssessment,
189
+ getById,
190
+ getByUserAndSkill,
191
+ getList,
192
+ };