@stackfactor/client-api 1.0.32 → 1.0.34

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