@constructor-io/constructorio-node 3.10.1 → 3.10.3
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/README.md +4 -3
- package/package.json +2 -1
- package/src/modules/catalog.js +439 -33
- package/src/modules/recommendations.js +1 -1
- package/src/modules/tasks.js +16 -1
package/README.md
CHANGED
|
@@ -8,9 +8,12 @@ A Node.js client for [Constructor.io](http://constructor.io/). [Constructor.io](
|
|
|
8
8
|
|
|
9
9
|
> This client is intended for use in server side integrations. If you want a JavaScript client for client side (i.e. front end) integrations please use [@constructor-io/constructorio-client-javascript](https://github.com/Constructor-io/constructorio-client-javascript)
|
|
10
10
|
|
|
11
|
+
## Documentation
|
|
12
|
+
Full API documentation is available on [Github Pages](https://constructor-io.github.io/constructorio-node)
|
|
13
|
+
|
|
11
14
|
## 1. Review the Requirements
|
|
12
15
|
|
|
13
|
-
Requesting results from your Node.js back-end can be useful in order to control result rendering logic on your server, or augment/hydrate results with data from another system. However, a back-end integration has additional requirements compared to a front-end integration.
|
|
16
|
+
Requesting results from your Node.js back-end can be useful in order to control result rendering logic on your server, or augment/hydrate results with data from another system. However, a back-end integration has additional requirements compared to a front-end integration. Please review the [Additional Information For Backend Integrations](https://github.com/Constructor-io/constructorio-node/wiki/Additional-Information-For-Backend-Integrations) article within the wiki for more detail.
|
|
14
17
|
|
|
15
18
|
## 2. Install
|
|
16
19
|
|
|
@@ -38,8 +41,6 @@ var constructorio = new ConstructorIOClient({
|
|
|
38
41
|
|
|
39
42
|
After instantiating an instance of the client, four modules will be exposed as properties to help retrieve data from Constructor.io: `search`, `browse`, `autocomplete`, `recommendations`, `catalog` and `tracker`.
|
|
40
43
|
|
|
41
|
-
Full API documentation is available on [Github Pages](https://constructor-io.github.io/constructorio-node)
|
|
42
|
-
|
|
43
44
|
## Development / npm commands
|
|
44
45
|
|
|
45
46
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-node",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.3",
|
|
4
4
|
"description": "Constructor.io Node.js client",
|
|
5
5
|
"main": "src/constructorio.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"src/**/*"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@cspell/eslint-plugin": "^6.8.2",
|
|
34
35
|
"chai": "^4.3.4",
|
|
35
36
|
"chai-as-promised": "^7.1.1",
|
|
36
37
|
"dotenv": "^8.6.0",
|
package/src/modules/catalog.js
CHANGED
|
@@ -149,7 +149,26 @@ class Catalog {
|
|
|
149
149
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
150
150
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
151
151
|
* @returns {Promise}
|
|
152
|
-
* @see https://docs.constructor.io/rest_api/items/add_an_item
|
|
152
|
+
* @see https://docs.constructor.io/rest_api/items/v1/add_an_item
|
|
153
|
+
* @example
|
|
154
|
+
* constructorio.catalog.addItem({
|
|
155
|
+
* item_name: 'black pullover hoodie',
|
|
156
|
+
* section: 'Products',
|
|
157
|
+
* keywords: ['black', 'hoodie', 'tops', 'outerwear'],
|
|
158
|
+
* url: '/products/blk_pllvr_hd_001'
|
|
159
|
+
* image_url: '/products/images/blk_pllvr_hd_001'
|
|
160
|
+
* description: 'a short description about the black pullover hoodie',
|
|
161
|
+
* id: 'blk_pllvr_hd_001',
|
|
162
|
+
* facets: {
|
|
163
|
+
* size: 'medium',
|
|
164
|
+
* color: 'black',
|
|
165
|
+
* },
|
|
166
|
+
* metadata: {
|
|
167
|
+
* swatch_image_url: '/products/swatch_images/blk_pllvr_hd_001',
|
|
168
|
+
* on_sale: true,
|
|
169
|
+
* },
|
|
170
|
+
* group_ids: ['cat_49203', 'subcat_12891'],
|
|
171
|
+
* });
|
|
153
172
|
*/
|
|
154
173
|
addItem(parameters = {}, networkParameters = {}) {
|
|
155
174
|
let requestUrl;
|
|
@@ -203,7 +222,26 @@ class Catalog {
|
|
|
203
222
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
204
223
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
205
224
|
* @returns {Promise}
|
|
206
|
-
* @see https://docs.constructor.io/rest_api/items/add_or_update_an_item
|
|
225
|
+
* @see https://docs.constructor.io/rest_api/items/v1/add_or_update_an_item
|
|
226
|
+
* @example
|
|
227
|
+
* constructorio.catalog.addOrUpdateItem({
|
|
228
|
+
* item_name: 'black pullover hoodie',
|
|
229
|
+
* section: 'Products',
|
|
230
|
+
* keywords: ['black', 'hoodie', 'tops', 'outerwear'],
|
|
231
|
+
* url: '/products/blk_pllvr_hd_001'
|
|
232
|
+
* image_url: '/products/images/blk_pllvr_hd_001'
|
|
233
|
+
* description: 'a short description about the black pullover hoodie',
|
|
234
|
+
* id: 'blk_pllvr_hd_001',
|
|
235
|
+
* facets: {
|
|
236
|
+
* size: 'medium',
|
|
237
|
+
* color: 'black',
|
|
238
|
+
* },
|
|
239
|
+
* metadata: {
|
|
240
|
+
* swatch_image_url: '/products/swatch_images/blk_pllvr_hd_001',
|
|
241
|
+
* on_sale: true,
|
|
242
|
+
* },
|
|
243
|
+
* group_ids: ['cat_49203', 'subcat_12891'],
|
|
244
|
+
* });
|
|
207
245
|
*/
|
|
208
246
|
addOrUpdateItem(parameters = {}, networkParameters = {}) {
|
|
209
247
|
let requestUrl;
|
|
@@ -248,7 +286,12 @@ class Catalog {
|
|
|
248
286
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
249
287
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
250
288
|
* @returns {Promise}
|
|
251
|
-
* @see https://docs.constructor.io/rest_api/items/remove_an_item
|
|
289
|
+
* @see https://docs.constructor.io/rest_api/items/v1/remove_an_item
|
|
290
|
+
* @example
|
|
291
|
+
* constructorio.catalog.removeItem({
|
|
292
|
+
* id: 'blk_pllvr_hd_001',
|
|
293
|
+
* section: 'Products',
|
|
294
|
+
* });
|
|
252
295
|
*/
|
|
253
296
|
removeItem(parameters = {}, networkParameters = {}) {
|
|
254
297
|
let requestUrl;
|
|
@@ -303,7 +346,26 @@ class Catalog {
|
|
|
303
346
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
304
347
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
305
348
|
* @returns {Promise}
|
|
306
|
-
* @see https://docs.constructor.io/rest_api/items/modify_an_item
|
|
349
|
+
* @see https://docs.constructor.io/rest_api/items/v1/modify_an_item
|
|
350
|
+
* @example
|
|
351
|
+
* constructorio.catalog.modifyItem({
|
|
352
|
+
* item_name: 'midnight black pullover hoodie',
|
|
353
|
+
* section: 'Products',
|
|
354
|
+
* keywords: ['midnight black', 'black', 'hoodie', 'tops', 'outerwear'],
|
|
355
|
+
* url: '/products/blk_pllvr_hd_001'
|
|
356
|
+
* image_url: '/products/images/blk_pllvr_hd_001'
|
|
357
|
+
* description: 'a modified short description about the black pullover hoodie',
|
|
358
|
+
* id: 'blk_pllvr_hd_001',
|
|
359
|
+
* facets: {
|
|
360
|
+
* size: 'large',
|
|
361
|
+
* color: 'midnight black',
|
|
362
|
+
* },
|
|
363
|
+
* metadata: {
|
|
364
|
+
* swatch_image_url: '/products/swatch_images/blk_pllvr_hd_001',
|
|
365
|
+
* on_sale: true,
|
|
366
|
+
* },
|
|
367
|
+
* group_ids: ['cat_49203', 'subcat_12891'],
|
|
368
|
+
* });
|
|
307
369
|
*/
|
|
308
370
|
modifyItem(parameters = {}, networkParameters = {}) {
|
|
309
371
|
let requestUrl;
|
|
@@ -342,12 +404,28 @@ class Catalog {
|
|
|
342
404
|
*
|
|
343
405
|
* @function addItemsBatch
|
|
344
406
|
* @param {object} parameters - Additional parameters for item details
|
|
345
|
-
* @param {object[]} parameters.items - A list of items with the same attributes as defined in the
|
|
407
|
+
* @param {object[]} parameters.items - A list of items with the same attributes as defined in the [addItem]{@link module:catalog~addItem} resource
|
|
346
408
|
* @param {string} parameters.section - Your autosuggest and search results can have multiple sections like "Products" and "Search Suggestions". This indicates which section this item is for
|
|
347
409
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
348
410
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
349
411
|
* @returns {Promise}
|
|
350
|
-
* @see https://docs.constructor.io/rest_api/items/batch_add_items
|
|
412
|
+
* @see https://docs.constructor.io/rest_api/items/v1/batch_add_items
|
|
413
|
+
* @example
|
|
414
|
+
* constructorio.catalog.addItemsBatch({
|
|
415
|
+
* items: [
|
|
416
|
+
* {
|
|
417
|
+
* item_name: 'midnight black pullover hoodie',
|
|
418
|
+
* section: 'Products',
|
|
419
|
+
* keywords: ['midnight black', 'black', 'hoodie', 'tops', 'outerwear'],
|
|
420
|
+
* url: '/products/blk_pllvr_hd_001'
|
|
421
|
+
* image_url: '/products/images/blk_pllvr_hd_001'
|
|
422
|
+
* description: 'a modified short description about the black pullover hoodie',
|
|
423
|
+
* id: 'blk_pllvr_hd_001',
|
|
424
|
+
* },
|
|
425
|
+
* . . .
|
|
426
|
+
* ],
|
|
427
|
+
* section: 'Products',
|
|
428
|
+
* });
|
|
351
429
|
*/
|
|
352
430
|
addItemsBatch(parameters = {}, networkParameters = {}) {
|
|
353
431
|
let requestUrl;
|
|
@@ -386,12 +464,28 @@ class Catalog {
|
|
|
386
464
|
*
|
|
387
465
|
* @function addOrUpdateItemsBatch
|
|
388
466
|
* @param {object} parameters - Additional parameters for item details
|
|
389
|
-
* @param {object[]} parameters.items - A list of items with the same attributes as defined in the
|
|
467
|
+
* @param {object[]} parameters.items - A list of items with the same attributes as defined in the [addItem]{@link module:catalog~addItem} resource
|
|
390
468
|
* @param {string} parameters.section - Your autosuggest and search results can have multiple sections like "Products" and "Search Suggestions". This indicates which section this item is for
|
|
391
469
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
392
470
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
393
471
|
* @returns {Promise}
|
|
394
|
-
* @see https://docs.constructor.io/rest_api/items/batch_add_or_update_items
|
|
472
|
+
* @see https://docs.constructor.io/rest_api/items/v1/batch_add_or_update_items
|
|
473
|
+
* @example
|
|
474
|
+
* constructorio.catalog.addOrUpdateItemsBatch({
|
|
475
|
+
* items: [
|
|
476
|
+
* {
|
|
477
|
+
* item_name: 'midnight black pullover hoodie',
|
|
478
|
+
* section: 'Products',
|
|
479
|
+
* keywords: ['midnight black', 'black', 'hoodie', 'tops', 'outerwear'],
|
|
480
|
+
* url: '/products/blk_pllvr_hd_001'
|
|
481
|
+
* image_url: '/products/images/blk_pllvr_hd_001'
|
|
482
|
+
* description: 'a modified short description about the black pullover hoodie',
|
|
483
|
+
* id: 'blk_pllvr_hd_001',
|
|
484
|
+
* },
|
|
485
|
+
* . . .
|
|
486
|
+
* ],
|
|
487
|
+
* section: 'Products',
|
|
488
|
+
* });
|
|
395
489
|
*/
|
|
396
490
|
addOrUpdateItemsBatch(parameters = {}, networkParameters = {}) {
|
|
397
491
|
let requestUrl;
|
|
@@ -430,12 +524,20 @@ class Catalog {
|
|
|
430
524
|
*
|
|
431
525
|
* @function removeItemsBatch
|
|
432
526
|
* @param {object} parameters - Additional parameters for item details
|
|
433
|
-
* @param {object[]} parameters.items - A list of items with the same attributes as defined in the
|
|
527
|
+
* @param {object[]} parameters.items - A list of items with the same attributes as defined in the [addItem]{@link module:catalog~addItem} resource
|
|
434
528
|
* @param {string} parameters.section - Your autosuggest and search results can have multiple sections like "Products" and "Search Suggestions". This indicates which section this item is for
|
|
435
529
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
436
530
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
437
531
|
* @returns {Promise}
|
|
438
|
-
* @see https://docs.constructor.io/rest_api/items/batch_remove_items
|
|
532
|
+
* @see https://docs.constructor.io/rest_api/items/v1/batch_remove_items
|
|
533
|
+
* @example
|
|
534
|
+
* constructorio.catalog.removeItemsBatch({
|
|
535
|
+
* items: [
|
|
536
|
+
* { id: 'blk_pllvr_hd_001' },
|
|
537
|
+
* { id: 'red_pllvr_hd_02' },
|
|
538
|
+
* ],
|
|
539
|
+
* section: 'Products',
|
|
540
|
+
* });
|
|
439
541
|
*/
|
|
440
542
|
removeItemsBatch(parameters = {}, networkParameters = {}) {
|
|
441
543
|
let requestUrl;
|
|
@@ -478,7 +580,11 @@ class Catalog {
|
|
|
478
580
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
479
581
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
480
582
|
* @returns {Promise}
|
|
481
|
-
* @see https://docs.constructor.io/rest_api/items/get_items
|
|
583
|
+
* @see https://docs.constructor.io/rest_api/items/v1/get_items
|
|
584
|
+
* @example
|
|
585
|
+
* constructorio.catalog.getItem({
|
|
586
|
+
* id: 'blk_pllvr_hd_001',
|
|
587
|
+
* });
|
|
482
588
|
*/
|
|
483
589
|
getItem(parameters = {}, networkParameters = {}) {
|
|
484
590
|
const queryParams = {};
|
|
@@ -536,7 +642,13 @@ class Catalog {
|
|
|
536
642
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
537
643
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
538
644
|
* @returns {Promise}
|
|
539
|
-
* @see https://docs.constructor.io/rest_api/items/get_items
|
|
645
|
+
* @see https://docs.constructor.io/rest_api/items/v1/get_items
|
|
646
|
+
* @example
|
|
647
|
+
* constructorio.catalog.getItems({
|
|
648
|
+
* section: 'Products',
|
|
649
|
+
* num_results_per_page: 50,
|
|
650
|
+
* page: 2,
|
|
651
|
+
* });
|
|
540
652
|
*/
|
|
541
653
|
getItems(parameters = {}, networkParameters = {}) {
|
|
542
654
|
const queryParams = {};
|
|
@@ -601,6 +713,12 @@ class Catalog {
|
|
|
601
713
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
602
714
|
* @returns {Promise}
|
|
603
715
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
716
|
+
* @example
|
|
717
|
+
* constructorio.catalog.addItemGroup({
|
|
718
|
+
* id: 'subcat_12891',
|
|
719
|
+
* name: 'Hoodies & Sweaters',
|
|
720
|
+
* parent_id: 'cat_49203',
|
|
721
|
+
* });
|
|
604
722
|
*/
|
|
605
723
|
addItemGroup(parameters = {}, networkParameters = {}) {
|
|
606
724
|
let requestUrl;
|
|
@@ -645,6 +763,20 @@ class Catalog {
|
|
|
645
763
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
646
764
|
* @returns {Promise}
|
|
647
765
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
766
|
+
* @example
|
|
767
|
+
* constructorio.catalog.addItemGroups({
|
|
768
|
+
* item_groups: [
|
|
769
|
+
* {
|
|
770
|
+
* id: 'subcat_12891',
|
|
771
|
+
* name: 'Hoodies & Sweaters',
|
|
772
|
+
* parent_id: 'cat_49203',
|
|
773
|
+
* },
|
|
774
|
+
* {
|
|
775
|
+
* id: 'cat49203',
|
|
776
|
+
* name: 'Outerwear',
|
|
777
|
+
* },
|
|
778
|
+
* ],
|
|
779
|
+
* });
|
|
648
780
|
*/
|
|
649
781
|
addItemGroups(parameters = {}, networkParameters = {}) {
|
|
650
782
|
let requestUrl;
|
|
@@ -688,6 +820,10 @@ class Catalog {
|
|
|
688
820
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
689
821
|
* @returns {Promise}
|
|
690
822
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
823
|
+
* @example
|
|
824
|
+
* constructorio.catalog.getItemGroup({
|
|
825
|
+
* id: 'subcat_12891',
|
|
826
|
+
* });
|
|
691
827
|
*/
|
|
692
828
|
getItemGroup(parameters = {}, networkParameters = {}) {
|
|
693
829
|
let requestUrl;
|
|
@@ -728,6 +864,8 @@ class Catalog {
|
|
|
728
864
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
729
865
|
* @returns {Promise}
|
|
730
866
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
867
|
+
* @example
|
|
868
|
+
* constructorio.catalog.getItemGroups();
|
|
731
869
|
*/
|
|
732
870
|
getItemGroups(networkParameters = {}) {
|
|
733
871
|
let requestUrl;
|
|
@@ -770,6 +908,20 @@ class Catalog {
|
|
|
770
908
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
771
909
|
* @returns {Promise}
|
|
772
910
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
911
|
+
* @example
|
|
912
|
+
* constructorio.catalog.addOrUpdateItemGroups({
|
|
913
|
+
* item_groups: [
|
|
914
|
+
* {
|
|
915
|
+
* id: 'subcat_12891',
|
|
916
|
+
* name: 'Hoodies, Sweaters, & Jackets',
|
|
917
|
+
* parent_id: 'cat_49203',
|
|
918
|
+
* },
|
|
919
|
+
* {
|
|
920
|
+
* id: 'cat49203',
|
|
921
|
+
* name: 'Outerwear',
|
|
922
|
+
* },
|
|
923
|
+
* ],
|
|
924
|
+
* });
|
|
773
925
|
*/
|
|
774
926
|
addOrUpdateItemGroups(parameters = {}, networkParameters = {}) {
|
|
775
927
|
let requestUrl;
|
|
@@ -816,6 +968,15 @@ class Catalog {
|
|
|
816
968
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
817
969
|
* @returns {Promise}
|
|
818
970
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
971
|
+
* @example
|
|
972
|
+
* constructorio.catalog.modifyItemGroup({
|
|
973
|
+
* id: 'subcat_12891',
|
|
974
|
+
* name: 'Hoodies, Sweaters & Jackets',
|
|
975
|
+
* parent_id: 'cat_49203',
|
|
976
|
+
* data: {
|
|
977
|
+
* landing_image_url: '/images/hd_swtrs_jckts.jpg',
|
|
978
|
+
* },
|
|
979
|
+
* });
|
|
819
980
|
*/
|
|
820
981
|
modifyItemGroup(parameters = {}, networkParameters = {}) {
|
|
821
982
|
let requestUrl;
|
|
@@ -858,6 +1019,8 @@ class Catalog {
|
|
|
858
1019
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
859
1020
|
* @returns {Promise}
|
|
860
1021
|
* @see https://docs.constructor.io/rest_api/item_groups
|
|
1022
|
+
* @example
|
|
1023
|
+
* constructorio.catalog.removeItemGroups();
|
|
861
1024
|
*/
|
|
862
1025
|
removeItemGroups(networkParameters = {}) {
|
|
863
1026
|
let requestUrl;
|
|
@@ -898,6 +1061,14 @@ class Catalog {
|
|
|
898
1061
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
899
1062
|
* @returns {Promise}
|
|
900
1063
|
* @see https://docs.constructor.io/rest_api/one_way_synonyms/add_synonyms
|
|
1064
|
+
* @example
|
|
1065
|
+
* constructorio.catalog.addOneWaySynonym({
|
|
1066
|
+
* phrase: 'spices',
|
|
1067
|
+
* child_phrases: [
|
|
1068
|
+
* { phrase: 'pepper' },
|
|
1069
|
+
* { phrase: 'cinnamon' },
|
|
1070
|
+
* ],
|
|
1071
|
+
* });
|
|
901
1072
|
*/
|
|
902
1073
|
addOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
903
1074
|
let requestUrl;
|
|
@@ -943,6 +1114,15 @@ class Catalog {
|
|
|
943
1114
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
944
1115
|
* @returns {Promise}
|
|
945
1116
|
* @see https://docs.constructor.io/rest_api/one_way_synonyms/modify_synonyms
|
|
1117
|
+
* @example
|
|
1118
|
+
* constructorio.catalog.modifyOneWaySynonym({
|
|
1119
|
+
* phrase: 'spices',
|
|
1120
|
+
* child_phrases: [
|
|
1121
|
+
* { phrase: 'pepper' },
|
|
1122
|
+
* { phrase: 'cinnamon' },
|
|
1123
|
+
* { phrase: 'paprika' },
|
|
1124
|
+
* ],
|
|
1125
|
+
* });
|
|
946
1126
|
*/
|
|
947
1127
|
modifyOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
948
1128
|
let requestUrl;
|
|
@@ -987,6 +1167,10 @@ class Catalog {
|
|
|
987
1167
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
988
1168
|
* @returns {Promise}
|
|
989
1169
|
* @see https://docs.constructor.io/rest_api/one_way_synonyms/retrieve_synonyms
|
|
1170
|
+
* @example
|
|
1171
|
+
* constructorio.catalog.getOneWaySynonym({
|
|
1172
|
+
* phrase: 'spices',
|
|
1173
|
+
* });
|
|
990
1174
|
*/
|
|
991
1175
|
getOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
992
1176
|
const { phrase } = parameters;
|
|
@@ -1032,6 +1216,11 @@ class Catalog {
|
|
|
1032
1216
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1033
1217
|
* @returns {Promise}
|
|
1034
1218
|
* @see https://docs.constructor.io/rest_api/one_way_synonyms/retrieve_synonyms
|
|
1219
|
+
* @example
|
|
1220
|
+
* constructorio.catalog.getOneWaySynonyms({
|
|
1221
|
+
* num_results_per_page: 50,
|
|
1222
|
+
* page: 2,
|
|
1223
|
+
* });
|
|
1035
1224
|
*/
|
|
1036
1225
|
getOneWaySynonyms(parameters = {}, networkParameters = {}) {
|
|
1037
1226
|
const queryParams = {};
|
|
@@ -1089,6 +1278,10 @@ class Catalog {
|
|
|
1089
1278
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1090
1279
|
* @returns {Promise}
|
|
1091
1280
|
* @see https://docs.constructor.io/rest_api/one_way_synonyms/remove_synonyms
|
|
1281
|
+
* @example
|
|
1282
|
+
* constructorio.catalog.removeOneWaySynonym({
|
|
1283
|
+
* phrase: 'spices',
|
|
1284
|
+
* });
|
|
1092
1285
|
*/
|
|
1093
1286
|
removeOneWaySynonym(parameters = {}, networkParameters = {}) {
|
|
1094
1287
|
const { phrase } = parameters;
|
|
@@ -1130,6 +1323,8 @@ class Catalog {
|
|
|
1130
1323
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1131
1324
|
* @returns {Promise}
|
|
1132
1325
|
* @see https://docs.constructor.io/rest_api/one_way_synonyms/remove_synonyms
|
|
1326
|
+
* @example
|
|
1327
|
+
* constructorio.catalog.removeOneWaySynonyms();
|
|
1133
1328
|
*/
|
|
1134
1329
|
removeOneWaySynonyms(networkParameters = {}) {
|
|
1135
1330
|
let requestUrl;
|
|
@@ -1172,6 +1367,10 @@ class Catalog {
|
|
|
1172
1367
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1173
1368
|
* @returns {Promise}
|
|
1174
1369
|
* @see https://docs.constructor.io/rest_api/synonyms/
|
|
1370
|
+
* @example
|
|
1371
|
+
* constructorio.catalog.addSynonymGroup({
|
|
1372
|
+
* synonyms: ['0% milk', 'skim milk'],
|
|
1373
|
+
* });
|
|
1175
1374
|
*/
|
|
1176
1375
|
addSynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1177
1376
|
let requestUrl;
|
|
@@ -1216,6 +1415,11 @@ class Catalog {
|
|
|
1216
1415
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1217
1416
|
* @returns {Promise}
|
|
1218
1417
|
* @see https://docs.constructor.io/rest_api/synonyms/
|
|
1418
|
+
* @example
|
|
1419
|
+
* constructorio.catalog.modifySynonymGroup({
|
|
1420
|
+
* id: 32,
|
|
1421
|
+
* synonyms: ['0% milk', 'skim milk', 'fat free milk'],
|
|
1422
|
+
* });
|
|
1219
1423
|
*/
|
|
1220
1424
|
modifySynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1221
1425
|
let requestUrl;
|
|
@@ -1260,6 +1464,10 @@ class Catalog {
|
|
|
1260
1464
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1261
1465
|
* @returns {Promise}
|
|
1262
1466
|
* @see https://docs.constructor.io/rest_api/synonyms/
|
|
1467
|
+
* @example
|
|
1468
|
+
* constructorio.catalog.modifySynonymGroup({
|
|
1469
|
+
* id: 32,
|
|
1470
|
+
* });
|
|
1263
1471
|
*/
|
|
1264
1472
|
getSynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1265
1473
|
let requestUrl;
|
|
@@ -1301,6 +1509,12 @@ class Catalog {
|
|
|
1301
1509
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1302
1510
|
* @returns {Promise}
|
|
1303
1511
|
* @see https://docs.constructor.io/rest_api/synonyms/
|
|
1512
|
+
* @example
|
|
1513
|
+
* constructorio.catalog.modifySynonymGroup({
|
|
1514
|
+
* phrase: '0% milk',
|
|
1515
|
+
* num_results_per_page: 50,
|
|
1516
|
+
* page: 3,
|
|
1517
|
+
* });
|
|
1304
1518
|
*/
|
|
1305
1519
|
getSynonymGroups(parameters = {}, networkParameters = {}) {
|
|
1306
1520
|
const queryParams = {};
|
|
@@ -1356,6 +1570,10 @@ class Catalog {
|
|
|
1356
1570
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1357
1571
|
* @returns {Promise}
|
|
1358
1572
|
* @see https://docs.constructor.io/rest_api/synonyms/
|
|
1573
|
+
* @example
|
|
1574
|
+
* constructorio.catalog.removeSynonymGroup({
|
|
1575
|
+
* id: 32,
|
|
1576
|
+
* });
|
|
1359
1577
|
*/
|
|
1360
1578
|
removeSynonymGroup(parameters = {}, networkParameters = {}) {
|
|
1361
1579
|
let requestUrl;
|
|
@@ -1394,6 +1612,8 @@ class Catalog {
|
|
|
1394
1612
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1395
1613
|
* @returns {Promise}
|
|
1396
1614
|
* @see https://docs.constructor.io/rest_api/synonyms/
|
|
1615
|
+
* @example
|
|
1616
|
+
* constructorio.catalog.modifySynonymGroup();
|
|
1397
1617
|
*/
|
|
1398
1618
|
removeSynonymGroups(networkParameters = {}) {
|
|
1399
1619
|
let requestUrl;
|
|
@@ -1438,6 +1658,20 @@ class Catalog {
|
|
|
1438
1658
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1439
1659
|
* @returns {Promise}
|
|
1440
1660
|
* @see https://docs.constructor.io/rest_api/redirect_rules
|
|
1661
|
+
* @example
|
|
1662
|
+
* constructorio.catalog.addRedirectRule({
|
|
1663
|
+
* url: '/categories/cat_49203',
|
|
1664
|
+
* matches: [{
|
|
1665
|
+
* pattern: 'outerwear',
|
|
1666
|
+
* match_type: 'EXACT'
|
|
1667
|
+
* }],
|
|
1668
|
+
* start_time: '2022-08-11T23:41:02.568Z',
|
|
1669
|
+
* end_time: '2022-08-20T23:41:02.568Z',
|
|
1670
|
+
* user_segments: ['US', 'Mobile'],
|
|
1671
|
+
* metadata: {
|
|
1672
|
+
* additional_data: 'additional string data',
|
|
1673
|
+
* },
|
|
1674
|
+
* });
|
|
1441
1675
|
*/
|
|
1442
1676
|
addRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1443
1677
|
let requestUrl;
|
|
@@ -1487,6 +1721,19 @@ class Catalog {
|
|
|
1487
1721
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1488
1722
|
* @returns {Promise}
|
|
1489
1723
|
* @see https://docs.constructor.io/rest_api/redirect_rules
|
|
1724
|
+
* @example
|
|
1725
|
+
* constructorio.catalog.updateRedirectRule({
|
|
1726
|
+
* id: 1,
|
|
1727
|
+
* url: '/categories/cat_49203',
|
|
1728
|
+
* matches: [{
|
|
1729
|
+
* pattern: 'outerwear',
|
|
1730
|
+
* match_type: 'EXACT'
|
|
1731
|
+
* }],
|
|
1732
|
+
* user_segments: ['US', 'Mobile', 'Web'],
|
|
1733
|
+
* metadata: {
|
|
1734
|
+
* additional_data: 'additional string data',
|
|
1735
|
+
* },
|
|
1736
|
+
* });
|
|
1490
1737
|
*/
|
|
1491
1738
|
updateRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1492
1739
|
let requestUrl;
|
|
@@ -1537,6 +1784,16 @@ class Catalog {
|
|
|
1537
1784
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1538
1785
|
* @returns {Promise}
|
|
1539
1786
|
* @see https://docs.constructor.io/rest_api/redirect_rules
|
|
1787
|
+
* @example
|
|
1788
|
+
* constructorio.catalog.modifyRedirectRule({
|
|
1789
|
+
* id: '1',
|
|
1790
|
+
* url: '/categories/cat_49203',
|
|
1791
|
+
* matches: [{
|
|
1792
|
+
* pattern: 'outerwear',
|
|
1793
|
+
* match_type: 'EXACT'
|
|
1794
|
+
* }],
|
|
1795
|
+
* user_segments: ['US', 'Mobile', 'Web'],
|
|
1796
|
+
* });
|
|
1540
1797
|
*/
|
|
1541
1798
|
modifyRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1542
1799
|
let requestUrl;
|
|
@@ -1581,6 +1838,10 @@ class Catalog {
|
|
|
1581
1838
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1582
1839
|
* @returns {Promise}
|
|
1583
1840
|
* @see https://docs.constructor.io/rest_api/redirect_rules
|
|
1841
|
+
* @example
|
|
1842
|
+
* constructorio.catalog.getRedirectRule({
|
|
1843
|
+
* id: '1',
|
|
1844
|
+
* });
|
|
1584
1845
|
*/
|
|
1585
1846
|
getRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1586
1847
|
let requestUrl;
|
|
@@ -1623,6 +1884,13 @@ class Catalog {
|
|
|
1623
1884
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1624
1885
|
* @returns {Promise}
|
|
1625
1886
|
* @see https://docs.constructor.io/rest_api/redirect_rules
|
|
1887
|
+
* @example
|
|
1888
|
+
* constructorio.catalog.getRedirectRules({
|
|
1889
|
+
* num_results_per_page: 50,
|
|
1890
|
+
* page: 2,
|
|
1891
|
+
* query: 'outerwear',
|
|
1892
|
+
* status: 'active',
|
|
1893
|
+
* });
|
|
1626
1894
|
*/
|
|
1627
1895
|
getRedirectRules(parameters = {}, networkParameters = {}) {
|
|
1628
1896
|
const queryParams = {};
|
|
@@ -1687,6 +1955,10 @@ class Catalog {
|
|
|
1687
1955
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1688
1956
|
* @returns {Promise}
|
|
1689
1957
|
* @see https://docs.constructor.io/rest_api/redirect_rules
|
|
1958
|
+
* @example
|
|
1959
|
+
* constructorio.catalog.removeRedirectRule({
|
|
1960
|
+
* id: '1',
|
|
1961
|
+
* });
|
|
1690
1962
|
*/
|
|
1691
1963
|
removeRedirectRule(parameters = {}, networkParameters = {}) {
|
|
1692
1964
|
let requestUrl;
|
|
@@ -1731,6 +2003,14 @@ class Catalog {
|
|
|
1731
2003
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1732
2004
|
* @returns {Promise}
|
|
1733
2005
|
* @see https://docs.constructor.io/rest_api/full_catalog
|
|
2006
|
+
* @example
|
|
2007
|
+
* constructorio.catalog.replaceCatalog({
|
|
2008
|
+
* section: 'Products',
|
|
2009
|
+
* notification_email: 'notifications@example.com',
|
|
2010
|
+
* items: itemsFileBufferOrStream,
|
|
2011
|
+
* variations: variationsFileBufferOrStream,
|
|
2012
|
+
* item_groups: itemGroupsFileBufferOrStream,
|
|
2013
|
+
* });
|
|
1734
2014
|
*/
|
|
1735
2015
|
async replaceCatalog(parameters = {}, networkParameters = {}) {
|
|
1736
2016
|
try {
|
|
@@ -1775,6 +2055,14 @@ class Catalog {
|
|
|
1775
2055
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1776
2056
|
* @returns {Promise}
|
|
1777
2057
|
* @see https://docs.constructor.io/rest_api/full_catalog
|
|
2058
|
+
* @example
|
|
2059
|
+
* constructorio.catalog.updateCatalog({
|
|
2060
|
+
* section: 'Products',
|
|
2061
|
+
* notification_email: 'notifications@example.com',
|
|
2062
|
+
* items: itemsFileBufferOrStream,
|
|
2063
|
+
* variations: variationsFileBufferOrStream,
|
|
2064
|
+
* item_groups: itemGroupsFileBufferOrStream,
|
|
2065
|
+
* });
|
|
1778
2066
|
*/
|
|
1779
2067
|
async updateCatalog(parameters = {}, networkParameters = {}) {
|
|
1780
2068
|
try {
|
|
@@ -1819,6 +2107,14 @@ class Catalog {
|
|
|
1819
2107
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1820
2108
|
* @returns {Promise}
|
|
1821
2109
|
* @see https://docs.constructor.io/rest_api/full_catalog
|
|
2110
|
+
* @example
|
|
2111
|
+
* constructorio.catalog.patchCatalog({
|
|
2112
|
+
* section: 'Products',
|
|
2113
|
+
* notification_email: 'notifications@example.com',
|
|
2114
|
+
* items: itemsFileBufferOrStream,
|
|
2115
|
+
* variations: variationsFileBufferOrStream,
|
|
2116
|
+
* item_groups: itemGroupsFileBufferOrStream,
|
|
2117
|
+
* });
|
|
1822
2118
|
*/
|
|
1823
2119
|
async patchCatalog(parameters = {}, networkParameters = {}) {
|
|
1824
2120
|
try {
|
|
@@ -1852,12 +2148,12 @@ class Catalog {
|
|
|
1852
2148
|
* Create a facet configuration
|
|
1853
2149
|
*
|
|
1854
2150
|
* @function addFacetConfiguration
|
|
1855
|
-
* @param {object} parameters -
|
|
2151
|
+
* @param {object} parameters - Additional parameters for facet configuration details
|
|
1856
2152
|
* @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
|
|
1857
2153
|
* @param {string} parameters.type - Type of facet. Must be one of multiple or range (numerical).
|
|
1858
2154
|
* @param {string} [parameters.display_name] - The name of the facet presented to the end users. Defaults to null, in which case the name will be presented.
|
|
1859
|
-
* @param {string} [parameters.sort_order] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, num_matches. Defaults to relevance. Can be
|
|
1860
|
-
* @param {boolean} [parameters.sort_descending] - Set to true if the options should be sorted in descending order, false to sort
|
|
2155
|
+
* @param {string} [parameters.sort_order] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, num_matches. Defaults to relevance. Can be overridden by setting position attribute on facet options.
|
|
2156
|
+
* @param {boolean} [parameters.sort_descending] - Set to true if the options should be sorted in descending order, false to sort ascending. Default value is true if sort_order is relevance and false for others.
|
|
1861
2157
|
* @param {string} [parameters.range_type] - Specifies how the range buckets are determined. Must be one of dynamic or static. Default value is null. Required if facet type is range and range_format is options.
|
|
1862
2158
|
* @param {string} [parameters.range_format] - Determine wether the range facet is configured to displayed as a slider (with min/max values) or as a list of buckets. Must be one of boundaries (for sliders) or options (for buckets).
|
|
1863
2159
|
* @param {string} [parameters.range_inclusive] - Used to create inclusive buckets. Must be one of above (options have no upper bound), below (no lower bound), or null (if range options should not be inclusive).
|
|
@@ -1874,6 +2170,15 @@ class Catalog {
|
|
|
1874
2170
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1875
2171
|
* @returns {Promise}
|
|
1876
2172
|
* @see https://docs.constructor.io/rest_api/facets#create-a-facet-config
|
|
2173
|
+
* @example
|
|
2174
|
+
* constructorio.catalog.addFacetConfiguration({
|
|
2175
|
+
* name: 'color',
|
|
2176
|
+
* type: 'multiple',
|
|
2177
|
+
* display_name: 'Color',
|
|
2178
|
+
* sort_order: 'value',
|
|
2179
|
+
* sort_descending: false,
|
|
2180
|
+
* position: 1,
|
|
2181
|
+
* });
|
|
1877
2182
|
*/
|
|
1878
2183
|
addFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
1879
2184
|
let requestUrl;
|
|
@@ -1915,7 +2220,7 @@ class Catalog {
|
|
|
1915
2220
|
* Get all facet configurations
|
|
1916
2221
|
*
|
|
1917
2222
|
* @function getFacetConfigurations
|
|
1918
|
-
* @param {object} parameters -
|
|
2223
|
+
* @param {object} parameters - Additional parameters for retrieving facet configurations.
|
|
1919
2224
|
* @param {number} [parameters.page] - Page number you'd like to request. Defaults to 1.
|
|
1920
2225
|
* @param {number} [parameters.num_results_per_page] - Number of facets per page in paginated response. Default value is 100.
|
|
1921
2226
|
* @param {string} [parameters.section] - The section in which your facet is defined. Default value is Products.
|
|
@@ -1923,6 +2228,11 @@ class Catalog {
|
|
|
1923
2228
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1924
2229
|
* @returns {Promise}
|
|
1925
2230
|
* @see https://docs.constructor.io/rest_api/facets#get-all-facet-configs
|
|
2231
|
+
* @example
|
|
2232
|
+
* constructorio.catalog.getFacetConfigurations({
|
|
2233
|
+
* page: 2,
|
|
2234
|
+
* num_results_per_page: 50,
|
|
2235
|
+
* });
|
|
1926
2236
|
*/
|
|
1927
2237
|
getFacetConfigurations(parameters = {}, networkParameters = {}) {
|
|
1928
2238
|
let requestUrl;
|
|
@@ -1962,13 +2272,17 @@ class Catalog {
|
|
|
1962
2272
|
* Get a single facet's configuration
|
|
1963
2273
|
*
|
|
1964
2274
|
* @function getFacetConfiguration
|
|
1965
|
-
* @param {object} parameters -
|
|
1966
|
-
* @param {number} [parameters.name] -
|
|
2275
|
+
* @param {object} parameters - Additional parameters for retrieving a facet configuration.
|
|
2276
|
+
* @param {number} [parameters.name] - Unique facet name used to refer to the facet in your catalog
|
|
1967
2277
|
* @param {string} [parameters.section] - The section in which your facet is defined. Default value is Products.
|
|
1968
2278
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1969
2279
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1970
2280
|
* @returns {Promise}
|
|
1971
2281
|
* @see https://docs.constructor.io/rest_api/facets#get-a-single-facets-config
|
|
2282
|
+
* @example
|
|
2283
|
+
* constructorio.catalog.getFacetConfiguration({
|
|
2284
|
+
* name: 'color',
|
|
2285
|
+
* });
|
|
1972
2286
|
*/
|
|
1973
2287
|
getFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
1974
2288
|
let requestUrl;
|
|
@@ -2009,12 +2323,29 @@ class Catalog {
|
|
|
2009
2323
|
* Modify the configurations of multiple facets (partially) at once.
|
|
2010
2324
|
*
|
|
2011
2325
|
* @function modifyFacetConfigurations
|
|
2012
|
-
* @param {object} parameters -
|
|
2326
|
+
* @param {object} parameters - Additional parameters for modifying facet configurations
|
|
2013
2327
|
* @param {array} parameters.facetConfigurations - List of facet configurations you would like to update. See [addFacetConfiguration]{@link module:catalog~addFacetConfiguration} for additional details on what parameters you can supply for each facet configuration.
|
|
2014
2328
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2015
2329
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2016
2330
|
* @returns {Promise}
|
|
2017
2331
|
* @see https://docs.constructor.io/rest_api/facets#update-facet-configs-partial
|
|
2332
|
+
* @example
|
|
2333
|
+
* constructorio.catalog.modifyFacetConfigurations(
|
|
2334
|
+
* facetConfigurations: [
|
|
2335
|
+
* {
|
|
2336
|
+
* name: 'color',
|
|
2337
|
+
* type: 'multiple',
|
|
2338
|
+
* display_name: 'Color',
|
|
2339
|
+
* sort_order: 'value',
|
|
2340
|
+
* sort_descending: false,
|
|
2341
|
+
* position: 1,
|
|
2342
|
+
* },
|
|
2343
|
+
* {
|
|
2344
|
+
* name: 'size',
|
|
2345
|
+
* ...
|
|
2346
|
+
* }
|
|
2347
|
+
* ],
|
|
2348
|
+
* });
|
|
2018
2349
|
*/
|
|
2019
2350
|
modifyFacetConfigurations(parameters = {}, networkParameters = {}) {
|
|
2020
2351
|
let requestUrl;
|
|
@@ -2058,12 +2389,12 @@ class Catalog {
|
|
|
2058
2389
|
* Caution: Overwrites all other configurations you may have defined for the facet group, resetting them to their defaults. This includes all facet option configurations you may have defined.
|
|
2059
2390
|
*
|
|
2060
2391
|
* @function replaceFacetConfiguration
|
|
2061
|
-
* @param {object} parameters -
|
|
2392
|
+
* @param {object} parameters - Additional parameters for facet configuration details
|
|
2062
2393
|
* @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
|
|
2063
2394
|
* @param {string} parameters.type - Type of facet. Must be one of multiple or range (numerical).
|
|
2064
2395
|
* @param {string} [parameters.display_name] - The name of the facet presented to the end users. Defaults to null, in which case the name will be presented.
|
|
2065
|
-
* @param {string} [parameters.sort_order] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, num_matches. Defaults to relevance. Can be
|
|
2066
|
-
* @param {boolean} [parameters.sort_descending] - Set to true if the options should be sorted in descending order, false to sort
|
|
2396
|
+
* @param {string} [parameters.sort_order] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, num_matches. Defaults to relevance. Can be overridden by setting position attribute on facet options.
|
|
2397
|
+
* @param {boolean} [parameters.sort_descending] - Set to true if the options should be sorted in descending order, false to sort ascending. Default value is true if sort_order is relevance and false for others.
|
|
2067
2398
|
* @param {string} [parameters.range_type] - Specifies how the range buckets are determined. Must be one of dynamic or static. Default value is null. Required if facet type is range and range_format is options.
|
|
2068
2399
|
* @param {string} [parameters.range_format] - Determine wether the range facet is configured to displayed as a slider (with min/max values) or as a list of buckets. Must be one of boundaries (for sliders) or options (for buckets).
|
|
2069
2400
|
* @param {string} [parameters.range_inclusive] - Used to create inclusive buckets. Must be one of above (options have no upper bound), below (no lower bound), or null (if range options should not be inclusive).
|
|
@@ -2080,6 +2411,15 @@ class Catalog {
|
|
|
2080
2411
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2081
2412
|
* @returns {Promise}
|
|
2082
2413
|
* @see https://docs.constructor.io/rest_api/facets#update-a-facet-config-total
|
|
2414
|
+
* @example
|
|
2415
|
+
* constructorio.catalog.replaceFacetConfiguration({
|
|
2416
|
+
* name: 'color',
|
|
2417
|
+
* type: 'multiple',
|
|
2418
|
+
* display_name: 'Color',
|
|
2419
|
+
* sort_order: 'value',
|
|
2420
|
+
* sort_descending: false,
|
|
2421
|
+
* position: 1,
|
|
2422
|
+
* });
|
|
2083
2423
|
*/
|
|
2084
2424
|
replaceFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2085
2425
|
let requestUrl;
|
|
@@ -2121,12 +2461,12 @@ class Catalog {
|
|
|
2121
2461
|
* Modify the configuration of a facet (partially)
|
|
2122
2462
|
*
|
|
2123
2463
|
* @function modifyFacetConfiguration
|
|
2124
|
-
* @param {object} parameters -
|
|
2464
|
+
* @param {object} parameters - Additional parameters for facet configuration details
|
|
2125
2465
|
* @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
|
|
2126
2466
|
* @param {string} parameters.type - Type of facet. Must be one of multiple or range (numerical).
|
|
2127
2467
|
* @param {string} [parameters.display_name] - The name of the facet presented to the end users. Defaults to null, in which case the name will be presented.
|
|
2128
|
-
* @param {string} [parameters.sort_order] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, num_matches. Defaults to relevance. Can be
|
|
2129
|
-
* @param {boolean} [parameters.sort_descending] - Set to true if the options should be sorted in descending order, false to sort
|
|
2468
|
+
* @param {string} [parameters.sort_order] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, num_matches. Defaults to relevance. Can be overridden by setting position attribute on facet options.
|
|
2469
|
+
* @param {boolean} [parameters.sort_descending] - Set to true if the options should be sorted in descending order, false to sort ascending. Default value is true if sort_order is relevance and false for others.
|
|
2130
2470
|
* @param {string} [parameters.range_type] - Specifies how the range buckets are determined. Must be one of dynamic or static. Default value is null. Required if facet type is range and range_format is options.
|
|
2131
2471
|
* @param {string} [parameters.range_format] - Determine wether the range facet is configured to displayed as a slider (with min/max values) or as a list of buckets. Must be one of boundaries (for sliders) or options (for buckets).
|
|
2132
2472
|
* @param {string} [parameters.range_inclusive] - Used to create inclusive buckets. Must be one of above (options have no upper bound), below (no lower bound), or null (if range options should not be inclusive).
|
|
@@ -2143,6 +2483,15 @@ class Catalog {
|
|
|
2143
2483
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2144
2484
|
* @returns {Promise}
|
|
2145
2485
|
* @see https://docs.constructor.io/rest_api/facets#update-a-facet-config-partial
|
|
2486
|
+
* @example
|
|
2487
|
+
* constructorio.catalog.modifyFacetConfiguration({
|
|
2488
|
+
* name: 'color',
|
|
2489
|
+
* type: 'multiple',
|
|
2490
|
+
* display_name: 'Color',
|
|
2491
|
+
* sort_order: 'num_matches',
|
|
2492
|
+
* sort_descending: true,
|
|
2493
|
+
* position: 1,
|
|
2494
|
+
* });
|
|
2146
2495
|
*/
|
|
2147
2496
|
modifyFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2148
2497
|
let requestUrl;
|
|
@@ -2186,13 +2535,17 @@ class Catalog {
|
|
|
2186
2535
|
* Caution: Once a facet group's configuration is removed, all configurations will return to their default values. This includes all facet option configurations (display name, position, etc) you may have defined for the facet group.
|
|
2187
2536
|
*
|
|
2188
2537
|
* @function removeFacetConfiguration
|
|
2189
|
-
* @param {object} parameters -
|
|
2538
|
+
* @param {object} parameters - Additional parameters for facet configuration details
|
|
2190
2539
|
* @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
|
|
2191
2540
|
* @param {string} [parameters.section] - The section in which your facet is defined. Default value is Products.
|
|
2192
2541
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2193
2542
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2194
2543
|
* @returns {Promise}
|
|
2195
2544
|
* @see https://docs.constructor.io/rest_api/facets#delete-a-facet-config
|
|
2545
|
+
* @example
|
|
2546
|
+
* constructorio.catalog.removeFacetConfiguration({
|
|
2547
|
+
* name: 'color',
|
|
2548
|
+
* });
|
|
2196
2549
|
*/
|
|
2197
2550
|
removeFacetConfiguration(parameters = {}, networkParameters = {}) {
|
|
2198
2551
|
let requestUrl;
|
|
@@ -2232,7 +2585,7 @@ class Catalog {
|
|
|
2232
2585
|
* Create a facet option configuration
|
|
2233
2586
|
*
|
|
2234
2587
|
* @function addFacetOptionConfiguration
|
|
2235
|
-
* @param {object} parameters -
|
|
2588
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2236
2589
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
|
|
2237
2590
|
* @param {string} parameters.value - A unique value for the facet option
|
|
2238
2591
|
* @param {string} [parameters.display_name=null] - The name of the facet presented to the end users - if none is supplied, the value from name will be used
|
|
@@ -2244,6 +2597,13 @@ class Catalog {
|
|
|
2244
2597
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2245
2598
|
* @returns {Promise}
|
|
2246
2599
|
* @see https://docs.constructor.io/rest_api/facet_options#create-a-facet-option-config
|
|
2600
|
+
* @example
|
|
2601
|
+
* constructorio.catalog.addFacetOptionConfiguration({
|
|
2602
|
+
* facetGroupName: 'color',
|
|
2603
|
+
* value: 'blue',
|
|
2604
|
+
* display_name: 'Blue',
|
|
2605
|
+
* position: 5,
|
|
2606
|
+
* });
|
|
2247
2607
|
*/
|
|
2248
2608
|
addFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
2249
2609
|
let requestUrl;
|
|
@@ -2285,7 +2645,7 @@ class Catalog {
|
|
|
2285
2645
|
* Create new facet option configurations or modify if they already exist
|
|
2286
2646
|
*
|
|
2287
2647
|
* @function addOrModifyFacetOptionConfigurations
|
|
2288
|
-
* @param {object} parameters -
|
|
2648
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2289
2649
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in the catalog
|
|
2290
2650
|
* @param {object[]} parameters.facetOptionConfigurations - List of facet option configurations to would like to update - refer to [addFacetConfiguration]{@link module:catalog~addFacetOptionConfiguration} for additional details on what parameters can be supplied for each facet option configuration
|
|
2291
2651
|
* @param {string} [parameters.section='Products'] - The section in which your facet is defined
|
|
@@ -2293,6 +2653,22 @@ class Catalog {
|
|
|
2293
2653
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2294
2654
|
* @returns {Promise}
|
|
2295
2655
|
* @see https://docs.constructor.io/rest_api/facet_options#batch-update-or-create-facet-options-configs
|
|
2656
|
+
* @example
|
|
2657
|
+
* constructorio.catalog.addOrModifyFacetOptionConfigurations({
|
|
2658
|
+
* facetGroupName: 'color',
|
|
2659
|
+
* facetOptionConfigurations: [
|
|
2660
|
+
* {
|
|
2661
|
+
* value: 'blue',
|
|
2662
|
+
* display_name: 'Blue',
|
|
2663
|
+
* position: 5,
|
|
2664
|
+
* },
|
|
2665
|
+
* {
|
|
2666
|
+
* value: 'red',
|
|
2667
|
+
* display_name: 'Red',
|
|
2668
|
+
* position: 3,
|
|
2669
|
+
* },
|
|
2670
|
+
* ],
|
|
2671
|
+
* });
|
|
2296
2672
|
*/
|
|
2297
2673
|
addOrModifyFacetOptionConfigurations(parameters = {}, networkParameters = {}) {
|
|
2298
2674
|
let requestUrl;
|
|
@@ -2334,7 +2710,7 @@ class Catalog {
|
|
|
2334
2710
|
* Get all facet option configurations for a given facet
|
|
2335
2711
|
*
|
|
2336
2712
|
* @function getFacetOptionConfigurations
|
|
2337
|
-
* @param {object} parameters -
|
|
2713
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2338
2714
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
|
|
2339
2715
|
* @param {number} [parameters.page=1] - Page number you'd like to request
|
|
2340
2716
|
* @param {number} [parameters.num_results_per_page=100] - Number of facets per page in paginated response
|
|
@@ -2343,6 +2719,12 @@ class Catalog {
|
|
|
2343
2719
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2344
2720
|
* @returns {Promise}
|
|
2345
2721
|
* @see https://docs.constructor.io/rest_api/facet_options#get-all-option-configs-for-facet
|
|
2722
|
+
* @example
|
|
2723
|
+
* constructorio.catalog.getFacetOptionConfigurations({
|
|
2724
|
+
* facetGroupName: 'color',
|
|
2725
|
+
* page: 3,
|
|
2726
|
+
* num_results_per_page: 50
|
|
2727
|
+
* });
|
|
2346
2728
|
*/
|
|
2347
2729
|
getFacetOptionConfigurations(parameters = {}, networkParameters = {}) {
|
|
2348
2730
|
let requestUrl;
|
|
@@ -2383,7 +2765,7 @@ class Catalog {
|
|
|
2383
2765
|
* Get a single facet option configuration for a given facet
|
|
2384
2766
|
*
|
|
2385
2767
|
* @function getFacetOptionConfiguration
|
|
2386
|
-
* @param {object} parameters -
|
|
2768
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2387
2769
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
|
|
2388
2770
|
* @param {string} parameters.value - The facet option value. Unique for a particular facet
|
|
2389
2771
|
* @param {string} [parameters.section='Products'] - The section in which your facet is defined
|
|
@@ -2391,6 +2773,11 @@ class Catalog {
|
|
|
2391
2773
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2392
2774
|
* @returns {Promise}
|
|
2393
2775
|
* @see https://docs.constructor.io/rest_api/facet_options#get-a-single-facet-option-config
|
|
2776
|
+
* @example
|
|
2777
|
+
* constructorio.catalog.getFacetOptionConfiguration({
|
|
2778
|
+
* facetGroupName: 'color',
|
|
2779
|
+
* value: 'blue',
|
|
2780
|
+
* });
|
|
2394
2781
|
*/
|
|
2395
2782
|
getFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
2396
2783
|
let requestUrl;
|
|
@@ -2431,7 +2818,7 @@ class Catalog {
|
|
|
2431
2818
|
* Replace a facet option configuration
|
|
2432
2819
|
*
|
|
2433
2820
|
* @function replaceFacetOptionConfiguration
|
|
2434
|
-
* @param {object} parameters -
|
|
2821
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2435
2822
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
|
|
2436
2823
|
* @param {string} parameters.value - A unique facet option value
|
|
2437
2824
|
* @param {string} [parameters.display_name=null] - The name of the facet presented to the end users - if none is supplied, the value from name will be used
|
|
@@ -2443,6 +2830,13 @@ class Catalog {
|
|
|
2443
2830
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2444
2831
|
* @returns {Promise}
|
|
2445
2832
|
* @see https://docs.constructor.io/rest_api/facet_options#update-facet-option-total
|
|
2833
|
+
* @example
|
|
2834
|
+
* constructorio.catalog.replaceFacetOptionConfiguration({
|
|
2835
|
+
* facetGroupName: 'color',
|
|
2836
|
+
* value: 'blue',
|
|
2837
|
+
* display_name: 'Midnight Blue',
|
|
2838
|
+
* position: 9,
|
|
2839
|
+
* });
|
|
2446
2840
|
*/
|
|
2447
2841
|
replaceFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
2448
2842
|
let requestUrl;
|
|
@@ -2484,7 +2878,7 @@ class Catalog {
|
|
|
2484
2878
|
* Modify a facet option configuration
|
|
2485
2879
|
*
|
|
2486
2880
|
* @function modifyFacetOptionConfiguration
|
|
2487
|
-
* @param {object} parameters -
|
|
2881
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2488
2882
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
|
|
2489
2883
|
* @param {string} parameters.value - A unique facet option value
|
|
2490
2884
|
* @param {string} [parameters.display_name=null] - The name of the facet presented to the end users - if none is supplied, the value from name will be used
|
|
@@ -2496,6 +2890,13 @@ class Catalog {
|
|
|
2496
2890
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2497
2891
|
* @returns {Promise}
|
|
2498
2892
|
* @see https://docs.constructor.io/rest_api/facet_options#update-facet-option-partial
|
|
2893
|
+
* @example
|
|
2894
|
+
* constructorio.catalog.modifyFacetOptionConfiguration({
|
|
2895
|
+
* facetGroupName: 'color',
|
|
2896
|
+
* value: 'blue',
|
|
2897
|
+
* display_name: 'Midnight Blue',
|
|
2898
|
+
* position: 9,
|
|
2899
|
+
* });
|
|
2499
2900
|
*/
|
|
2500
2901
|
modifyFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
2501
2902
|
let requestUrl;
|
|
@@ -2537,7 +2938,7 @@ class Catalog {
|
|
|
2537
2938
|
* Remove a facet option configuration
|
|
2538
2939
|
*
|
|
2539
2940
|
* @function removeFacetOptionConfiguration
|
|
2540
|
-
* @param {object} parameters -
|
|
2941
|
+
* @param {object} parameters - Additional parameters for facet option configuration details
|
|
2541
2942
|
* @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
|
|
2542
2943
|
* @param {string} parameters.value - A unique value for this facet option
|
|
2543
2944
|
* @param {string} [parameters.section='Products'] - The section in which your facet is defined
|
|
@@ -2545,6 +2946,11 @@ class Catalog {
|
|
|
2545
2946
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2546
2947
|
* @returns {Promise}
|
|
2547
2948
|
* @see https://docs.constructor.io/rest_api/facet_options#delete-a-facet-option-config
|
|
2949
|
+
* @example
|
|
2950
|
+
* constructorio.removeFacetOptionConfiguration({
|
|
2951
|
+
* facetGroupName: 'color',
|
|
2952
|
+
* value: 'red',
|
|
2953
|
+
* });
|
|
2548
2954
|
*/
|
|
2549
2955
|
removeFacetOptionConfiguration(parameters = {}, networkParameters = {}) {
|
|
2550
2956
|
let requestUrl;
|
|
@@ -101,7 +101,7 @@ class Recommendations {
|
|
|
101
101
|
* @param {number} [parameters.numResults] - The number of results to return
|
|
102
102
|
* @param {string} [parameters.section] - The section to return results from
|
|
103
103
|
* @param {string} [parameters.term] - The term to use to refine results (strategy specific)
|
|
104
|
-
* @param {object} [parameters.filters] -
|
|
104
|
+
* @param {object} [parameters.filters] - Key / value mapping of filters used to refine results
|
|
105
105
|
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
106
106
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
107
107
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
package/src/modules/tasks.js
CHANGED
|
@@ -46,6 +46,9 @@ class Tasks {
|
|
|
46
46
|
* @param {object} parameters - Additional parameters for task details
|
|
47
47
|
* @param {number} [parameters.num_results_per_page = 20] - The number of tasks to return - maximum value 100
|
|
48
48
|
* @param {number} [parameters.page = 1] - The page of results to return
|
|
49
|
+
* @param {string} [parameters.startDate] - The start date of results to return - YYYY-MM-DD
|
|
50
|
+
* @param {string} [parameters.endDate] - The end date of results to return - YYYY-MM-DD
|
|
51
|
+
* @param {string} [parameters.status] - The status of tasks to return - 'QUEUED', 'IN_PROGRESS', 'DONE', 'FAILED', 'CANCELED'
|
|
49
52
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
50
53
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
51
54
|
* @returns {Promise}
|
|
@@ -59,7 +62,7 @@ class Tasks {
|
|
|
59
62
|
const { signal } = controller;
|
|
60
63
|
|
|
61
64
|
if (parameters) {
|
|
62
|
-
const { num_results_per_page: numResultsPerPage, page } = parameters;
|
|
65
|
+
const { num_results_per_page: numResultsPerPage, page, startDate, endDate, status } = parameters;
|
|
63
66
|
|
|
64
67
|
// Pull number of results per page from parameters
|
|
65
68
|
if (numResultsPerPage) {
|
|
@@ -70,6 +73,18 @@ class Tasks {
|
|
|
70
73
|
if (page) {
|
|
71
74
|
queryParams.page = page;
|
|
72
75
|
}
|
|
76
|
+
|
|
77
|
+
if (startDate) {
|
|
78
|
+
queryParams.start_date = startDate;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (endDate) {
|
|
82
|
+
queryParams.end_date = endDate;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (status) {
|
|
86
|
+
queryParams.status = status;
|
|
87
|
+
}
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
try {
|