@stackfactor/client-api 1.0.32 → 1.0.33

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/lib/skill.js CHANGED
@@ -1,337 +1,325 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
3
+ /**
4
+ * Create skill and set information
5
+ * @param {Object} data
6
+ * @param {String} token Authorization token
7
+ */
8
+ export const createSkill = (data, token) => {
9
+ return new Promise(function (resolve, reject) {
10
+ let confirmationRequest = axios.put(
11
+ "api/v1/skills",
12
+ { data: data },
13
+ {
14
+ headers: { authorization: token },
15
+ }
16
+ );
17
+ confirmationRequest
18
+ .then((response) => {
19
+ resolve(response.data);
20
+ })
21
+ .catch((error) => {
22
+ reject(error);
23
+ });
24
+ });
25
+ };
5
26
 
6
- /**
7
- * Create skill and set information
8
- * @param {Object} data
9
- * @param {String} token Authorization token
10
- */
11
- createSkill: (data, token) => {
12
- return new Promise(function (resolve, reject) {
13
- let confirmationRequest = axios.put(
14
- "api/v1/skills",
15
- { data: data },
16
- {
17
- headers: { authorization: token },
18
- }
19
- );
20
- confirmationRequest
21
- .then((response) => {
22
- resolve(response.data);
23
- })
24
- .catch((error) => {
25
- reject(error);
26
- });
27
+ /**
28
+ * Create skills from templates
29
+ * @param {Array<String>} templateIds,
30
+ * @param {String} token Authorization token
31
+ */
32
+ export const createSkillsFromTemplates = (templateIds, token) => {
33
+ return new Promise(function (resolve, reject) {
34
+ const requestData = {
35
+ templateIds: templateIds,
36
+ };
37
+ let confirmationRequest = axios.put(
38
+ "api/v1/skills/createfromtemplate/",
39
+ requestData,
40
+ {
41
+ headers: { authorization: token },
42
+ }
43
+ );
44
+ confirmationRequest
45
+ .then((response) => {
46
+ resolve(response.data);
47
+ })
48
+ .catch((error) => {
49
+ reject(error);
50
+ });
51
+ });
52
+ };
53
+
54
+ /**
55
+ * Delete skill
56
+ * @param {String} id The id of the skill to be deleted
57
+ * @param {String} comment The comment included with the deletion
58
+ * @param {String} token Authorization token
59
+ */
60
+ export const deleteSkill = (id, comment, token) => {
61
+ return new Promise(function (resolve, reject) {
62
+ const data = {
63
+ id: id,
64
+ };
65
+ if (comment) data.comment = comment;
66
+ const request = axios.delete(`api/v1/skills/`, {
67
+ headers: { authorization: token },
68
+ data: data,
27
69
  });
28
- },
70
+ request
71
+ .then((response) => {
72
+ resolve(response.data);
73
+ })
74
+ .catch((error) => {
75
+ reject(error);
76
+ });
77
+ });
78
+ };
29
79
 
30
- /**
31
- * Create skills from templates
32
- * @param {Array<String>} templateIds,
33
- * @param {String} token Authorization token
34
- */
35
- createSkillsFromTemplates: (templateIds, token) => {
36
- return new Promise(function (resolve, reject) {
37
- const requestData = {
38
- templateIds: templateIds,
39
- };
40
- let confirmationRequest = axios.put(
41
- "api/v1/skills/createfromtemplate/",
42
- requestData,
43
- {
44
- headers: { authorization: token },
45
- }
46
- );
47
- confirmationRequest
48
- .then((response) => {
49
- resolve(response.data);
50
- })
51
- .catch((error) => {
52
- reject(error);
53
- });
80
+ /**
81
+ * Discard the skill draft changes
82
+ * @param {String} id The id of the skill to be deleted
83
+ * @param {String} token Authorization token
84
+ */
85
+ export const discardSkillChanges = (id, token) => {
86
+ return new Promise(function (resolve, reject) {
87
+ const data = {};
88
+ const request = axios.get(`api/v1/skills/discard/${id}`, {
89
+ headers: { authorization: token },
90
+ data: data,
54
91
  });
55
- },
92
+ request
93
+ .then((response) => {
94
+ resolve(response.data);
95
+ })
96
+ .catch((error) => {
97
+ reject(error);
98
+ });
99
+ });
100
+ };
56
101
 
57
- /**
58
- * Delete skill
59
- * @param {String} id The id of the skill to be deleted
60
- * @param {String} comment The comment included with the deletion
61
- * @param {String} token Authorization token
62
- */
63
- deleteSkill: (id, comment, token) => {
64
- return new Promise(function (resolve, reject) {
65
- const data = {
66
- id: id,
67
- };
68
- if (comment) data.comment = comment;
69
- const request = axios.delete(`api/v1/skills/`, {
102
+ /**
103
+ * Get the skill related roles
104
+ * @param {String} id
105
+ * @param {String} token
106
+ * @returns
107
+ */
108
+ export const getSkillRelatedRoles = (id, token) => {
109
+ return new Promise(function (resolve, reject) {
110
+ let confirmationRequest = axios.get(
111
+ `api/v1/skills/getskillrelatedroles/${id}`,
112
+ {
70
113
  headers: { authorization: token },
71
- data: data,
114
+ }
115
+ );
116
+ confirmationRequest
117
+ .then((response) => {
118
+ resolve(response.data);
119
+ })
120
+ .catch((error) => {
121
+ reject(error);
72
122
  });
73
- request
74
- .then((response) => {
75
- resolve(response.data);
76
- })
77
- .catch((error) => {
78
- reject(error);
79
- });
80
- });
81
- },
123
+ });
124
+ };
82
125
 
83
- /**
84
- * Discard the skill draft changes
85
- * @param {String} id The id of the skill to be deleted
86
- * @param {String} token Authorization token
87
- */
88
- discardSkillChanges: (id, token) => {
89
- return new Promise(function (resolve, reject) {
90
- const data = {};
91
- const request = axios.get(`api/v1/skills/discard/${id}`, {
126
+ /**
127
+ * Get skill required assessment type
128
+ * @param {String} id
129
+ * @param {String} token
130
+ */
131
+ export const getSkillRequiredAssessmentType = (id, token) => {
132
+ return new Promise(function (resolve, reject) {
133
+ let confirmationRequest = axios.get(
134
+ `api/v1/skills/getrequiredassessmenttype/${id}`,
135
+ {
92
136
  headers: { authorization: token },
93
- data: data,
137
+ }
138
+ );
139
+ confirmationRequest
140
+ .then((response) => {
141
+ resolve(response.data);
142
+ })
143
+ .catch((error) => {
144
+ reject(error);
94
145
  });
95
- request
96
- .then((response) => {
97
- resolve(response.data);
98
- })
99
- .catch((error) => {
100
- reject(error);
101
- });
102
- });
103
- },
104
-
105
- /**
106
- * Get the skill related roles
107
- * @param {String} id
108
- * @param {String} token
109
- * @returns
110
- */
111
- getSkillRelatedRoles: (id, token) => {
112
- return new Promise(function (resolve, reject) {
113
- let confirmationRequest = axios.get(
114
- `api/v1/skills/getskillrelatedroles/${id}`,
115
- {
116
- headers: { authorization: token },
117
- }
118
- );
119
- confirmationRequest
120
- .then((response) => {
121
- resolve(response.data);
122
- })
123
- .catch((error) => {
124
- reject(error);
125
- });
126
- });
127
- },
146
+ });
147
+ };
128
148
 
129
- /**
130
- * Get skill required assessment type
131
- * @param {String} id
132
- * @param {String} token
133
- */
134
- getSkillRequiredAssessmentType: (id, token) => {
135
- return new Promise(function (resolve, reject) {
136
- let confirmationRequest = axios.get(
137
- `api/v1/skills/getrequiredassessmenttype/${id}`,
138
- {
139
- headers: { authorization: token },
140
- }
141
- );
142
- confirmationRequest
143
- .then((response) => {
144
- resolve(response.data);
145
- })
146
- .catch((error) => {
147
- reject(error);
148
- });
149
- });
150
- },
149
+ /**
150
+ * Get skill skill information
151
+ * @param {String} id The id of the skill
152
+ * @param {String} token Authorization token
153
+ */
154
+ export const getSkillInformationById = (id, version, token) => {
155
+ return new Promise(function (resolve, reject) {
156
+ let confirmationRequest = axios.get(
157
+ `api/v1/skills/skill/${id}/${version}`,
158
+ {
159
+ headers: { authorization: token },
160
+ }
161
+ );
162
+ confirmationRequest
163
+ .then((response) => {
164
+ resolve(response.data);
165
+ })
166
+ .catch((error) => {
167
+ reject(error);
168
+ });
169
+ });
170
+ };
151
171
 
152
- /**
153
- * Get skill skill information
154
- * @param {String} id The id of the skill
155
- * @param {String} token Authorization token
156
- */
157
- getSkillInformationById: (id, version, token) => {
158
- return new Promise(function (resolve, reject) {
159
- let confirmationRequest = axios.get(
160
- `api/v1/skills/skill/${id}/${version}`,
161
- {
162
- headers: { authorization: token },
163
- }
164
- );
165
- confirmationRequest
166
- .then((response) => {
167
- resolve(response.data);
168
- })
169
- .catch((error) => {
170
- reject(error);
171
- });
172
+ /**
173
+ * Get skill list
174
+ * @param {Array<String>} filter The filter used to select the skill
175
+ * @param {String} version The version to be retrieved
176
+ * @param {Boolean} includeDeleted If true it will return deleted records as well
177
+ * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
178
+ * @param {String} token Authorization token
179
+ */
180
+ export const getSkillList = (
181
+ filter,
182
+ version,
183
+ includeDeleted,
184
+ returnDefaultIfVersionNotAvailable,
185
+ token
186
+ ) => {
187
+ return new Promise(function (resolve, reject) {
188
+ const requestData = {
189
+ version: version,
190
+ includeDeleted: includeDeleted,
191
+ returnDefaultIfVersionNotAvailable: returnDefaultIfVersionNotAvailable,
192
+ };
193
+ if (filter) requestData.filter = filter;
194
+ let confirmationRequest = axios.post(`api/v1/skills`, requestData, {
195
+ headers: { authorization: token },
172
196
  });
173
- },
197
+ confirmationRequest
198
+ .then((response) => {
199
+ resolve(response.data);
200
+ })
201
+ .catch((error) => {
202
+ reject(error);
203
+ });
204
+ });
205
+ };
174
206
 
175
- /**
176
- * Get skill list
177
- * @param {Array<String>} filter The filter used to select the skill
178
- * @param {String} version The version to be retrieved
179
- * @param {Boolean} includeDeleted If true it will return deleted records as well
180
- * @param {Boolean} returnDefaultIfVersionNotAvailable Return the default version if published not available
181
- * @param {String} token Authorization token
182
- */
183
- getSkillList: (
184
- filter,
185
- version,
186
- includeDeleted,
187
- returnDefaultIfVersionNotAvailable,
188
- token
189
- ) => {
190
- return new Promise(function (resolve, reject) {
191
- const requestData = {
192
- version: version,
193
- includeDeleted: includeDeleted,
194
- returnDefaultIfVersionNotAvailable: returnDefaultIfVersionNotAvailable,
195
- };
196
- if (filter) requestData.filter = filter;
197
- let confirmationRequest = axios.post(`api/v1/skills`, requestData, {
207
+ /**
208
+ * Get skills for team by id
209
+ * @param {String} teamId The ID of the team for which skills will be loaded
210
+ * @param {Number} maxDepth How many levels down in the organization the skills will be loaded
211
+ * @param {String} token Authorization token
212
+ */
213
+ export const getTeamSkillsById = (teamId, maxDepth, token) => {
214
+ return new Promise(function (resolve, reject) {
215
+ let confirmationRequest = axios.get(
216
+ `api/v1/skills/getteambyid/${teamId}/${maxDepth}`,
217
+ {
198
218
  headers: { authorization: token },
219
+ }
220
+ );
221
+ confirmationRequest
222
+ .then((response) => {
223
+ resolve(response.data);
224
+ })
225
+ .catch((error) => {
226
+ reject(error);
199
227
  });
200
- confirmationRequest
201
- .then((response) => {
202
- resolve(response.data);
203
- })
204
- .catch((error) => {
205
- reject(error);
206
- });
207
- });
208
- },
228
+ });
229
+ };
209
230
 
210
- /**
211
- * Get skills for team by id
212
- * @param {String} teamId The ID of the team for which skills will be loaded
213
- * @param {*} maxDepth How many levels down in the organization the skills will be loaded
214
- * @param {*} token Authorization token
215
- */
216
- getTeamSkillsById: (teamId, maxDepth, token) => {
217
- return new Promise(function (resolve, reject) {
218
- let confirmationRequest = axios.get(
219
- `api/v1/skills/getteambyid/${teamId}/${maxDepth}`,
220
- {
221
- headers: { authorization: token },
222
- }
223
- );
224
- confirmationRequest
225
- .then((response) => {
226
- resolve(response.data);
227
- })
228
- .catch((error) => {
229
- reject(error);
230
- });
231
- });
232
- },
231
+ /**
232
+ * Get current user team skills
233
+ * @param {Number} maxDepth How many levels down in the organization the skills will be loaded
234
+ * @param {String} token Authorization token
235
+ */
236
+ export const getCurrentUserTeamSkills = (maxDepth, token) => {
237
+ return new Promise(function (resolve, reject) {
238
+ let confirmationRequest = axios.get(
239
+ `api/v1/skills/getcurrentuserteam/${maxDepth}`,
240
+ {
241
+ headers: { authorization: token },
242
+ }
243
+ );
244
+ confirmationRequest
245
+ .then((response) => {
246
+ resolve(response.data);
247
+ })
248
+ .catch((error) => {
249
+ reject(error);
250
+ });
251
+ });
252
+ };
233
253
 
234
- /**
235
- * Get current user team skills
236
- * @param {*} maxDepth How many levels down in the organization the skills will be loaded
237
- * @param {*} token Authorization token
238
- */
239
- getCurrentUserTeamSkills: (maxDepth, token) => {
240
- return new Promise(function (resolve, reject) {
241
- let confirmationRequest = axios.get(
242
- `api/v1/skills/getcurrentuserteam/${maxDepth}`,
243
- {
244
- headers: { authorization: token },
245
- }
246
- );
247
- confirmationRequest
248
- .then((response) => {
249
- resolve(response.data);
250
- })
251
- .catch((error) => {
252
- reject(error);
253
- });
254
+ /**
255
+ * Publish skill
256
+ * @param {String} id The id of the skill to be published
257
+ * @param {String} comment The comment to be include with the request
258
+ * @param {String} token Authorization token
259
+ */
260
+ export const publishSkill = (id, comment, token) => {
261
+ return new Promise(function (resolve, reject) {
262
+ let data = {};
263
+ if (comment) data.comment = comment;
264
+ let confirmationRequest = axios.post(`api/v1/skills/publish/${id}`, data, {
265
+ headers: { authorization: token },
254
266
  });
255
- },
267
+ confirmationRequest
268
+ .then((response) => {
269
+ resolve(response.data);
270
+ })
271
+ .catch((error) => {
272
+ reject(error);
273
+ });
274
+ });
275
+ };
256
276
 
257
- /**
258
- * Publish skill
259
- * @param {String} id The id of the skill to be published
260
- * @param {String} comment The comment to be include with the request
261
- * @param {String} token Authorization token
262
- */
263
- publishSkill: (id, comment, token) => {
264
- return new Promise(function (resolve, reject) {
265
- let data = {};
266
- if (comment) data.comment = comment;
267
- let confirmationRequest = axios.post(
268
- `api/v1/skills/publish/${id}`,
269
- data,
270
- {
271
- headers: { authorization: token },
272
- }
273
- );
274
- confirmationRequest
275
- .then((response) => {
276
- resolve(response.data);
277
- })
278
- .catch((error) => {
279
- reject(error);
280
- });
277
+ /**
278
+ * Set skill information
279
+ * @param {String} id The id of the skill to be updated
280
+ * @param {Object} data Data used to update the skill
281
+ * @param {String} token Authorization token
282
+ */
283
+ export const setSkillInformation = (id, data, token) => {
284
+ return new Promise(function (resolve, reject) {
285
+ const requestData = {
286
+ data: data,
287
+ id: id,
288
+ };
289
+ let confirmationRequest = axios.post(`api/v1/skills/update/`, requestData, {
290
+ headers: { authorization: token },
281
291
  });
282
- },
292
+ confirmationRequest
293
+ .then((response) => {
294
+ resolve(response.data);
295
+ })
296
+ .catch((error) => {
297
+ reject(error);
298
+ });
299
+ });
300
+ };
283
301
 
284
- /**
285
- * Set skill information
286
- * @param {String} id The id of the skill to be updated
287
- * @param {Object} data Data used to update the skill
288
- * @param {String} token Authorization token
289
- */
290
- setSkillInformation: (id, data, token) => {
291
- return new Promise(function (resolve, reject) {
292
- const requestData = {
293
- data: data,
294
- id: id,
295
- };
296
- let confirmationRequest = axios.post(
297
- `api/v1/skills/update/`,
298
- requestData,
299
- {
300
- headers: { authorization: token },
301
- }
302
- );
303
- confirmationRequest
304
- .then((response) => {
305
- resolve(response.data);
306
- })
307
- .catch((error) => {
308
- reject(error);
309
- });
302
+ /**
303
+ * Watch skill
304
+ * @param {String} id The id of the skill to be updated
305
+ * @param {Boolean} watch Set to true or false
306
+ * @param {String} token Authorization token
307
+ */
308
+ export const watchSkill = (id, watch, token) => {
309
+ return new Promise(function (resolve, reject) {
310
+ const requestData = {
311
+ id: id,
312
+ watch: watch,
313
+ };
314
+ let confirmationRequest = axios.post(`api/v1/skills/watch`, requestData, {
315
+ headers: { authorization: token },
310
316
  });
311
- },
312
-
313
- /**
314
- * Watch skill
315
- * @param {String} id The id of the skill to be updated
316
- * @param {Boolean} watch Set to true or false
317
- * @param {String} token Authorization token
318
- */
319
- watchSkill: (id, watch, token) => {
320
- return new Promise(function (resolve, reject) {
321
- const requestData = {
322
- id: id,
323
- watch: watch,
324
- };
325
- let confirmationRequest = axios.post(`api/v1/skills/watch`, requestData, {
326
- headers: { authorization: token },
317
+ confirmationRequest
318
+ .then((response) => {
319
+ resolve(response.data);
320
+ })
321
+ .catch((error) => {
322
+ reject(error);
327
323
  });
328
- confirmationRequest
329
- .then((response) => {
330
- resolve(response.data);
331
- })
332
- .catch((error) => {
333
- reject(error);
334
- });
335
- });
336
- },
324
+ });
337
325
  };