@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/index.js CHANGED
@@ -18,7 +18,6 @@ const skillAssessment = require("./lib/skillAssessments");
18
18
  const skillAssessmentTestingSession = require("./lib/skillAssessmentTestingSession");
19
19
  const skillTemplate = require("./lib/skillTemplate");
20
20
  const team = require("./lib/teams");
21
- const templates = require("./lib/templates");
22
21
  const tenant = require("./lib/tenants");
23
22
  const trainingPlanTemplate = require("./lib/trainingPlanTemplate");
24
23
  const trainingPlan = require("./lib/trainingPlans");
@@ -51,7 +50,6 @@ module.exports = {
51
50
  skillAssessmentTestingSession,
52
51
  skillTemplate,
53
52
  team,
54
- templates,
55
53
  tenant,
56
54
  trainingPlanTemplate,
57
55
  trainingPlan,
@@ -1,240 +1,216 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
3
+ /**
4
+ * Get all permissions
5
+ * @param {String} authToken The authentication token
6
+ */
7
+ export const getAllUserNotifications = (authToken) => {
8
+ return new Promise(function (resolve, reject) {
9
+ const request = axios.get(`api/v1/actionnotifications`, {
10
+ headers: { authorization: authToken },
11
+ });
12
+ request
13
+ .then((response) => {
14
+ resolve(response.data);
15
+ })
16
+ .catch((error) => {
17
+ reject(error);
18
+ });
19
+ });
20
+ };
5
21
 
6
- /**
7
- * Get all permissions
8
- * @param {String} authToken The authentication token
9
- */
10
- getAllUserNotifications: (authToken) => {
11
- return new Promise(function (resolve, reject) {
12
- const request = axios.get(`api/v1/actionnotifications`, {
13
- headers: { authorization: authToken },
22
+ /**
23
+ * Mark notifications as open or viewed
24
+ * @param {Array<String>} ids The id of the notifications to be marked
25
+ * @param {String} status The new status
26
+ * @param {String} authToken The authentication token
27
+ */
28
+ export const markNotifications = (ids, status, authToken) => {
29
+ return new Promise(function (resolve, reject) {
30
+ const request = axios.put(
31
+ `api/v1/actionnotifications/mark`,
32
+ {
33
+ ids: ids,
34
+ status: status,
35
+ },
36
+ { headers: { authorization: authToken } }
37
+ );
38
+ request
39
+ .then((response) => {
40
+ resolve(response.data);
41
+ })
42
+ .catch((error) => {
43
+ reject(error);
14
44
  });
15
- request
16
- .then((response) => {
17
- resolve(response.data);
18
- })
19
- .catch((error) => {
20
- reject(error);
21
- });
22
- });
23
- },
45
+ });
46
+ };
24
47
 
25
- /**
26
- * Mark notifications as open or viewed
27
- * @param {Array<String>} ids The id of the notifications to be marked
28
- * @param {String} status The new status
29
- * @param {String} authToken The authentication token
30
- */
31
- markNotifications: (ids, status, authToken) => {
32
- return new Promise(function (resolve, reject) {
33
- const request = axios.put(
34
- `api/v1/actionnotifications/mark`,
35
- {
36
- ids: ids,
37
- status: status,
38
- },
39
- { headers: { authorization: authToken } }
40
- );
41
- request
42
- .then((response) => {
43
- resolve(response.data);
44
- })
45
- .catch((error) => {
46
- reject(error);
47
- });
48
- });
49
- },
48
+ /**
49
+ * Process a notification
50
+ * @param {String} id The notification id
51
+ * @param {String} action The action to be executed
52
+ * @param {String} comment The comment to be saved in the notification
53
+ * @param {String} authToken The authentication token
54
+ */
55
+ export const processNotification = (id, action, comment, authToken) => {
56
+ return new Promise(function (resolve, reject) {
57
+ const request = axios.put(
58
+ `api/v1/actionnotifications/process`,
59
+ {
60
+ id: id,
61
+ action: action,
62
+ comment: comment,
63
+ },
64
+ { headers: { authorization: authToken } }
65
+ );
66
+ request
67
+ .then((response) => {
68
+ resolve(response.data);
69
+ })
70
+ .catch((error) => {
71
+ reject(error);
72
+ });
73
+ });
74
+ };
50
75
 
51
- /**
52
- * Process a notification
53
- * @param {String} id The notification id
54
- * @param {String} action The action to be executed
55
- * @param {String} comment The comment to be saved in the notification
56
- * @param {String} authToken The authentication token
57
- */
58
- processNotification: (id, action, comment, authToken) => {
59
- return new Promise(function (resolve, reject) {
60
- const request = axios.put(
61
- `api/v1/actionnotifications/process`,
62
- {
63
- id: id,
64
- action: action,
65
- comment: comment,
66
- },
67
- { headers: { authorization: authToken } }
68
- );
69
- request
70
- .then((response) => {
71
- resolve(response.data);
72
- })
73
- .catch((error) => {
74
- reject(error);
75
- });
76
+ /**
77
+ * Get groups for current tenant
78
+ * @param {String} authToken The authentication token
79
+ */
80
+ export const getGroups = (authToken) => {
81
+ return new Promise(function (resolve, reject) {
82
+ const request = axios.get(`api/v1/groups/`, {
83
+ headers: { authorization: authToken },
76
84
  });
77
- },
78
-
79
- /**
80
- * Get groups for current tenant
81
- * @param {String} authToken The authentication token
82
- */
83
- getGroups: (authToken) => {
84
- return new Promise(function (resolve, reject) {
85
- const request = axios.get(`api/v1/groups/`, {
86
- headers: { authorization: authToken },
85
+ request
86
+ .then((response) => {
87
+ resolve(response.data);
88
+ })
89
+ .catch((error) => {
90
+ reject(error);
87
91
  });
88
- request
89
- .then((response) => {
90
- resolve(response.data);
91
- })
92
- .catch((error) => {
93
- reject(error);
94
- });
95
- });
96
- },
92
+ });
93
+ };
97
94
 
98
- /**
99
- * Get current user permissions
100
- * @param {String} authToken The authentication token
101
- */
102
- getUserPermissions: (authToken) => {
103
- return new Promise(function (resolve, reject) {
104
- const request = axios.get(`api/v1/groups/users/getuserpermissions`, {
105
- headers: { authorization: authToken },
106
- });
107
- request
108
- .then((response) => {
109
- resolve(response.data);
110
- })
111
- .catch((error) => {
112
- reject(error);
113
- });
95
+ /**
96
+ * Get current user permissions
97
+ * @param {String} authToken The authentication token
98
+ */
99
+ export const getUserPermissions = (authToken) => {
100
+ return new Promise(function (resolve, reject) {
101
+ const request = axios.get(`api/v1/groups/users/getuserpermissions`, {
102
+ headers: { authorization: authToken },
114
103
  });
115
- },
104
+ request
105
+ .then((response) => {
106
+ resolve(response.data);
107
+ })
108
+ .catch((error) => {
109
+ reject(error);
110
+ });
111
+ });
112
+ };
116
113
 
117
- /**
118
- * Build in permissions
119
- */
120
- permissions: {
121
- ADMIN_PROMOTE_CONTENT: "5ea3d10bea252025c8ec351b",
122
- ADMIN_AUTHOR_CONTENT: "5ea3d1152839450e16e72bba",
123
- AUTHOR_CONTENT: "5fac210560e43de7c6b4a208",
124
- MANAGE_BILLING: "5e1570cd03f676213bfdcd08",
125
- MANAGE_CONTENT_PROVIDERS: "5f0fa12f16a720fde58ea820",
126
- MANAGE_GROUPS: "5dd612fe59e518ac87b8cf8e",
127
- MANAGE_OWN_PROFILE_INFORMATION_AUTO_APP: "5fac210e7e6539d37a897c94",
128
- MANAGE_ORGANIZATION_INFORMATION: "5dd612d5338ea9a6ae6326da",
129
- MANAGE_OWN_SKILL_SET_AUTO_APPROVE: "5fac21164351c6727a34cd4e",
130
- MANAGE_SETTINGS: "5e1570e087d836dc77888a5f",
131
- MANAGE_TEAM_INFORMATION_AUTO_APPROVE: "5fac211e6c8f874bd7137b98",
132
- MANAGE_TEAMS: "5dd61314afc2455a89b1a37b",
133
- MANAGE_USERS: "5dd612e40f0bc559c41a2b29",
134
- PROMOTE_CONTENT: "5fac2126427ce31f8a92c0cb",
135
- MANAGE_PLAN_TEMPLATES: "5dd61305a73c68b44c3f0827",
136
- },
137
- /**
138
- * Remove permissions from group
139
- * @param {String} groupId The group Id
140
- * @param {Array<String>} permissions The permissions to be removed from the group
141
- * @param {String} authToken The authentication token
142
- */
143
- removePermissionsFromGroup: (groupId, permissions, authToken) => {
144
- return new Promise(function (resolve, reject) {
145
- const request = axios.post(
146
- `api/v1/groups/permissions/remove/`,
147
- {
148
- groupId: groupId,
149
- permissions: permissions,
150
- },
151
- { headers: { authorization: authToken } }
152
- );
153
- request
154
- .then((response) => {
155
- resolve(response.data);
156
- })
157
- .catch((error) => {
158
- reject(error);
159
- });
160
- });
161
- },
114
+ /**
115
+ * Remove permissions from group
116
+ * @param {String} groupId The group Id
117
+ * @param {Array<String>} permissions The permissions to be removed from the group
118
+ * @param {String} authToken The authentication token
119
+ */
120
+ export const removePermissionsFromGroup = (groupId, permissions, authToken) => {
121
+ return new Promise(function (resolve, reject) {
122
+ const request = axios.post(
123
+ `api/v1/groups/permissions/remove/`,
124
+ {
125
+ groupId: groupId,
126
+ permissions: permissions,
127
+ },
128
+ { headers: { authorization: authToken } }
129
+ );
130
+ request
131
+ .then((response) => {
132
+ resolve(response.data);
133
+ })
134
+ .catch((error) => {
135
+ reject(error);
136
+ });
137
+ });
138
+ };
162
139
 
163
- /**
164
- * Remove users from group
165
- * @param {String} groupId The group Id
166
- * @param {Array<String>} users The users to be removed from the group
167
- * @param {String} authToken The authentication token
168
- */
169
- removeUsersFromGroup: (groupId, users, authToken) => {
170
- return new Promise(function (resolve, reject) {
171
- const request = axios.post(
172
- `api/v1/groups/users/remove/`,
173
- {
174
- groupId: groupId,
175
- users: users,
176
- },
177
- { headers: { authorization: authToken } }
178
- );
179
- request
180
- .then((response) => {
181
- resolve(response.data);
182
- })
183
- .catch((error) => {
184
- reject(error);
185
- });
186
- });
187
- },
140
+ /**
141
+ * Remove users from group
142
+ * @param {String} groupId The group Id
143
+ * @param {Array<String>} users The users to be removed from the group
144
+ * @param {String} authToken The authentication token
145
+ */
146
+ export const removeUsersFromGroup = (groupId, users, authToken) => {
147
+ return new Promise(function (resolve, reject) {
148
+ const request = axios.post(
149
+ `api/v1/groups/users/remove/`,
150
+ {
151
+ groupId: groupId,
152
+ users: users,
153
+ },
154
+ { headers: { authorization: authToken } }
155
+ );
156
+ request
157
+ .then((response) => {
158
+ resolve(response.data);
159
+ })
160
+ .catch((error) => {
161
+ reject(error);
162
+ });
163
+ });
164
+ };
188
165
 
189
- /*
190
- * Set group as defualt
191
- * @param {String} groupId The group Id
192
- * @param {String} authToken The authentication token
193
- */
194
- setDefault: (groupId, authToken) => {
195
- return new Promise(function (resolve, reject) {
196
- const request = axios.put(
197
- `api/v1/groups/setDefault/`,
198
- {
199
- id: groupId,
200
- },
201
- { headers: { authorization: authToken } }
202
- );
203
- request
204
- .then((response) => {
205
- resolve(response.data);
206
- })
207
- .catch((error) => {
208
- reject(error);
209
- });
210
- });
211
- },
166
+ /*
167
+ * Set group as defualt
168
+ * @param {String} groupId The group Id
169
+ * @param {String} authToken The authentication token
170
+ */
171
+ export const setDefault = (groupId, authToken) => {
172
+ return new Promise(function (resolve, reject) {
173
+ const request = axios.put(
174
+ `api/v1/groups/setDefault/`,
175
+ {
176
+ id: groupId,
177
+ },
178
+ { headers: { authorization: authToken } }
179
+ );
180
+ request
181
+ .then((response) => {
182
+ resolve(response.data);
183
+ })
184
+ .catch((error) => {
185
+ reject(error);
186
+ });
187
+ });
188
+ };
212
189
 
213
- /**
214
- * Update group
215
- * @param {String} groupId The group Id
216
- * @param {string} name The updated name of the group
217
- * @param {string} description The updated description of the group
218
- * @param {String} authToken The authentication token
219
- */
220
- updateGroup: (groupId, name, description, authToken) => {
221
- return new Promise(function (resolve, reject) {
222
- const request = axios.patch(
223
- `api/v1/groups/group/`,
224
- {
225
- id: groupId,
226
- name: name,
227
- description: description,
228
- },
229
- { headers: { authorization: authToken } }
230
- );
231
- request
232
- .then((response) => {
233
- resolve(response.data);
234
- })
235
- .catch((error) => {
236
- reject(error);
237
- });
238
- });
239
- },
190
+ /**
191
+ * Update group
192
+ * @param {String} groupId The group Id
193
+ * @param {string} name The updated name of the group
194
+ * @param {string} description The updated description of the group
195
+ * @param {String} authToken The authentication token
196
+ */
197
+ export const updateGroup = (groupId, name, description, authToken) => {
198
+ return new Promise(function (resolve, reject) {
199
+ const request = axios.patch(
200
+ `api/v1/groups/group/`,
201
+ {
202
+ id: groupId,
203
+ name: name,
204
+ description: description,
205
+ },
206
+ { headers: { authorization: authToken } }
207
+ );
208
+ request
209
+ .then((response) => {
210
+ resolve(response.data);
211
+ })
212
+ .catch((error) => {
213
+ reject(error);
214
+ });
215
+ });
240
216
  };
package/lib/address.js CHANGED
@@ -1,29 +1,23 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
5
-
6
- /**
7
- * Validate Address
8
- *
9
- * @param {String} input - the address in raw format
10
- * @param {String} authToken - Authorization token
11
- *
12
- */
13
- autoComplete: (input, authToken) => {
14
- return new Promise(function (resolve, reject) {
15
- const getAddressesRequest = axios.post(
16
- `api/v1/address/autocomplete/`,
17
- { input: input },
18
- { headers: { authorization: authToken } }
19
- );
20
- getAddressesRequest
21
- .then((response) => {
22
- resolve(response.data);
23
- })
24
- .catch((error) => {
25
- reject(error);
26
- });
27
- });
28
- },
3
+ /**
4
+ * Validate Address
5
+ * @param {String} input - the address in raw format
6
+ * @param {String} authToken - Authorization token
7
+ */
8
+ export const autoComplete = (input, authToken) => {
9
+ return new Promise(function (resolve, reject) {
10
+ const getAddressesRequest = axios.post(
11
+ `api/v1/address/autocomplete/`,
12
+ { input: input },
13
+ { headers: { authorization: authToken } }
14
+ );
15
+ getAddressesRequest
16
+ .then((response) => {
17
+ resolve(response.data);
18
+ })
19
+ .catch((error) => {
20
+ reject(error);
21
+ });
22
+ });
29
23
  };
@@ -4,7 +4,7 @@ import utils from "./utils";
4
4
 
5
5
  const baseUrl = utils.getBaseUrl();
6
6
 
7
- export const axios = client.create({
7
+ export default client.create({
8
8
  baseURL: baseUrl,
9
9
  httpsAgent: new https.Agent({
10
10
  rejectUnauthorized: false,
package/lib/config.js CHANGED
@@ -1,70 +1,66 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
5
-
6
- /**
7
- * Get the specified configuration by Id. It returns a promise
8
- * @param {String} id - the id of the configuration element
9
- * @param {String} authToken - Authorization token
10
- */
11
- getConfigurationById: (id, authToken) => {
12
- return new Promise(function (resolve, reject) {
13
- const getConfigInformationRequest = axios.get(
14
- `api/v1/configurations/configuration/id/${id}`,
15
- { headers: { authorization: authToken } }
16
- );
17
- getConfigInformationRequest
18
- .then((response) => {
19
- resolve(response.data);
20
- })
21
- .catch((error) => {
22
- reject(error);
23
- });
24
- });
25
- },
3
+ /**
4
+ * Get the specified configuration by Id. It returns a promise
5
+ * @param {String} id - the id of the configuration element
6
+ * @param {String} authToken - Authorization token
7
+ */
8
+ export const getConfigurationById = (id, authToken) => {
9
+ return new Promise(function (resolve, reject) {
10
+ const getConfigInformationRequest = axios.get(
11
+ `api/v1/configurations/configuration/id/${id}`,
12
+ { headers: { authorization: authToken } }
13
+ );
14
+ getConfigInformationRequest
15
+ .then((response) => {
16
+ resolve(response.data);
17
+ })
18
+ .catch((error) => {
19
+ reject(error);
20
+ });
21
+ });
22
+ };
26
23
 
27
- /**
28
- * Get the specified configuration by type. It returns a promise
29
- * @param {String} type - the id of the configuration element
30
- * @param {String} authToken - Authorization token
31
- */
32
- getConfigurationByType: (type, authToken) => {
33
- return new Promise(function (resolve, reject) {
34
- const getConfigInformationRequest = axios.get(
35
- `api/v1/configurations/configuration/type/${type}`,
36
- { headers: { authorization: authToken } }
37
- );
38
- getConfigInformationRequest
39
- .then((response) => {
40
- resolve(response.data);
41
- })
42
- .catch((error) => {
43
- reject(error);
44
- });
45
- });
46
- },
24
+ /**
25
+ * Get the specified configuration by type. It returns a promise
26
+ * @param {String} type - the id of the configuration element
27
+ * @param {String} authToken - Authorization token
28
+ */
29
+ export const getConfigurationByType = (type, authToken) => {
30
+ return new Promise(function (resolve, reject) {
31
+ const getConfigInformationRequest = axios.get(
32
+ `api/v1/configurations/configuration/type/${type}`,
33
+ { headers: { authorization: authToken } }
34
+ );
35
+ getConfigInformationRequest
36
+ .then((response) => {
37
+ resolve(response.data);
38
+ })
39
+ .catch((error) => {
40
+ reject(error);
41
+ });
42
+ });
43
+ };
47
44
 
48
- /**
49
- * Set the specified configuration by Id. It returns a promise
50
- * @param {String} id - the id of the configuration element
51
- * @param {Object} data - the object containing the updated configuration element
52
- * @param {String} authToken - Authorization token
53
- */
54
- setConfigurationById: (id, data, authToken) => {
55
- return new Promise(function (resolve, reject) {
56
- const getConfigInformationRequest = axios.post(
57
- `api/v1/configurations/configuration/${id}`,
58
- { data: data },
59
- { headers: { authorization: authToken } }
60
- );
61
- getConfigInformationRequest
62
- .then((response) => {
63
- resolve(response.data);
64
- })
65
- .catch((error) => {
66
- reject(error);
67
- });
68
- });
69
- },
45
+ /**
46
+ * Set the specified configuration by Id. It returns a promise
47
+ * @param {String} id - the id of the configuration element
48
+ * @param {Object} data - the object containing the updated configuration element
49
+ * @param {String} authToken - Authorization token
50
+ */
51
+ export const setConfigurationById = (id, data, authToken) => {
52
+ return new Promise(function (resolve, reject) {
53
+ const getConfigInformationRequest = axios.post(
54
+ `api/v1/configurations/configuration/${id}`,
55
+ { data: data },
56
+ { headers: { authorization: authToken } }
57
+ );
58
+ getConfigInformationRequest
59
+ .then((response) => {
60
+ resolve(response.data);
61
+ })
62
+ .catch((error) => {
63
+ reject(error);
64
+ });
65
+ });
70
66
  };