@constructor-io/constructorio-node 4.13.0 → 4.14.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.
package/package.json
CHANGED
package/src/modules/catalog.js
CHANGED
|
@@ -1443,7 +1443,6 @@ class Catalog {
|
|
|
1443
1443
|
return fetch(requestUrl, {
|
|
1444
1444
|
method: 'DELETE',
|
|
1445
1445
|
headers: {
|
|
1446
|
-
'Content-Type': 'application/json',
|
|
1447
1446
|
...helpers.createAuthHeader(this.options),
|
|
1448
1447
|
},
|
|
1449
1448
|
signal,
|
|
@@ -1485,7 +1484,6 @@ class Catalog {
|
|
|
1485
1484
|
return fetch(requestUrl, {
|
|
1486
1485
|
method: 'DELETE',
|
|
1487
1486
|
headers: {
|
|
1488
|
-
'Content-Type': 'application/json',
|
|
1489
1487
|
...helpers.createAuthHeader(this.options),
|
|
1490
1488
|
},
|
|
1491
1489
|
signal,
|
|
@@ -199,13 +199,15 @@ class Recommendations {
|
|
|
199
199
|
* Get all recommendation pods
|
|
200
200
|
*
|
|
201
201
|
* @function getRecommendationPods
|
|
202
|
+
* @param {object} [parameters] - Parameters relevant to the network request
|
|
203
|
+
* @param {string} [parameters.section] - Recommendations section
|
|
202
204
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
203
205
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
204
206
|
* @returns {Promise}
|
|
205
207
|
* @example
|
|
206
208
|
* constructorio.recommendations.getRecommendationPods();
|
|
207
209
|
*/
|
|
208
|
-
getRecommendationPods(networkParameters = {}) {
|
|
210
|
+
getRecommendationPods(parameters = {}, networkParameters = {}) {
|
|
209
211
|
const {
|
|
210
212
|
apiKey,
|
|
211
213
|
serviceUrl,
|
|
@@ -214,9 +216,26 @@ class Recommendations {
|
|
|
214
216
|
const controller = new AbortController();
|
|
215
217
|
const { signal } = controller;
|
|
216
218
|
const headers = {};
|
|
217
|
-
const
|
|
219
|
+
const url = `${serviceUrl}/v1/recommendation_pods`;
|
|
218
220
|
|
|
219
|
-
|
|
221
|
+
// For backwards compatibility we allow only "networkParameters" to be passed, meaning "parameters" should be
|
|
222
|
+
// copied to networkParameters. If both parameters and networkParameters are passed we leave them as is
|
|
223
|
+
let parsedNetworkParameters = networkParameters;
|
|
224
|
+
if (parameters.timeout || parameters.headers) {
|
|
225
|
+
parsedNetworkParameters = parameters;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const { section } = parameters;
|
|
229
|
+
|
|
230
|
+
let queryParams = {
|
|
231
|
+
key: apiKey,
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
if (section) {
|
|
235
|
+
queryParams.section = section;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
Object.assign(headers, helpers.combineCustomHeaders(this.options, parsedNetworkParameters));
|
|
220
239
|
|
|
221
240
|
// Append security token as 'x-cnstrc-token' if available
|
|
222
241
|
if (this.options.securityToken && typeof this.options.securityToken === 'string') {
|
|
@@ -224,7 +243,11 @@ class Recommendations {
|
|
|
224
243
|
}
|
|
225
244
|
|
|
226
245
|
// Handle network timeout if specified
|
|
227
|
-
helpers.applyNetworkTimeout(this.options,
|
|
246
|
+
helpers.applyNetworkTimeout(this.options, parsedNetworkParameters, controller);
|
|
247
|
+
|
|
248
|
+
queryParams = helpers.cleanParams(queryParams);
|
|
249
|
+
const queryString = qs.stringify(queryParams, { indices: false });
|
|
250
|
+
const requestUrl = `${url}?${queryString}`;
|
|
228
251
|
|
|
229
252
|
return fetch(requestUrl, { headers: { ...headers, ...helpers.createAuthHeader(this.options) }, signal })
|
|
230
253
|
.then((response) => {
|