@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.
@@ -0,0 +1,139 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ axios: axios,
5
+
6
+ /**
7
+ * Add new entry skill assessment
8
+ * @param {String} id
9
+ * @param {Object} data
10
+ * @param {String} comments
11
+ * @param {String} token Authorization token
12
+ */
13
+ addEntry(id, data, comments, token) {
14
+ return new Promise(function (resolve, reject) {
15
+ const requestData = {
16
+ comments: comments,
17
+ data: data,
18
+ id: id,
19
+ };
20
+ let confirmationRequest = axios.put(
21
+ "api/v1/skillassessments/addentry",
22
+ requestData,
23
+ {
24
+ headers: { authorization: token },
25
+ }
26
+ );
27
+ confirmationRequest
28
+ .then((response) => {
29
+ resolve(response.data);
30
+ })
31
+ .catch((error) => {
32
+ reject(error);
33
+ });
34
+ });
35
+ },
36
+
37
+ /**
38
+ * Create skill assessment
39
+ * @param {Object} data
40
+ * @param {String} comments
41
+ * @param {String} userId
42
+ * @param {String} token Authorization token
43
+ */
44
+ create(data, comments, userId, token) {
45
+ return new Promise(function (resolve, reject) {
46
+ const requestData = {
47
+ comments: comments,
48
+ data: data,
49
+ userId: userId,
50
+ };
51
+ let confirmationRequest = axios.put(
52
+ "api/v1/skillassessments/",
53
+ requestData,
54
+ {
55
+ headers: { authorization: token },
56
+ }
57
+ );
58
+ confirmationRequest
59
+ .then((response) => {
60
+ resolve(response.data);
61
+ })
62
+ .catch((error) => {
63
+ reject(error);
64
+ });
65
+ });
66
+ },
67
+
68
+ /**
69
+ * Delete skill assessment
70
+ * @param {number} id The id of the skill to be deleted
71
+ * @param {String} comments The comment included with the deletion
72
+ * @param {String} token Authorization token
73
+ */
74
+ deleteSkillAssessment(id, comments, token) {
75
+ return new Promise(function (resolve, reject) {
76
+ const data = {
77
+ id: id,
78
+ };
79
+ if (comments) data.comments = comments;
80
+ const request = axios.delete(`api/v1/skillassessments`, {
81
+ headers: { authorization: token },
82
+ data: data,
83
+ });
84
+ request
85
+ .then((response) => {
86
+ resolve(response.data);
87
+ })
88
+ .catch((error) => {
89
+ reject(error);
90
+ });
91
+ });
92
+ },
93
+
94
+ /**
95
+ * Get skill assessment by id
96
+ * @param {String} id
97
+ * @param {String} token
98
+ */
99
+ getById(id, token) {
100
+ return new Promise(function (resolve, reject) {
101
+ let confirmationRequest = axios.get(`api/v1/skillassessments/${id}`, {
102
+ headers: { authorization: token },
103
+ });
104
+ confirmationRequest
105
+ .then((response) => {
106
+ resolve(response.data);
107
+ })
108
+ .catch((error) => {
109
+ reject(error);
110
+ });
111
+ });
112
+ },
113
+
114
+ /**
115
+ * Get list
116
+ * @param {Object} userId The user used to select the skill
117
+ * @param {String} token Authorization token
118
+ */
119
+ getList(userId, token) {
120
+ return new Promise(function (resolve, reject) {
121
+ const requestData = {};
122
+ if (userId) requestData.userId = userId;
123
+ let confirmationRequest = axios.post(
124
+ `api/v1/skillassessments`,
125
+ requestData,
126
+ {
127
+ headers: { authorization: token },
128
+ }
129
+ );
130
+ confirmationRequest
131
+ .then((response) => {
132
+ resolve(response.data);
133
+ })
134
+ .catch((error) => {
135
+ reject(error);
136
+ });
137
+ });
138
+ },
139
+ };
@@ -0,0 +1,248 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ axios: axios,
5
+
6
+ /**
7
+ * Create skill template and set information
8
+ * @param {Object} data
9
+ * @param {String} token Authorization token
10
+ */
11
+ createSkillTemplate(data, token) {
12
+ return new Promise(function (resolve, reject) {
13
+ const requestData = {
14
+ data: data,
15
+ };
16
+ let confirmationRequest = axios.put(
17
+ "api/v1/skilltemplates",
18
+ requestData,
19
+ { headers: { authorization: token } }
20
+ );
21
+ confirmationRequest
22
+ .then((response) => {
23
+ resolve(response.data);
24
+ })
25
+ .catch((error) => {
26
+ reject(error);
27
+ });
28
+ });
29
+ },
30
+
31
+ /**
32
+ * Delete skill template
33
+ * @param {number} id The id of the template to be deleted
34
+ * @param {String} comment The comment included with the deletion
35
+ * @param {String} token Authorization token
36
+ */
37
+ deleteSkillTemplate(id, comment, token) {
38
+ const data = {
39
+ id: id,
40
+ };
41
+ if (comment) data.comment = comment;
42
+ return new Promise(function (resolve, reject) {
43
+ const request = axios.delete(`api/v1/skilltemplates/`, {
44
+ headers: { authorization: token },
45
+ data: data,
46
+ });
47
+ request
48
+ .then((response) => {
49
+ resolve(response.data);
50
+ })
51
+ .catch((error) => {
52
+ reject(error);
53
+ });
54
+ });
55
+ },
56
+
57
+ /**
58
+ * Discard the skill template draft changes
59
+ * @param {String} id The id of the skill template to be deleted
60
+ * @param {String} token Authorization token
61
+ */
62
+ discardSkillTemplateChanges(id, token) {
63
+ return new Promise(function (resolve, reject) {
64
+ const data = {};
65
+ const request = axios.get(`api/v1/skilltemplates/discard/${id}`, {
66
+ headers: { authorization: token },
67
+ data: data,
68
+ });
69
+ request
70
+ .then((response) => {
71
+ resolve(response.data);
72
+ })
73
+ .catch((error) => {
74
+ reject(error);
75
+ });
76
+ });
77
+ },
78
+
79
+ /**
80
+ * Get skill template information
81
+ * @param {String} id The id of the template
82
+ * @param {String} version The version of the template
83
+ * @param {String} token Authorization token
84
+ */
85
+ getSkillTemplateInformationById(id, version, token) {
86
+ return new Promise(function (resolve, reject) {
87
+ let confirmationRequest = axios.get(
88
+ `api/v1/skilltemplates/${id}/${version}`,
89
+ {
90
+ headers: { authorization: token },
91
+ }
92
+ );
93
+ confirmationRequest
94
+ .then((response) => {
95
+ resolve(response.data);
96
+ })
97
+ .catch((error) => {
98
+ reject(error);
99
+ });
100
+ });
101
+ },
102
+
103
+ /**
104
+ * Get skill template list
105
+ * @param {Array<String>} filter The filter used to select the template
106
+ * @param {String} version The version to be retrieved
107
+ * @param {boolean} includeDeleted When true it will return the deleted records as well
108
+ * @param {String} token Authorization token
109
+ */
110
+ getSkillTemplateList(filter, version, includeDeleted, token) {
111
+ return new Promise(function (resolve, reject) {
112
+ const requestData = {
113
+ version: version,
114
+ includeDeleted: includeDeleted,
115
+ };
116
+ if (filter) requestData.filter = filter;
117
+ let confirmationRequest = axios.post(
118
+ `api/v1/skilltemplates`,
119
+ requestData,
120
+ {
121
+ headers: { authorization: token },
122
+ }
123
+ );
124
+ confirmationRequest
125
+ .then((response) => {
126
+ resolve(response.data);
127
+ })
128
+ .catch((error) => {
129
+ reject(error);
130
+ });
131
+ });
132
+ },
133
+
134
+ /**
135
+ * Publish template
136
+ * @param {number} id The id of the template to be published
137
+ * @param {String} comment The comment to be include with the request
138
+ * @param {String} token Authorization token
139
+ */
140
+ publishTemplate(id, comment, token) {
141
+ return new Promise(function (resolve, reject) {
142
+ let data = {};
143
+ if (comment) data.comment = comment;
144
+
145
+ let confirmationRequest = axios.post(
146
+ `api/v1/skilltemplates/publish/${id}`,
147
+ data,
148
+ {
149
+ headers: { authorization: token },
150
+ }
151
+ );
152
+ confirmationRequest
153
+ .then((response) => {
154
+ resolve(response.data);
155
+ })
156
+ .catch((error) => {
157
+ reject(error);
158
+ });
159
+ });
160
+ },
161
+
162
+ /**
163
+ * Set template profile information
164
+ * @param {String} id The id of the template to be updated
165
+ * @param {Object} data Data used to update the template
166
+ * @param {String} token Authorization token
167
+ */
168
+ setTemplateInformation(id, data, token) {
169
+ return new Promise(function (resolve, reject) {
170
+ const requestData = {
171
+ data: data,
172
+ id: id,
173
+ };
174
+ let confirmationRequest = axios.post(
175
+ `api/v1/skilltemplates/update`,
176
+ requestData,
177
+ {
178
+ headers: { authorization: token },
179
+ }
180
+ );
181
+ confirmationRequest
182
+ .then((response) => {
183
+ resolve(response.data);
184
+ })
185
+ .catch((error) => {
186
+ reject(error);
187
+ });
188
+ });
189
+ },
190
+
191
+ /**
192
+ * Update the skill template tags
193
+ * @param {String} id The id of the template to be updated
194
+ * @param {Object} tags Updated template tags
195
+ * @param {String} token Authorization token
196
+ */
197
+ setTemplateTags(id, tags, token) {
198
+ return new Promise(function (resolve, reject) {
199
+ const requestData = {
200
+ tags: tags,
201
+ id: id,
202
+ };
203
+ let confirmationRequest = axios.post(
204
+ `api/v1/skilltemplates/updatetags/`,
205
+ requestData,
206
+ {
207
+ headers: { authorization: token },
208
+ }
209
+ );
210
+ confirmationRequest
211
+ .then((response) => {
212
+ resolve(response.data);
213
+ })
214
+ .catch((error) => {
215
+ reject(error);
216
+ });
217
+ });
218
+ },
219
+
220
+ /**
221
+ * Watch skill template
222
+ * @param {String} id The id of the skill template to be updated
223
+ * @param {Boolean} watch Set to true or false
224
+ * @param {String} token Authorization token
225
+ */
226
+ watchSkillTemplate(id, watch, token) {
227
+ return new Promise(function (resolve, reject) {
228
+ const requestData = {
229
+ id: id,
230
+ watch: watch,
231
+ };
232
+ let confirmationRequest = axios.post(
233
+ `api/v1/skilltemplates/watch`,
234
+ requestData,
235
+ {
236
+ headers: { authorization: token },
237
+ }
238
+ );
239
+ confirmationRequest
240
+ .then((response) => {
241
+ resolve(response.data);
242
+ })
243
+ .catch((error) => {
244
+ reject(error);
245
+ });
246
+ });
247
+ },
248
+ };
package/lib/teams.js ADDED
@@ -0,0 +1,277 @@
1
+ //
2
+ // Team specific requests
3
+ //
4
+ import axios from "./axios";
5
+
6
+ export default {
7
+ axios: axios,
8
+
9
+ /**
10
+ * Add users to team
11
+ * @param {String} teamId The team Id
12
+ * @param {Array<String>} users The users to be added
13
+ * @param {String} authToken - Authentication token
14
+ */
15
+ addUsersToTeam(teamId, users, authToken) {
16
+ return new Promise(function (resolve, reject) {
17
+ const request = axios.post(
18
+ `api/v1/teams/users/add`,
19
+ {
20
+ teamId: teamId,
21
+ users: users,
22
+ },
23
+ { headers: { authorization: authToken } }
24
+ );
25
+ request
26
+ .then((response) => {
27
+ resolve(response.data);
28
+ })
29
+ .catch((error) => {
30
+ reject(error);
31
+ });
32
+ });
33
+ },
34
+
35
+ /**
36
+ * Create team
37
+ * @param {String} name The name of the team
38
+ * @param {String} managerId The id of the manager
39
+ * @param {String} description The description of the team
40
+ * @param {String} authToken The authorization token
41
+ */
42
+ createTeam(name, managerId, description, authToken) {
43
+ return new Promise(function (resolve, reject) {
44
+ const request = axios.post(
45
+ `api/v1/teams/team`,
46
+ {
47
+ name: name,
48
+ managerId: managerId,
49
+ description: description,
50
+ },
51
+ { headers: { authorization: authToken } }
52
+ );
53
+ request
54
+ .then((response) => {
55
+ resolve(response.data);
56
+ })
57
+ .catch((error) => {
58
+ reject(error);
59
+ });
60
+ });
61
+ },
62
+
63
+ /**
64
+ * Delete team
65
+ * @param {String} teamId The team to be deleted
66
+ * @param {String} defaultTeamId The default team all the users will be moved to
67
+ * @param {String} authToken The authentication token
68
+ */
69
+ deleteTeam(teamId, defaultTeamId, authToken) {
70
+ return new Promise(function (resolve, reject) {
71
+ const request = axios.delete(`api/v1/teams/delete`, {
72
+ headers: { authorization: authToken },
73
+ data: {
74
+ id: teamId,
75
+ defaultTeamId: defaultTeamId,
76
+ },
77
+ });
78
+ request
79
+ .then((response) => {
80
+ resolve(response.data);
81
+ })
82
+ .catch((error) => {
83
+ reject(error);
84
+ });
85
+ });
86
+ },
87
+
88
+ /**
89
+ * Get team by Id
90
+ * @param {String} teamId The team Id
91
+ * @param {Boolean} includeUserSummaryInformation True if request to load user summary information
92
+ * @param {String} authToken The authentication token
93
+ */
94
+ getTeamById(teamId, includeUserSummaryInformation, authToken) {
95
+ return new Promise(function (resolve, reject) {
96
+ const request = axios.post(
97
+ `api/v1/teams/team/${teamId}`,
98
+ {
99
+ includeUserSummaryInformation: includeUserSummaryInformation,
100
+ },
101
+ { headers: { authorization: authToken } }
102
+ );
103
+ request
104
+ .then((response) => {
105
+ resolve(response.data);
106
+ })
107
+ .catch((error) => {
108
+ reject(error);
109
+ });
110
+ });
111
+ },
112
+
113
+ /**
114
+ * Get team roles
115
+ * @param {String} teamId The team Id
116
+ * @param {*} authToken The authentication token
117
+ */
118
+ getTeamByIdRoles(teamId, authToken) {
119
+ return new Promise(function (resolve, reject) {
120
+ const request = axios.get(`api/v1/teams/getroles/${teamId}`, {
121
+ headers: { authorization: authToken },
122
+ });
123
+ request
124
+ .then((response) => {
125
+ resolve(response.data);
126
+ })
127
+ .catch((error) => {
128
+ reject(error);
129
+ });
130
+ });
131
+ },
132
+
133
+ /**
134
+ * Get teams for current tenant
135
+ * @param {String} userId
136
+ * @param {*} authToken The authentication token
137
+ */
138
+ getTeams(authToken) {
139
+ return new Promise(function (resolve, reject) {
140
+ const request = axios.get(`api/v1/teams/`, {
141
+ headers: { authorization: authToken },
142
+ });
143
+ request
144
+ .then((response) => {
145
+ resolve(response.data);
146
+ })
147
+ .catch((error) => {
148
+ reject(error);
149
+ });
150
+ });
151
+ },
152
+
153
+ /**
154
+ * Get the team for the selected user
155
+ * @param {String} userId
156
+ * @param {Boolean} includeUserSummaryInformation True if request to load user summary information
157
+ * @param {String} authToken The authentication token
158
+ */
159
+ getTeamByUserId(userId, includeUserSummaryInformation, authToken) {
160
+ return new Promise(function (resolve, reject) {
161
+ const request = axios.post(
162
+ `/api/v1/teams/getuserteam/${userId ? userId : ""}`,
163
+ {
164
+ includeUserSummaryInformation: includeUserSummaryInformation,
165
+ },
166
+ { headers: { authorization: authToken } }
167
+ );
168
+ request
169
+ .then((response) => {
170
+ resolve(response.data);
171
+ })
172
+ .catch((error) => {
173
+ reject(error);
174
+ });
175
+ });
176
+ },
177
+
178
+ /**
179
+ * Get top team in the organization, usually the executive team
180
+ * @param {Boolean} includeUserSummaryInformation True if request to load user summary information
181
+ * @param {String} authToken The authentication token
182
+ */
183
+ getTopTeam(includeUserSummaryInformation, authToken) {
184
+ return new Promise(function (resolve, reject) {
185
+ const request = axios.post(
186
+ `api/v1/teams/gettopteam`,
187
+ {
188
+ includeUserSummaryInformation: includeUserSummaryInformation,
189
+ },
190
+ { headers: { authorization: authToken } }
191
+ );
192
+ request
193
+ .then((response) => {
194
+ resolve(response.data);
195
+ })
196
+ .catch((error) => {
197
+ reject(error);
198
+ });
199
+ });
200
+ },
201
+
202
+ /**
203
+ * Remove users from team
204
+ * @param {String} teamId The team Id
205
+ * @param {Array<String>} users The users to be removed from the team
206
+ * @param {String} authToken The authentication token
207
+ */
208
+ removeUsersFromTeam(teamId, users, authToken) {
209
+ return new Promise(function (resolve, reject) {
210
+ const request = axios.post(
211
+ `api/v1/teams/users/remove/`,
212
+ {
213
+ teamId: teamId,
214
+ users: users,
215
+ },
216
+ { headers: { authorization: authToken } }
217
+ );
218
+ request
219
+ .then((response) => {
220
+ resolve(response.data);
221
+ })
222
+ .catch((error) => {
223
+ reject(error);
224
+ });
225
+ });
226
+ },
227
+
228
+ /*
229
+ * Set team as defualt
230
+ * @param {String} teamId The team Id
231
+ * @param {String} authToken The authentication token
232
+ */
233
+ setDefault(teamId, authToken) {
234
+ return new Promise(function (resolve, reject) {
235
+ const request = axios.put(
236
+ `api/v1/teams/setDefault/`,
237
+ {
238
+ id: teamId,
239
+ },
240
+ { headers: { authorization: authToken } }
241
+ );
242
+ request
243
+ .then((response) => {
244
+ resolve(response.data);
245
+ })
246
+ .catch((error) => {
247
+ reject(error);
248
+ });
249
+ });
250
+ },
251
+
252
+ /**
253
+ * Update team
254
+ * @param {String} teamId The team Id
255
+ * @param {String} data The updated name of the team
256
+ * @param {String} authToken The authentication token
257
+ */
258
+ updateTeam(teamId, data, authToken) {
259
+ return new Promise(function (resolve, reject) {
260
+ const request = axios.patch(
261
+ `api/v1/teams/team/`,
262
+ {
263
+ id: teamId,
264
+ data: data,
265
+ },
266
+ { headers: { authorization: authToken } }
267
+ );
268
+ request
269
+ .then((response) => {
270
+ resolve(response.data);
271
+ })
272
+ .catch((error) => {
273
+ reject(error);
274
+ });
275
+ });
276
+ },
277
+ };