@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.
@@ -1,272 +1,264 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
5
-
6
- /**
7
- * Create role template and set information
8
- * @param {Object} data
9
- * @param {String} token Authorization token
10
- */
11
- createRoleTemplate: (data, token) => {
12
- return new Promise(function (resolve, reject) {
13
- const requestData = {
14
- data: data,
15
- };
16
- let confirmationRequest = axios.put("api/v1/roletemplates", requestData, {
17
- headers: { authorization: token },
18
- });
19
- confirmationRequest
20
- .then((response) => {
21
- resolve(response.data);
22
- })
23
- .catch((error) => {
24
- reject(error);
25
- });
3
+ /**
4
+ * Create role template and set information
5
+ * @param {Object} data
6
+ * @param {String} token Authorization token
7
+ */
8
+ export const createRoleTemplate = (data, token) => {
9
+ return new Promise(function (resolve, reject) {
10
+ const requestData = {
11
+ data: data,
12
+ };
13
+ let confirmationRequest = axios.put("api/v1/roletemplates", requestData, {
14
+ headers: { authorization: token },
26
15
  });
27
- },
16
+ confirmationRequest
17
+ .then((response) => {
18
+ resolve(response.data);
19
+ })
20
+ .catch((error) => {
21
+ reject(error);
22
+ });
23
+ });
24
+ };
28
25
 
29
- /**
30
- * Delete role template
31
- * @param {String} id The id of the template to be deleted
32
- * @param {String} comment The comment included with the deletion
33
- * @param {String} token Authorization token
34
- */
35
- deleteRoleTemplate: (id, comment, token) => {
36
- return new Promise(function (resolve, reject) {
37
- const data = {
38
- id: id,
39
- };
40
- if (comment) data.comment = comment;
41
- const request = axios.delete(`api/v1/roletemplates/`, {
42
- headers: { authorization: token },
43
- data: data,
26
+ /**
27
+ * Delete role template
28
+ * @param {String} id The id of the template to be deleted
29
+ * @param {String} comment The comment included with the deletion
30
+ * @param {String} token Authorization token
31
+ */
32
+ export const deleteRoleTemplate = (id, comment, token) => {
33
+ return new Promise(function (resolve, reject) {
34
+ const data = {
35
+ id: id,
36
+ };
37
+ if (comment) data.comment = comment;
38
+ const request = axios.delete(`api/v1/roletemplates/`, {
39
+ headers: { authorization: token },
40
+ data: data,
41
+ });
42
+ request
43
+ .then((response) => {
44
+ resolve(response.data);
45
+ })
46
+ .catch((error) => {
47
+ reject(error);
44
48
  });
45
- request
46
- .then((response) => {
47
- resolve(response.data);
48
- })
49
- .catch((error) => {
50
- reject(error);
51
- });
49
+ });
50
+ };
51
+
52
+ /**
53
+ * Discard the role template draft changes
54
+ * @param {String} id The id of the role template to be deleted
55
+ * @param {String} token Authorization token
56
+ */
57
+ export const discardRoleTemplateChanges = (id, token) => {
58
+ return new Promise(function (resolve, reject) {
59
+ const data = {};
60
+ const request = axios.get(`api/v1/roletemplates/discard/${id}`, {
61
+ headers: { authorization: token },
62
+ data: data,
52
63
  });
53
- },
64
+ request
65
+ .then((response) => {
66
+ resolve(response.data);
67
+ })
68
+ .catch((error) => {
69
+ reject(error);
70
+ });
71
+ });
72
+ };
54
73
 
55
- /**
56
- * Discard the role template draft changes
57
- * @param {String} id The id of the role template to be deleted
58
- * @param {String} token Authorization token
59
- */
60
- discardRoleTemplateChanges: (id, token) => {
61
- return new Promise(function (resolve, reject) {
62
- const data = {};
63
- const request = axios.get(`api/v1/roletemplates/discard/${id}`, {
74
+ /**
75
+ * Get role template information
76
+ * @param {String} id The id of the template
77
+ * @param {String} token Authorization token
78
+ */
79
+ export const getRoleTemplateInformationById = (id, version, token) => {
80
+ return new Promise(function (resolve, reject) {
81
+ let confirmationRequest = axios.get(
82
+ `api/v1/roletemplates/${id}/${version}`,
83
+ {
64
84
  headers: { authorization: token },
65
- data: data,
85
+ }
86
+ );
87
+ confirmationRequest
88
+ .then((response) => {
89
+ resolve(response.data);
90
+ })
91
+ .catch((error) => {
92
+ reject(error);
66
93
  });
67
- request
68
- .then((response) => {
69
- resolve(response.data);
70
- })
71
- .catch((error) => {
72
- reject(error);
73
- });
74
- });
75
- },
76
-
77
- /**
78
- * Get role template information
79
- * @param {String} id The id of the template
80
- * @param {String} token Authorization token
81
- */
82
- getRoleTemplateInformationById: (id, version, token) => {
83
- return new Promise(function (resolve, reject) {
84
- let confirmationRequest = axios.get(
85
- `api/v1/roletemplates/${id}/${version}`,
86
- {
87
- headers: { authorization: token },
88
- }
89
- );
90
- confirmationRequest
91
- .then((response) => {
92
- resolve(response.data);
93
- })
94
- .catch((error) => {
95
- reject(error);
96
- });
97
- });
98
- },
94
+ });
95
+ };
99
96
 
100
- /**
101
- * Get role template list
102
- * @param {Array<String>} filter The list of integrations to be received
103
- * @param {boolean} includeDeleted When true it will return the deleted records as well
104
- * @param {String} token Authorization token
105
- */
106
- getRoleTemplateList: (filter, version, includeDeleted, token) => {
107
- return new Promise(function (resolve, reject) {
108
- const requestData = {
109
- version: version,
110
- includeDeleted: includeDeleted,
111
- };
112
- if (filter) requestData.filter = filter;
113
- let confirmationRequest = axios.post(
114
- `api/v1/roletemplates`,
115
- requestData,
116
- {
117
- headers: { authorization: token },
118
- }
119
- );
120
- confirmationRequest
121
- .then((response) => {
122
- resolve(response.data);
123
- })
124
- .catch((error) => {
125
- reject(error);
126
- });
97
+ /**
98
+ * Get role template list
99
+ * @param {Array<String>} filter The list of integrations to be received
100
+ * @param {boolean} includeDeleted When true it will return the deleted records as well
101
+ * @param {String} token Authorization token
102
+ */
103
+ export const getRoleTemplateList = (filter, version, includeDeleted, token) => {
104
+ return new Promise(function (resolve, reject) {
105
+ const requestData = {
106
+ version: version,
107
+ includeDeleted: includeDeleted,
108
+ };
109
+ if (filter) requestData.filter = filter;
110
+ let confirmationRequest = axios.post(`api/v1/roletemplates`, requestData, {
111
+ headers: { authorization: token },
127
112
  });
128
- },
113
+ confirmationRequest
114
+ .then((response) => {
115
+ resolve(response.data);
116
+ })
117
+ .catch((error) => {
118
+ reject(error);
119
+ });
120
+ });
121
+ };
129
122
 
130
- /**
131
- * Import role templates
132
- * @param {Array<String>} data The list of role templates to be imported
133
- * @param {String} token
134
- * @returns
135
- */
136
- importRoleTemplates: (data, token) => {
137
- return new Promise(function (resolve, reject) {
138
- const requestData = {
139
- data: data,
140
- };
141
- let confirmationRequest = axios.post(
142
- `api/v1/roletemplates/import`,
143
- requestData,
144
- {
145
- headers: { authorization: token },
146
- }
147
- );
148
- confirmationRequest
123
+ /**
124
+ * Import role templates
125
+ * @param {Array<String>} data The list of role templates to be imported
126
+ * @param {String} token
127
+ * @returns
128
+ */
129
+ export const importRoleTemplates = (data, token) => {
130
+ return new Promise(function (resolve, reject) {
131
+ const requestData = {
132
+ data: data,
133
+ };
134
+ let confirmationRequest = axios.post(
135
+ `api/v1/roletemplates/import`,
136
+ requestData,
137
+ {
138
+ headers: { authorization: token },
139
+ }
140
+ );
141
+ confirmationRequest
149
142
 
150
- .then((response) => {
151
- resolve(response.data);
152
- })
153
- .catch((error) => {
154
- reject(error);
155
- });
156
- });
157
- },
143
+ .then((response) => {
144
+ resolve(response.data);
145
+ })
146
+ .catch((error) => {
147
+ reject(error);
148
+ });
149
+ });
150
+ };
158
151
 
159
- /**
160
- * Publish template
161
- * @param {number} id The id of the template to be published
162
- * @param {String} comment The comment to be include with the request
163
- * @param {String} token Authorization token
164
- */
165
- publishTemplate: (id, comment, token) => {
166
- return new Promise(function (resolve, reject) {
167
- let data = {};
168
- if (comment) data.comment = comment;
169
- let confirmationRequest = axios.post(
170
- `api/v1/roletemplates/publish/${id}`,
171
- data,
172
- {
173
- headers: { authorization: token },
174
- }
175
- );
176
- confirmationRequest
177
- .then((response) => {
178
- resolve(response.data);
179
- })
180
- .catch((error) => {
181
- reject(error);
182
- });
183
- });
184
- },
152
+ /**
153
+ * Publish template
154
+ * @param {number} id The id of the template to be published
155
+ * @param {String} comment The comment to be include with the request
156
+ * @param {String} token Authorization token
157
+ */
158
+ export const publishTemplate = (id, comment, token) => {
159
+ return new Promise(function (resolve, reject) {
160
+ let data = {};
161
+ if (comment) data.comment = comment;
162
+ let confirmationRequest = axios.post(
163
+ `api/v1/roletemplates/publish/${id}`,
164
+ data,
165
+ {
166
+ headers: { authorization: token },
167
+ }
168
+ );
169
+ confirmationRequest
170
+ .then((response) => {
171
+ resolve(response.data);
172
+ })
173
+ .catch((error) => {
174
+ reject(error);
175
+ });
176
+ });
177
+ };
185
178
 
186
- /**
187
- * Set template profile information
188
- * @param {String} id The id of the template to be updated
189
- * @param {Object} data Data used to update the template
190
- * @param {String} token Authorization token
191
- */
192
- setTemplateInformation: (id, data, token) => {
193
- return new Promise(function (resolve, reject) {
194
- const requestData = {
195
- data: data,
196
- id: id,
197
- };
198
- let confirmationRequest = axios.post(
199
- `api/v1/roletemplates/update`,
200
- requestData,
201
- {
202
- headers: { authorization: token },
203
- }
204
- );
205
- confirmationRequest
206
- .then((response) => {
207
- resolve(response.data);
208
- })
209
- .catch((error) => {
210
- reject(error);
211
- });
212
- });
213
- },
179
+ /**
180
+ * Set template profile information
181
+ * @param {String} id The id of the template to be updated
182
+ * @param {Object} data Data used to update the template
183
+ * @param {String} token Authorization token
184
+ */
185
+ export const setTemplateInformation = (id, data, token) => {
186
+ return new Promise(function (resolve, reject) {
187
+ const requestData = {
188
+ data: data,
189
+ id: id,
190
+ };
191
+ let confirmationRequest = axios.post(
192
+ `api/v1/roletemplates/update`,
193
+ requestData,
194
+ {
195
+ headers: { authorization: token },
196
+ }
197
+ );
198
+ confirmationRequest
199
+ .then((response) => {
200
+ resolve(response.data);
201
+ })
202
+ .catch((error) => {
203
+ reject(error);
204
+ });
205
+ });
206
+ };
214
207
 
215
- /**
216
- * Update the role template tags
217
- * @param {String} id The id of the template to be updated
218
- * @param {Object} tags Updated template tags
219
- * @param {String} token Authorization token
220
- */
221
- setTemplateTags: (id, tags, token) => {
222
- return new Promise(function (resolve, reject) {
223
- const requestData = {
224
- tags: tags,
225
- id: id,
226
- };
227
- let confirmationRequest = axios.post(
228
- `api/v1/roletemplates/updatetags/`,
229
- requestData,
230
- {
231
- headers: { authorization: token },
232
- }
233
- );
234
- confirmationRequest
235
- .then((response) => {
236
- resolve(response.data);
237
- })
238
- .catch((error) => {
239
- reject(error);
240
- });
241
- });
242
- },
208
+ /**
209
+ * Update the role template tags
210
+ * @param {String} id The id of the template to be updated
211
+ * @param {Object} tags Updated template tags
212
+ * @param {String} token Authorization token
213
+ */
214
+ export const setTemplateTags = (id, tags, token) => {
215
+ return new Promise(function (resolve, reject) {
216
+ const requestData = {
217
+ tags: tags,
218
+ id: id,
219
+ };
220
+ let confirmationRequest = axios.post(
221
+ `api/v1/roletemplates/updatetags/`,
222
+ requestData,
223
+ {
224
+ headers: { authorization: token },
225
+ }
226
+ );
227
+ confirmationRequest
228
+ .then((response) => {
229
+ resolve(response.data);
230
+ })
231
+ .catch((error) => {
232
+ reject(error);
233
+ });
234
+ });
235
+ };
243
236
 
244
- /**
245
- * Watch role template
246
- * @param {String} id The id of the skill to be updated
247
- * @param {Boolean} watch Set to true or false
248
- * @param {String} token Authorization token
249
- */
250
- watchRoleTemplate: (id, watch, token) => {
251
- return new Promise(function (resolve, reject) {
252
- const requestData = {
253
- id: id,
254
- watch: watch,
255
- };
256
- let confirmationRequest = axios.post(
257
- `api/v1/roletemplates/watch`,
258
- requestData,
259
- {
260
- headers: { authorization: token },
261
- }
262
- );
263
- confirmationRequest
264
- .then((response) => {
265
- resolve(response.data);
266
- })
267
- .catch((error) => {
268
- reject(error);
269
- });
270
- });
271
- },
237
+ /**
238
+ * Watch role template
239
+ * @param {String} id The id of the skill to be updated
240
+ * @param {Boolean} watch Set to true or false
241
+ * @param {String} token Authorization token
242
+ */
243
+ export const watchRoleTemplate = (id, watch, token) => {
244
+ return new Promise(function (resolve, reject) {
245
+ const requestData = {
246
+ id: id,
247
+ watch: watch,
248
+ };
249
+ let confirmationRequest = axios.post(
250
+ `api/v1/roletemplates/watch`,
251
+ requestData,
252
+ {
253
+ headers: { authorization: token },
254
+ }
255
+ );
256
+ confirmationRequest
257
+ .then((response) => {
258
+ resolve(response.data);
259
+ })
260
+ .catch((error) => {
261
+ reject(error);
262
+ });
263
+ });
272
264
  };