@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/index.js +0 -2
- package/lib/actionNotifications.js +202 -226
- package/lib/address.js +21 -27
- package/lib/axiosClient.js +1 -1
- package/lib/config.js +62 -66
- package/lib/dashboard.js +64 -68
- package/lib/departmentTrainingPlans.js +159 -153
- package/lib/groups.js +266 -291
- package/lib/integration.js +307 -312
- package/lib/integrationConfiguration.js +96 -90
- package/lib/integrations/contentGenerator.js +71 -74
- package/lib/learningContent.js +239 -240
- package/lib/logger.js +51 -56
- package/lib/role.js +238 -245
- package/lib/roleTemplate.js +247 -255
- package/lib/skill.js +299 -311
- package/lib/skillAssessmentTestingSession.js +132 -137
- package/lib/skillAssessments.js +125 -129
- package/lib/skillTemplate.js +250 -255
- package/lib/teams.js +261 -257
- package/lib/tenants.js +48 -52
- package/lib/trainingPlanTemplate.js +203 -202
- package/lib/trainingPlans.js +249 -251
- package/lib/userInformation.js +97 -85
- package/lib/users.js +557 -555
- package/lib/utils.js +38 -42
- package/package.json +2 -1
- package/lib/templates.js +0 -148
package/lib/integration.js
CHANGED
|
@@ -1,341 +1,336 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const errorToString = axios.errorToString;
|
|
1
|
+
import axios, { errorToString } from "./axiosClient";
|
|
3
2
|
const axiosLib = require("axios");
|
|
4
3
|
const htmlParser = require("node-html-parser");
|
|
5
4
|
const htmlToText = require("html2plaintext");
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
let confirmationRequest = axios.put("api/v1/integrations/", requestData, {
|
|
21
|
-
headers: { authorization: token },
|
|
22
|
-
});
|
|
23
|
-
confirmationRequest
|
|
24
|
-
.then((response) => {
|
|
25
|
-
resolve(response.data);
|
|
26
|
-
})
|
|
27
|
-
.catch((error) => {
|
|
28
|
-
reject(error);
|
|
29
|
-
});
|
|
6
|
+
/**
|
|
7
|
+
* Create integration and set information
|
|
8
|
+
* @param {Object} data The new integration information
|
|
9
|
+
* @param {String} token Authorization token
|
|
10
|
+
*/
|
|
11
|
+
export const createIntegration = (data, token) => {
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
const requestData = {
|
|
14
|
+
data: data,
|
|
15
|
+
};
|
|
16
|
+
let confirmationRequest = axios.put("api/v1/integrations/", requestData, {
|
|
17
|
+
headers: { authorization: token },
|
|
30
18
|
});
|
|
31
|
-
|
|
19
|
+
confirmationRequest
|
|
20
|
+
.then((response) => {
|
|
21
|
+
resolve(response.data);
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
reject(error);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Delete integration
|
|
31
|
+
* @param {String} id The id of the integration to be deleted
|
|
32
|
+
* @param {String} token Authorization token
|
|
33
|
+
*/
|
|
34
|
+
export const deleteIntegration = (id, token) => {
|
|
35
|
+
return new Promise(function (resolve, reject) {
|
|
36
|
+
const request = axios.delete(`api/v1/integrations/`, {
|
|
37
|
+
headers: { authorization: token },
|
|
38
|
+
data: {
|
|
39
|
+
id: id,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
request
|
|
43
|
+
.then((response) => {
|
|
44
|
+
resolve(response.data);
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
reject(error);
|
|
45
48
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Discard the integration 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 discardIntegrationChanges = (id, token) => {
|
|
58
|
+
return new Promise(function (resolve, reject) {
|
|
59
|
+
const data = {};
|
|
60
|
+
const request = axios.get(`api/v1/integrations/discard/${id}`, {
|
|
61
|
+
headers: { authorization: token },
|
|
62
|
+
data: data,
|
|
53
63
|
});
|
|
54
|
-
|
|
64
|
+
request
|
|
65
|
+
.then((response) => {
|
|
66
|
+
resolve(response.data);
|
|
67
|
+
})
|
|
68
|
+
.catch((error) => {
|
|
69
|
+
reject(error);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Get integration information
|
|
76
|
+
* @param {String} id The id of the integration
|
|
77
|
+
* @param {String} version The version of the integration to be received
|
|
78
|
+
* @param {String} token Authorization token
|
|
79
|
+
*/
|
|
80
|
+
export const getIntegrationInformationById = (id, version, token) => {
|
|
81
|
+
return new Promise(function (resolve, reject) {
|
|
82
|
+
let confirmationRequest = axios.get(
|
|
83
|
+
`api/v1/integrations/${id}/${version}`,
|
|
84
|
+
{
|
|
65
85
|
headers: { authorization: token },
|
|
66
|
-
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
confirmationRequest
|
|
89
|
+
.then((response) => {
|
|
90
|
+
resolve(response.data);
|
|
91
|
+
})
|
|
92
|
+
.catch((error) => {
|
|
93
|
+
reject(error);
|
|
67
94
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
resolve(response.data);
|
|
71
|
-
})
|
|
72
|
-
.catch((error) => {
|
|
73
|
-
reject(error);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
},
|
|
95
|
+
});
|
|
96
|
+
};
|
|
77
97
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Get integrations list
|
|
100
|
+
* @param {Array<String>} filter The filter used to select the integration
|
|
101
|
+
* @param {String} type The type of the integration
|
|
102
|
+
* @param {String} version The version to be retrieved
|
|
103
|
+
* @param {Boolean} includeSupportedCapabilities If true, the supported capabilities will be included in the response
|
|
104
|
+
* @param {String} token Authorization token
|
|
105
|
+
*/
|
|
106
|
+
export const getIntegrationsList = (
|
|
107
|
+
filter,
|
|
108
|
+
type,
|
|
109
|
+
version,
|
|
110
|
+
includeSupportedCapabilities,
|
|
111
|
+
token
|
|
112
|
+
) => {
|
|
113
|
+
return new Promise(function (resolve, reject) {
|
|
114
|
+
const requestData = {
|
|
115
|
+
includeSupportedCapabilities: includeSupportedCapabilities,
|
|
116
|
+
version: version,
|
|
117
|
+
};
|
|
118
|
+
if (filter) requestData.filter = filter;
|
|
119
|
+
if (type) requestData.type = type;
|
|
120
|
+
let confirmationRequest = axios.post(`api/v1/integrations`, requestData, {
|
|
121
|
+
headers: { authorization: token },
|
|
99
122
|
});
|
|
100
|
-
|
|
123
|
+
confirmationRequest
|
|
124
|
+
.then((response) => {
|
|
125
|
+
resolve(response.data);
|
|
126
|
+
})
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
reject(error);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
101
132
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const requestData = {
|
|
119
|
-
includeSupportedCapabilities: includeSupportedCapabilities,
|
|
120
|
-
version: version,
|
|
121
|
-
};
|
|
122
|
-
if (filter) requestData.filter = filter;
|
|
123
|
-
if (type) requestData.type = type;
|
|
124
|
-
let confirmationRequest = axios.post(`api/v1/integrations`, requestData, {
|
|
133
|
+
/**
|
|
134
|
+
* Get content information by Url
|
|
135
|
+
* @param {String} url The training url
|
|
136
|
+
* @param {String} verb The verb
|
|
137
|
+
* @param {String} token Authorization token
|
|
138
|
+
*/
|
|
139
|
+
export const getContentInformationByUrl = (url, verb, token) => {
|
|
140
|
+
return new Promise(function (resolve, reject) {
|
|
141
|
+
const requestData = {
|
|
142
|
+
url: url,
|
|
143
|
+
verb: verb,
|
|
144
|
+
};
|
|
145
|
+
let confirmationRequest = axios.post(
|
|
146
|
+
`api/v1/contentproviders/getcontentinformationbyurl`,
|
|
147
|
+
requestData,
|
|
148
|
+
{
|
|
125
149
|
headers: { authorization: token },
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
confirmationRequest
|
|
153
|
+
.then((response) => {
|
|
154
|
+
resolve(response.data);
|
|
155
|
+
})
|
|
156
|
+
.catch((error) => {
|
|
157
|
+
reject(error);
|
|
126
158
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
resolve(response.data);
|
|
130
|
-
})
|
|
131
|
-
.catch((error) => {
|
|
132
|
-
reject(error);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
},
|
|
159
|
+
});
|
|
160
|
+
};
|
|
136
161
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
verb: verb,
|
|
148
|
-
};
|
|
149
|
-
let confirmationRequest = axios.post(
|
|
150
|
-
`api/v1/contentproviders/getcontentinformationbyurl`,
|
|
151
|
-
requestData,
|
|
152
|
-
{
|
|
153
|
-
headers: { authorization: token },
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
confirmationRequest
|
|
157
|
-
.then((response) => {
|
|
158
|
-
resolve(response.data);
|
|
159
|
-
})
|
|
160
|
-
.catch((error) => {
|
|
161
|
-
reject(error);
|
|
162
|
-
});
|
|
162
|
+
/**
|
|
163
|
+
* Get content information by url from the browser instead of the backend
|
|
164
|
+
* @param {String} url
|
|
165
|
+
* @returns {Object}
|
|
166
|
+
*/
|
|
167
|
+
export const getContentInformationByUrlFromBrowser = (url) => {
|
|
168
|
+
return new Promise(function (resolve, reject) {
|
|
169
|
+
let domain = new URL(url);
|
|
170
|
+
let instance = axiosLib.create({
|
|
171
|
+
baseURL: domain.origin,
|
|
163
172
|
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"Accept-Encoding": "gzip, deflate, br",
|
|
185
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
186
|
-
"User-Agent": "Mozilla/5.0",
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
confirmationRequest
|
|
190
|
-
.then((response) => {
|
|
191
|
-
//get the reading time
|
|
192
|
-
const getReadingTime = (text) => {
|
|
193
|
-
const wpm = 225;
|
|
194
|
-
const words = text.trim().split(/\s+/).length;
|
|
195
|
-
return Math.ceil(words / wpm);
|
|
196
|
-
};
|
|
173
|
+
let confirmationRequest = instance.get(domain.pathname, {
|
|
174
|
+
headers: {
|
|
175
|
+
"Access-Control-Allow-Origin": "*",
|
|
176
|
+
"Access-Control-Allow-Headers":
|
|
177
|
+
"Authorization, Origin, X-Requested-With, Content-Type, Accept",
|
|
178
|
+
Accept:
|
|
179
|
+
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
180
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
181
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
182
|
+
"User-Agent": "Mozilla/5.0",
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
confirmationRequest
|
|
186
|
+
.then((response) => {
|
|
187
|
+
//get the reading time
|
|
188
|
+
const getReadingTime = (text) => {
|
|
189
|
+
const wpm = 225;
|
|
190
|
+
const words = text.trim().split(/\s+/).length;
|
|
191
|
+
return Math.ceil(words / wpm);
|
|
192
|
+
};
|
|
197
193
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
);
|
|
217
|
-
description = descriptionContent.substring(
|
|
218
|
-
0,
|
|
219
|
-
descriptionContent.length - 1
|
|
194
|
+
let document = htmlParser.parse(response.responseText);
|
|
195
|
+
let duration = getReadingTime(htmlToText(response.responseText));
|
|
196
|
+
let title = document.querySelector("title")?.rawText;
|
|
197
|
+
let description = "";
|
|
198
|
+
const descriptionEl = document.querySelector("meta");
|
|
199
|
+
try {
|
|
200
|
+
if (descriptionEl) {
|
|
201
|
+
const descriptionParentNode = descriptionEl.parentNode;
|
|
202
|
+
if (descriptionParentNode) {
|
|
203
|
+
const descriptionChildNodes = descriptionParentNode.childNodes;
|
|
204
|
+
if (descriptionChildNodes) {
|
|
205
|
+
const descriptionRawAttr = descriptionChildNodes.find((item) =>
|
|
206
|
+
item.rawAttrs.includes("description")
|
|
207
|
+
);
|
|
208
|
+
if (descriptionRawAttr) {
|
|
209
|
+
const descriptionContent =
|
|
210
|
+
descriptionRawAttr.rawAttrs.substring(
|
|
211
|
+
descriptionRawAttr.rawAttrs.indexOf("content=") + 9
|
|
220
212
|
);
|
|
221
|
-
|
|
213
|
+
description = descriptionContent.substring(
|
|
214
|
+
0,
|
|
215
|
+
descriptionContent.length - 1
|
|
216
|
+
);
|
|
222
217
|
}
|
|
223
218
|
}
|
|
224
219
|
}
|
|
225
|
-
} finally {
|
|
226
|
-
resolve({
|
|
227
|
-
description: description,
|
|
228
|
-
duration: duration,
|
|
229
|
-
icon: `http://www.google.com/s2/favicons?sz=128&domain_url=${pathArray[2]}`,
|
|
230
|
-
title: title ? title.trim() : url,
|
|
231
|
-
type: 0,
|
|
232
|
-
internal: true,
|
|
233
|
-
});
|
|
234
220
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
* @param {String} userid
|
|
245
|
-
* @param {String} verb The verb
|
|
246
|
-
* @param {String} token Authorization token
|
|
247
|
-
*/
|
|
248
|
-
getEnabledContentProviders: (userId, token) => {
|
|
249
|
-
return new Promise(function (resolve, reject) {
|
|
250
|
-
let confirmationRequest = axios.get(
|
|
251
|
-
`api/v1/contentproviders/getenabledcontentproviders/${userId}`,
|
|
252
|
-
{
|
|
253
|
-
headers: { authorization: token },
|
|
221
|
+
} finally {
|
|
222
|
+
resolve({
|
|
223
|
+
description: description,
|
|
224
|
+
duration: duration,
|
|
225
|
+
icon: `http://www.google.com/s2/favicons?sz=128&domain_url=${pathArray[2]}`,
|
|
226
|
+
title: title ? title.trim() : url,
|
|
227
|
+
type: 0,
|
|
228
|
+
internal: true,
|
|
229
|
+
});
|
|
254
230
|
}
|
|
255
|
-
)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
reject(error);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
},
|
|
231
|
+
})
|
|
232
|
+
.catch((error) => {
|
|
233
|
+
reject(new Error(errorToString(error)));
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
265
237
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Get enabled content providers
|
|
240
|
+
* @param {String} userid
|
|
241
|
+
* @param {String} verb The verb
|
|
242
|
+
* @param {String} token Authorization token
|
|
243
|
+
*/
|
|
244
|
+
export const getEnabledContentProviders = (userId, token) => {
|
|
245
|
+
return new Promise(function (resolve, reject) {
|
|
246
|
+
let confirmationRequest = axios.get(
|
|
247
|
+
`api/v1/contentproviders/getenabledcontentproviders/${userId}`,
|
|
248
|
+
{
|
|
249
|
+
headers: { authorization: token },
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
confirmationRequest
|
|
253
|
+
.then((response) => {
|
|
254
|
+
resolve(response.data);
|
|
255
|
+
})
|
|
256
|
+
.catch((error) => {
|
|
257
|
+
reject(error);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
};
|
|
289
261
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
reject(error);
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
},
|
|
262
|
+
/**
|
|
263
|
+
* Publish integration
|
|
264
|
+
* @param {String} id The id of the integration to be published
|
|
265
|
+
* @param {String} token Authorization token
|
|
266
|
+
*/
|
|
267
|
+
export const publishIntegration = (id, token) => {
|
|
268
|
+
return new Promise(function (resolve, reject) {
|
|
269
|
+
let confirmationRequest = axios.post(
|
|
270
|
+
`api/v1/integrations/publish/${id}`,
|
|
271
|
+
{},
|
|
272
|
+
{
|
|
273
|
+
headers: { authorization: token },
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
confirmationRequest
|
|
277
|
+
.then((response) => {
|
|
278
|
+
resolve(response.data);
|
|
279
|
+
})
|
|
280
|
+
.catch((error) => {
|
|
281
|
+
reject(error);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
};
|
|
317
285
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Set integration information
|
|
288
|
+
* @param {String} id The id of the integration to be updated
|
|
289
|
+
* @param {Object} data Data used to update the integration
|
|
290
|
+
* @param {String} token Authorization token
|
|
291
|
+
*/
|
|
292
|
+
export const setIntegrationInformation = (id, data, token) => {
|
|
293
|
+
return new Promise(function (resolve, reject) {
|
|
294
|
+
const requestData = {
|
|
295
|
+
data: data,
|
|
296
|
+
};
|
|
297
|
+
let confirmationRequest = axios.post(
|
|
298
|
+
`api/v1/integrations/${id}`,
|
|
299
|
+
requestData,
|
|
300
|
+
{
|
|
301
|
+
headers: { authorization: token },
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
confirmationRequest
|
|
305
|
+
.then((response) => {
|
|
306
|
+
resolve(response.data);
|
|
307
|
+
})
|
|
308
|
+
.catch((error) => {
|
|
309
|
+
reject(error);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Set default integration
|
|
316
|
+
* @param {String} id The id of the integration to be set as default
|
|
317
|
+
* @param {String} token Authorization token
|
|
318
|
+
*/
|
|
319
|
+
export const setDefaultIntegration = (id, token) => {
|
|
320
|
+
return new Promise(function (resolve, reject) {
|
|
321
|
+
let confirmationRequest = axios.post(
|
|
322
|
+
`api/v1/integrations/${id}/default`,
|
|
323
|
+
"",
|
|
324
|
+
{
|
|
325
|
+
headers: { authorization: token },
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
confirmationRequest
|
|
329
|
+
.then((response) => {
|
|
330
|
+
resolve(response.data);
|
|
331
|
+
})
|
|
332
|
+
.catch((error) => {
|
|
333
|
+
reject(error);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
341
336
|
};
|