@constructor-io/constructorio-node 4.4.6 → 4.5.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.
@@ -6,6 +6,7 @@ const FormData = require('form-data');
6
6
  const fs = require('fs');
7
7
  const { Duplex } = require('stream');
8
8
  const helpers = require('../utils/helpers');
9
+ const { toSnakeCaseKeys } = require('../utils/helpers');
9
10
 
10
11
  // Create URL from supplied path and options
11
12
  function createCatalogUrl(path, options, additionalQueryParams = {}, apiVersion = 'v1') {
@@ -24,6 +25,7 @@ function createCatalogUrl(path, options, additionalQueryParams = {}, apiVersion
24
25
 
25
26
  queryParams.key = apiKey;
26
27
  queryParams = helpers.cleanParams(queryParams);
28
+ queryParams = toSnakeCaseKeys(queryParams);
27
29
 
28
30
  const queryString = qs.stringify(queryParams, { indices: false });
29
31
 
@@ -55,8 +57,8 @@ async function createQueryParamsAndFormData(parameters) {
55
57
  const formData = new FormData();
56
58
 
57
59
  if (parameters) {
58
- const { section, notificationEmail, force } = parameters;
59
- let { items, variations, item_groups: itemGroups } = parameters;
60
+ const { section, notification_email, notificationEmail = notification_email, force, item_groups, onMissing } = parameters;
61
+ let { items, variations, itemGroups = item_groups } = parameters;
60
62
 
61
63
  try {
62
64
  // Convert items to buffer if passed as stream
@@ -92,6 +94,16 @@ async function createQueryParamsAndFormData(parameters) {
92
94
  queryParams.force = force;
93
95
  }
94
96
 
97
+ // Pull onMissing from parameters
98
+ if (onMissing) {
99
+ // Validate onMissing parameter
100
+ if (onMissing && !['FAIL', 'IGNORE', 'CREATE'].includes(onMissing)) {
101
+ throw new Error('onMissing must be one of FAIL, IGNORE, or CREATE');
102
+ }
103
+
104
+ queryParams.on_missing = onMissing;
105
+ }
106
+
95
107
  // Pull items from parameters
96
108
  if (items) {
97
109
  formData.append('items', items, {
@@ -119,9 +131,15 @@ async function createQueryParamsAndFormData(parameters) {
119
131
 
120
132
  async function addTarArchiveToFormData(parameters, formData, operation, apiKey) {
121
133
  try {
122
- const { section } = parameters;
134
+ const { section, onMissing } = parameters;
135
+ const onMissingParameter = onMissing && onMissing !== 'FAIL' ? onMissing.toLowerCase() : '';
123
136
  let { tarArchive } = parameters;
124
137
 
138
+ // Validate onMissing parameter
139
+ if (onMissing && !['FAIL', 'IGNORE', 'CREATE'].includes(onMissing)) {
140
+ throw new Error('onMissing must be one of FAIL, IGNORE, or CREATE');
141
+ }
142
+
125
143
  // Convert tarArchive to buffer if passed as stream
126
144
  if (tarArchive instanceof fs.ReadStream || tarArchive instanceof Duplex) {
127
145
  tarArchive = await convertToBuffer(tarArchive);
@@ -135,7 +153,7 @@ async function addTarArchiveToFormData(parameters, formData, operation, apiKey)
135
153
  .replace('T', '-')
136
154
  .replace(/:/g, '-')
137
155
  .slice(0, 19);
138
- const filename = `${apiKey}_${section}_${operation}_${formattedDateTime}.tar.gz`;
156
+ const filename = `${apiKey}_${section}_${operation}${onMissingParameter}_${formattedDateTime}.tar.gz`;
139
157
 
140
158
  formData.append(filename, tarArchive, {
141
159
  filename,
@@ -195,7 +213,7 @@ class Catalog {
195
213
  const { fetch } = this.options;
196
214
  const controller = new AbortController();
197
215
  const { signal } = controller;
198
- const { items, section, force, notificationEmail } = parameters;
216
+ const { items, section, force, notification_email, notificationEmail = notification_email } = parameters;
199
217
  const queryParams = {};
200
218
 
201
219
  // Validate items is provided
@@ -277,7 +295,7 @@ class Catalog {
277
295
  const { fetch } = this.options;
278
296
  const controller = new AbortController();
279
297
  const { signal } = controller;
280
- const { items, section, force, notificationEmail } = parameters;
298
+ const { items, section, force, notification_email, notificationEmail = notification_email } = parameters;
281
299
  const queryParams = {};
282
300
 
283
301
  // Validate items is provided
@@ -349,7 +367,7 @@ class Catalog {
349
367
  const { fetch } = this.options;
350
368
  const controller = new AbortController();
351
369
  const { signal } = controller;
352
- const { items, section, force, notificationEmail } = parameters;
370
+ const { items, section, force, notification_email, notificationEmail = notification_email } = parameters;
353
371
  const queryParams = {};
354
372
 
355
373
  // Validate items is provided
@@ -508,7 +526,7 @@ class Catalog {
508
526
  const { fetch } = this.options;
509
527
  const controller = new AbortController();
510
528
  const { signal } = controller;
511
- const { section, force, notificationEmail, variations } = parameters;
529
+ const { section, force, notification_email, notificationEmail = notification_email, variations } = parameters;
512
530
  const queryParams = {};
513
531
 
514
532
  // Validate variations are provided
@@ -591,7 +609,7 @@ class Catalog {
591
609
  const { fetch } = this.options;
592
610
  const controller = new AbortController();
593
611
  const { signal } = controller;
594
- const { section, force, notificationEmail, variations } = parameters;
612
+ const { section, force, notification_email, notificationEmail = notification_email, variations } = parameters;
595
613
  const queryParams = {};
596
614
 
597
615
  // Validate variations are provided
@@ -664,7 +682,7 @@ class Catalog {
664
682
  const { fetch } = this.options;
665
683
  const controller = new AbortController();
666
684
  const { signal } = controller;
667
- const { section, force, notificationEmail, variations } = parameters;
685
+ const { section, force, notification_email, notificationEmail = notification_email, variations } = parameters;
668
686
  const queryParams = {};
669
687
 
670
688
  // Validate variations are provided
@@ -800,7 +818,7 @@ class Catalog {
800
818
  * @param {object} parameters - Additional parameters for item group details
801
819
  * @param {string} parameters.id - Item group ID
802
820
  * @param {string} parameters.name - Item group name
803
- * @param {string} [parameters.parent_id] - Item group parent ID
821
+ * @param {string} [parameters.parentId] - Item group parent ID
804
822
  * @param {object} [parameters.data] - JSON object with custom metadata attached with the item group
805
823
  * @param {object} [networkParameters] - Parameters relevant to the network request
806
824
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -810,7 +828,7 @@ class Catalog {
810
828
  * constructorio.catalog.addItemGroup({
811
829
  * id: 'subcat_12891',
812
830
  * name: 'Hoodies & Sweaters',
813
- * parent_id: 'cat_49203',
831
+ * parentId: 'cat_49203',
814
832
  * });
815
833
  */
816
834
  addItemGroup(parameters = {}, networkParameters = {}) {
@@ -831,7 +849,7 @@ class Catalog {
831
849
 
832
850
  return fetch(requestUrl, {
833
851
  method: 'PUT',
834
- body: JSON.stringify(rest),
852
+ body: JSON.stringify(toSnakeCaseKeys(rest, false)),
835
853
  headers: {
836
854
  'Content-Type': 'application/json',
837
855
  ...helpers.createAuthHeader(this.options),
@@ -851,18 +869,18 @@ class Catalog {
851
869
  *
852
870
  * @function addItemGroups
853
871
  * @param {object} parameters - Additional parameters for item group details
854
- * @param {object[]} parameters.item_groups - A list of item groups
872
+ * @param {object[]} parameters.itemGroups - A list of item groups
855
873
  * @param {object} [networkParameters] - Parameters relevant to the network request
856
874
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
857
875
  * @returns {Promise}
858
876
  * @see https://docs.constructor.io/rest_api/item_groups
859
877
  * @example
860
878
  * constructorio.catalog.addItemGroups({
861
- * item_groups: [
879
+ * itemGroups: [
862
880
  * {
863
881
  * id: 'subcat_12891',
864
882
  * name: 'Hoodies & Sweaters',
865
- * parent_id: 'cat_49203',
883
+ * parentId: 'cat_49203',
866
884
  * },
867
885
  * {
868
886
  * id: 'cat49203',
@@ -877,6 +895,11 @@ class Catalog {
877
895
  const controller = new AbortController();
878
896
  const { signal } = controller;
879
897
 
898
+ // Backwards Compatibility
899
+ const { item_groups, itemGroups = item_groups, ...rest } = parameters;
900
+ const params = { itemGroups, ...rest };
901
+ params.itemGroups = params.itemGroups.map((itemGroup) => toSnakeCaseKeys(itemGroup, false));
902
+
880
903
  try {
881
904
  requestUrl = createCatalogUrl('item_groups', this.options);
882
905
  } catch (e) {
@@ -888,7 +911,7 @@ class Catalog {
888
911
 
889
912
  return fetch(requestUrl, {
890
913
  method: 'POST',
891
- body: JSON.stringify(parameters),
914
+ body: JSON.stringify(toSnakeCaseKeys(params, false)),
892
915
  headers: {
893
916
  'Content-Type': 'application/json',
894
917
  ...helpers.createAuthHeader(this.options),
@@ -996,18 +1019,18 @@ class Catalog {
996
1019
  *
997
1020
  * @function addOrUpdateItemGroups
998
1021
  * @param {object} parameters - Additional parameters for item group details
999
- * @param {object[]} parameters.item_groups - A list of item groups
1022
+ * @param {object[]} parameters.itemGroups - A list of item groups
1000
1023
  * @param {object} [networkParameters] - Parameters relevant to the network request
1001
1024
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1002
1025
  * @returns {Promise}
1003
1026
  * @see https://docs.constructor.io/rest_api/item_groups
1004
1027
  * @example
1005
1028
  * constructorio.catalog.addOrUpdateItemGroups({
1006
- * item_groups: [
1029
+ * itemGroups: [
1007
1030
  * {
1008
1031
  * id: 'subcat_12891',
1009
1032
  * name: 'Hoodies, Sweaters, & Jackets',
1010
- * parent_id: 'cat_49203',
1033
+ * parentId: 'cat_49203',
1011
1034
  * },
1012
1035
  * {
1013
1036
  * id: 'cat49203',
@@ -1022,6 +1045,10 @@ class Catalog {
1022
1045
  const controller = new AbortController();
1023
1046
  const { signal } = controller;
1024
1047
 
1048
+ // Backwards Compatibility
1049
+ const { item_groups, itemGroups = item_groups, ...rest } = parameters;
1050
+ const params = { itemGroups, ...rest };
1051
+ params.itemGroups = params.itemGroups.map((config) => toSnakeCaseKeys(config));
1025
1052
  try {
1026
1053
  requestUrl = createCatalogUrl('item_groups', this.options);
1027
1054
  } catch (e) {
@@ -1033,7 +1060,7 @@ class Catalog {
1033
1060
 
1034
1061
  return fetch(requestUrl, {
1035
1062
  method: 'PATCH',
1036
- body: JSON.stringify(parameters),
1063
+ body: JSON.stringify(toSnakeCaseKeys(params)),
1037
1064
  headers: {
1038
1065
  'Content-Type': 'application/json',
1039
1066
  ...helpers.createAuthHeader(this.options),
@@ -1055,7 +1082,7 @@ class Catalog {
1055
1082
  * @param {object} parameters - Additional parameters for item group details
1056
1083
  * @param {string} parameters.id - The group ID to update
1057
1084
  * @param {string} [parameters.name] - Item group display name
1058
- * @param {string} [parameters.parent_id] - Parent item group customer ID or null for root item groups
1085
+ * @param {string} [parameters.parentId] - Parent item group customer ID or null for root item groups
1059
1086
  * @param {object} [parameters.data] - JSON object with custom metadata attached with the item group
1060
1087
  * @param {object} [networkParameters] - Parameters relevant to the network request
1061
1088
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -1065,7 +1092,7 @@ class Catalog {
1065
1092
  * constructorio.catalog.modifyItemGroup({
1066
1093
  * id: 'subcat_12891',
1067
1094
  * name: 'Hoodies, Sweaters & Jackets',
1068
- * parent_id: 'cat_49203',
1095
+ * parentId: 'cat_49203',
1069
1096
  * data: {
1070
1097
  * landing_image_url: '/images/hd_swtrs_jckts.jpg',
1071
1098
  * },
@@ -1089,7 +1116,7 @@ class Catalog {
1089
1116
 
1090
1117
  return fetch(requestUrl, {
1091
1118
  method: 'PUT',
1092
- body: JSON.stringify(rest),
1119
+ body: JSON.stringify(toSnakeCaseKeys(rest)),
1093
1120
  headers: {
1094
1121
  'Content-Type': 'application/json',
1095
1122
  ...helpers.createAuthHeader(this.options),
@@ -1149,7 +1176,7 @@ class Catalog {
1149
1176
  * @function addOneWaySynonym
1150
1177
  * @param {object} parameters - Additional parameters for synonym details
1151
1178
  * @param {string} parameters.phrase - Parent phrase
1152
- * @param {string[]} parameters.child_phrases - Array of synonyms
1179
+ * @param {string[]} parameters.childPhrases - Array of synonyms
1153
1180
  * @param {object} [networkParameters] - Parameters relevant to the network request
1154
1181
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1155
1182
  * @returns {Promise}
@@ -1157,7 +1184,7 @@ class Catalog {
1157
1184
  * @example
1158
1185
  * constructorio.catalog.addOneWaySynonym({
1159
1186
  * phrase: 'spices',
1160
- * child_phrases: [
1187
+ * childPhrases: [
1161
1188
  * { phrase: 'pepper' },
1162
1189
  * { phrase: 'cinnamon' },
1163
1190
  * ],
@@ -1181,7 +1208,7 @@ class Catalog {
1181
1208
 
1182
1209
  return fetch(requestUrl, {
1183
1210
  method: 'POST',
1184
- body: JSON.stringify(rest),
1211
+ body: JSON.stringify(toSnakeCaseKeys(rest)),
1185
1212
  headers: {
1186
1213
  'Content-Type': 'application/json',
1187
1214
  ...helpers.createAuthHeader(this.options),
@@ -1202,7 +1229,7 @@ class Catalog {
1202
1229
  * @function modifyOneWaySynonym
1203
1230
  * @param {object} parameters - Additional parameters for synonym details
1204
1231
  * @param {string} parameters.phrase - Parent phrase
1205
- * @param {string[]} parameters.child_phrases - Array of synonyms
1232
+ * @param {string[]} parameters.childPhrases - Array of synonyms
1206
1233
  * @param {object} [networkParameters] - Parameters relevant to the network request
1207
1234
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1208
1235
  * @returns {Promise}
@@ -1210,7 +1237,7 @@ class Catalog {
1210
1237
  * @example
1211
1238
  * constructorio.catalog.modifyOneWaySynonym({
1212
1239
  * phrase: 'spices',
1213
- * child_phrases: [
1240
+ * childPhrases: [
1214
1241
  * { phrase: 'pepper' },
1215
1242
  * { phrase: 'cinnamon' },
1216
1243
  * { phrase: 'paprika' },
@@ -1235,7 +1262,7 @@ class Catalog {
1235
1262
 
1236
1263
  return fetch(requestUrl, {
1237
1264
  method: 'PUT',
1238
- body: JSON.stringify(rest),
1265
+ body: JSON.stringify(toSnakeCaseKeys(rest)),
1239
1266
  headers: {
1240
1267
  'Content-Type': 'application/json',
1241
1268
  ...helpers.createAuthHeader(this.options),
@@ -1303,7 +1330,7 @@ class Catalog {
1303
1330
  *
1304
1331
  * @function getOneWaySynonyms
1305
1332
  * @param {object} [parameters] - Additional parameters for synonym details
1306
- * @param {number} [parameters.num_results_per_page] - The number of synonym groups to return. Defaults to 100
1333
+ * @param {number} [parameters.numResultsPerPage] - The number of synonym groups to return. Defaults to 100
1307
1334
  * @param {number} [parameters.page] - The page of results to return. Defaults to 1
1308
1335
  * @param {object} [networkParameters] - Parameters relevant to the network request
1309
1336
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -1311,7 +1338,7 @@ class Catalog {
1311
1338
  * @see https://docs.constructor.io/rest_api/one_way_synonyms/retrieve_synonyms
1312
1339
  * @example
1313
1340
  * constructorio.catalog.getOneWaySynonyms({
1314
- * num_results_per_page: 50,
1341
+ * numResultsPerPage: 50,
1315
1342
  * page: 2,
1316
1343
  * });
1317
1344
  */
@@ -1323,7 +1350,7 @@ class Catalog {
1323
1350
  const { signal } = controller;
1324
1351
 
1325
1352
  if (parameters) {
1326
- const { num_results_per_page: numResultsPerPage, page } = parameters;
1353
+ const { num_results_per_page, numResultsPerPage = num_results_per_page, page } = parameters;
1327
1354
 
1328
1355
  // Pull number of results per page from parameters
1329
1356
  if (numResultsPerPage) {
@@ -1596,7 +1623,7 @@ class Catalog {
1596
1623
  * @function getSynonymGroups
1597
1624
  * @param {object} [parameters] - Additional parameters for synonym group details
1598
1625
  * @param {string} [parameters.phrase] - The phrase for which all synonym groups containing it will be returned
1599
- * @param {number} [parameters.num_results_per_page] - The number of synonym groups to return. Defaults to 100
1626
+ * @param {number} [parameters.numResultsPerPage] - The number of synonym groups to return. Defaults to 100
1600
1627
  * @param {number} [parameters.page] - The page of results to return. Defaults to 1
1601
1628
  * @param {object} [networkParameters] - Parameters relevant to the network request
1602
1629
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -1605,7 +1632,7 @@ class Catalog {
1605
1632
  * @example
1606
1633
  * constructorio.catalog.modifySynonymGroup({
1607
1634
  * phrase: '0% milk',
1608
- * num_results_per_page: 50,
1635
+ * numResultsPerPage: 50,
1609
1636
  * page: 3,
1610
1637
  * });
1611
1638
  */
@@ -1618,7 +1645,7 @@ class Catalog {
1618
1645
  const { signal } = controller;
1619
1646
 
1620
1647
  if (parameters) {
1621
- const { num_results_per_page: numResultsPerPage, page } = parameters;
1648
+ const { num_results_per_page, numResultsPerPage = num_results_per_page, page } = parameters;
1622
1649
 
1623
1650
  // Pull number of results per page from parameters
1624
1651
  if (numResultsPerPage) {
@@ -1743,9 +1770,9 @@ class Catalog {
1743
1770
  * @param {object} parameters - Additional parameters for redirect rule details
1744
1771
  * @param {string} parameters.url - Target URL returned when a match happens
1745
1772
  * @param {object[]} parameters.matches - List of match definitions
1746
- * @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
1747
- * @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
1748
- * @param {string[]} [parameters.user_segments] - List of user segments
1773
+ * @param {string} [parameters.startTime] - Time at which rule begins to apply (ISO8601 format preferred)
1774
+ * @param {string} [parameters.endTime] - Time at which rule stops to apply (ISO8601 format preferred)
1775
+ * @param {string[]} [parameters.userSegments] - List of user segments
1749
1776
  * @param {object} [parameters.metadata] - Object with arbitrary metadata
1750
1777
  * @param {object} [networkParameters] - Parameters relevant to the network request
1751
1778
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -1756,11 +1783,11 @@ class Catalog {
1756
1783
  * url: '/categories/cat_49203',
1757
1784
  * matches: [{
1758
1785
  * pattern: 'outerwear',
1759
- * match_type: 'EXACT'
1786
+ * matchType: 'EXACT'
1760
1787
  * }],
1761
- * start_time: '2022-08-11T23:41:02.568Z',
1762
- * end_time: '2022-08-20T23:41:02.568Z',
1763
- * user_segments: ['US', 'Mobile'],
1788
+ * startTime: '2022-08-11T23:41:02.568Z',
1789
+ * endTime: '2022-08-20T23:41:02.568Z',
1790
+ * userSegments: ['US', 'Mobile'],
1764
1791
  * metadata: {
1765
1792
  * additional_data: 'additional string data',
1766
1793
  * },
@@ -1771,6 +1798,10 @@ class Catalog {
1771
1798
  const { fetch } = this.options;
1772
1799
  const controller = new AbortController();
1773
1800
  const { signal } = controller;
1801
+ let { matches } = parameters;
1802
+
1803
+ matches = matches.map((match) => toSnakeCaseKeys(match, false));
1804
+ const newParameters = { ...parameters, matches };
1774
1805
 
1775
1806
  try {
1776
1807
  requestUrl = createCatalogUrl('redirect_rules', this.options);
@@ -1783,7 +1814,7 @@ class Catalog {
1783
1814
 
1784
1815
  return fetch(requestUrl, {
1785
1816
  method: 'POST',
1786
- body: JSON.stringify(parameters),
1817
+ body: JSON.stringify(toSnakeCaseKeys(newParameters, false)),
1787
1818
  headers: {
1788
1819
  'Content-Type': 'application/json',
1789
1820
  ...helpers.createAuthHeader(this.options),
@@ -1806,9 +1837,9 @@ class Catalog {
1806
1837
  * @param {string} parameters.id - Redirect rule ID
1807
1838
  * @param {string} parameters.url - Target URL returned when a match happens
1808
1839
  * @param {object[]} parameters.matches - List of match definitions
1809
- * @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
1810
- * @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
1811
- * @param {string[]} [parameters.user_segments] - List of user segments
1840
+ * @param {string} [parameters.startTime] - Time at which rule begins to apply (ISO8601 format preferred)
1841
+ * @param {string} [parameters.endTime] - Time at which rule stops to apply (ISO8601 format preferred)
1842
+ * @param {string[]} [parameters.userSegments] - List of user segments
1812
1843
  * @param {object} [parameters.metadata] - Object with arbitrary metadata
1813
1844
  * @param {object} [networkParameters] - Parameters relevant to the network request
1814
1845
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -1820,9 +1851,9 @@ class Catalog {
1820
1851
  * url: '/categories/cat_49203',
1821
1852
  * matches: [{
1822
1853
  * pattern: 'outerwear',
1823
- * match_type: 'EXACT'
1854
+ * matchType: 'EXACT'
1824
1855
  * }],
1825
- * user_segments: ['US', 'Mobile', 'Web'],
1856
+ * userSegments: ['US', 'Mobile', 'Web'],
1826
1857
  * metadata: {
1827
1858
  * additional_data: 'additional string data',
1828
1859
  * },
@@ -1834,6 +1865,10 @@ class Catalog {
1834
1865
  const controller = new AbortController();
1835
1866
  const { signal } = controller;
1836
1867
  const { id, ...rest } = parameters;
1868
+ let { matches } = parameters;
1869
+
1870
+ matches = matches.map((match) => toSnakeCaseKeys(match, false));
1871
+ const newParameters = { ...rest, matches };
1837
1872
 
1838
1873
  try {
1839
1874
  requestUrl = createCatalogUrl(`redirect_rules/${id}`, this.options);
@@ -1846,7 +1881,7 @@ class Catalog {
1846
1881
 
1847
1882
  return fetch(requestUrl, {
1848
1883
  method: 'PUT',
1849
- body: JSON.stringify(rest),
1884
+ body: JSON.stringify(toSnakeCaseKeys(newParameters, false)),
1850
1885
  headers: {
1851
1886
  'Content-Type': 'application/json',
1852
1887
  ...helpers.createAuthHeader(this.options),
@@ -1869,9 +1904,9 @@ class Catalog {
1869
1904
  * @param {string} parameters.id - Redirect rule ID
1870
1905
  * @param {string} parameters.url - Target URL returned when a match happens
1871
1906
  * @param {object[]} parameters.matches - List of match definitions
1872
- * @param {string} [parameters.start_time] - Time at which rule begins to apply (ISO8601 format preferred)
1873
- * @param {string} [parameters.end_time] - Time at which rule stops to apply (ISO8601 format preferred)
1874
- * @param {string[]} [parameters.user_segments] - List of user segments
1907
+ * @param {string} [parameters.startTime] - Time at which rule begins to apply (ISO8601 format preferred)
1908
+ * @param {string} [parameters.endTime] - Time at which rule stops to apply (ISO8601 format preferred)
1909
+ * @param {string[]} [parameters.userSegments] - List of user segments
1875
1910
  * @param {object} [parameters.metadata] - Object with arbitrary metadata
1876
1911
  * @param {object} [networkParameters] - Parameters relevant to the network request
1877
1912
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -1883,9 +1918,9 @@ class Catalog {
1883
1918
  * url: '/categories/cat_49203',
1884
1919
  * matches: [{
1885
1920
  * pattern: 'outerwear',
1886
- * match_type: 'EXACT'
1921
+ * matchType: 'EXACT'
1887
1922
  * }],
1888
- * user_segments: ['US', 'Mobile', 'Web'],
1923
+ * userSegments: ['US', 'Mobile', 'Web'],
1889
1924
  * });
1890
1925
  */
1891
1926
  modifyRedirectRule(parameters = {}, networkParameters = {}) {
@@ -1894,6 +1929,10 @@ class Catalog {
1894
1929
  const controller = new AbortController();
1895
1930
  const { signal } = controller;
1896
1931
  const { id, ...rest } = parameters;
1932
+ let { matches } = parameters;
1933
+
1934
+ matches = matches.map((match) => toSnakeCaseKeys(match, false));
1935
+ const newParameters = { ...rest, matches };
1897
1936
 
1898
1937
  try {
1899
1938
  requestUrl = createCatalogUrl(`redirect_rules/${id}`, this.options);
@@ -1906,7 +1945,7 @@ class Catalog {
1906
1945
 
1907
1946
  return fetch(requestUrl, {
1908
1947
  method: 'PATCH',
1909
- body: JSON.stringify(rest),
1948
+ body: JSON.stringify(toSnakeCaseKeys(newParameters)),
1910
1949
  headers: {
1911
1950
  'Content-Type': 'application/json',
1912
1951
  ...helpers.createAuthHeader(this.options),
@@ -1969,7 +2008,7 @@ class Catalog {
1969
2008
  *
1970
2009
  * @function getRedirectRules
1971
2010
  * @param {object} [parameters] - Additional parameters for redirect rule details
1972
- * @param {number} [parameters.num_results_per_page] - The number of rules to return. Defaults to 20
2011
+ * @param {number} [parameters.numResultsPerPage] - The number of rules to return. Defaults to 20
1973
2012
  * @param {number} [parameters.page] - The page of redirect rules to return. Defaults to 1
1974
2013
  * @param {string} [parameters.query] - Return redirect rules whose url or match pattern match the provided query
1975
2014
  * @param {string} [parameters.status] - One of "current" (return redirect rules that are currently active), "pending" (return redirect rules that will become active in the future), and "expired" (return redirect rules that are not active anymore)
@@ -1979,7 +2018,7 @@ class Catalog {
1979
2018
  * @see https://docs.constructor.io/rest_api/redirect_rules
1980
2019
  * @example
1981
2020
  * constructorio.catalog.getRedirectRules({
1982
- * num_results_per_page: 50,
2021
+ * numResultsPerPage: 50,
1983
2022
  * page: 2,
1984
2023
  * query: 'outerwear',
1985
2024
  * status: 'active',
@@ -1993,7 +2032,7 @@ class Catalog {
1993
2032
  const { signal } = controller;
1994
2033
 
1995
2034
  if (parameters) {
1996
- const { num_results_per_page: numResultsPerPage, page, query, status } = parameters;
2035
+ const { num_results_per_page, numResultsPerPage = num_results_per_page, page, query, status } = parameters;
1997
2036
 
1998
2037
  // Pull number of results per page from parameters
1999
2038
  if (numResultsPerPage) {
@@ -2087,11 +2126,11 @@ class Catalog {
2087
2126
  * @function replaceCatalog
2088
2127
  * @param {object} parameters - Additional parameters for catalog details
2089
2128
  * @param {string} parameters.section - The section to update
2090
- * @param {string} [parameters.notification_email] - An email address to receive an email notification if the task fails
2129
+ * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2091
2130
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2092
2131
  * @param {file} [parameters.items] - The CSV file with all new items
2093
2132
  * @param {file} [parameters.variations] - The CSV file with all new variations
2094
- * @param {file} [parameters.item_groups] - The CSV file with all new item_groups
2133
+ * @param {file} [parameters.itemGroups] - The CSV file with all new itemGroups
2095
2134
  * @param {object} [networkParameters] - Parameters relevant to the network request
2096
2135
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2097
2136
  * @returns {Promise}
@@ -2099,10 +2138,10 @@ class Catalog {
2099
2138
  * @example
2100
2139
  * constructorio.catalog.replaceCatalog({
2101
2140
  * section: 'Products',
2102
- * notification_email: 'notifications@example.com',
2141
+ * notificationEmail: 'notifications@example.com',
2103
2142
  * items: itemsFileBufferOrStream,
2104
2143
  * variations: variationsFileBufferOrStream,
2105
- * item_groups: itemGroupsFileBufferOrStream,
2144
+ * itemGroups: itemGroupsFileBufferOrStream,
2106
2145
  * });
2107
2146
  */
2108
2147
  async replaceCatalog(parameters = {}, networkParameters = {}) {
@@ -2139,11 +2178,11 @@ class Catalog {
2139
2178
  * @function updateCatalog
2140
2179
  * @param {object} parameters - Additional parameters for catalog details
2141
2180
  * @param {string} parameters.section - The section to update
2142
- * @param {string} [parameters.notification_email] - An email address to receive an email notification if the task fails
2181
+ * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2143
2182
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2144
2183
  * @param {file} [parameters.items] - The CSV file with all new items
2145
2184
  * @param {file} [parameters.variations] - The CSV file with all new variations
2146
- * @param {file} [parameters.item_groups] - The CSV file with all new item_groups
2185
+ * @param {file} [parameters.itemGroups] - The CSV file with all new itemGroups
2147
2186
  * @param {object} [networkParameters] - Parameters relevant to the network request
2148
2187
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2149
2188
  * @returns {Promise}
@@ -2151,10 +2190,10 @@ class Catalog {
2151
2190
  * @example
2152
2191
  * constructorio.catalog.updateCatalog({
2153
2192
  * section: 'Products',
2154
- * notification_email: 'notifications@example.com',
2193
+ * notificationEmail: 'notifications@example.com',
2155
2194
  * items: itemsFileBufferOrStream,
2156
2195
  * variations: variationsFileBufferOrStream,
2157
- * item_groups: itemGroupsFileBufferOrStream,
2196
+ * itemGroups: itemGroupsFileBufferOrStream,
2158
2197
  * });
2159
2198
  */
2160
2199
  async updateCatalog(parameters = {}, networkParameters = {}) {
@@ -2191,11 +2230,12 @@ class Catalog {
2191
2230
  * @function patchCatalog
2192
2231
  * @param {object} parameters - Additional parameters for catalog details
2193
2232
  * @param {string} parameters.section - The section to update
2194
- * @param {string} [parameters.notification_email] - An email address to receive an email notification if the task fails
2233
+ * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2195
2234
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2235
+ * @param {string} [parameters.onMissing] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence. Defaults to FAIL
2196
2236
  * @param {file} [parameters.items] - The CSV file with all new items
2197
2237
  * @param {file} [parameters.variations] - The CSV file with all new variations
2198
- * @param {file} [parameters.item_groups] - The CSV file with all new item_groups
2238
+ * @param {file} [parameters.itemGroups] - The CSV file with all new itemGroups
2199
2239
  * @param {object} [networkParameters] - Parameters relevant to the network request
2200
2240
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2201
2241
  * @returns {Promise}
@@ -2203,10 +2243,10 @@ class Catalog {
2203
2243
  * @example
2204
2244
  * constructorio.catalog.patchCatalog({
2205
2245
  * section: 'Products',
2206
- * notification_email: 'notifications@example.com',
2246
+ * notificationEmail: 'notifications@example.com',
2207
2247
  * items: itemsFileBufferOrStream,
2208
2248
  * variations: variationsFileBufferOrStream,
2209
- * item_groups: itemGroupsFileBufferOrStream,
2249
+ * itemGroups: itemGroupsFileBufferOrStream,
2210
2250
  * });
2211
2251
  */
2212
2252
  async patchCatalog(parameters = {}, networkParameters = {}) {
@@ -2243,7 +2283,7 @@ class Catalog {
2243
2283
  * @function replaceCatalogUsingTarArchive
2244
2284
  * @param {object} parameters - Additional parameters for catalog details
2245
2285
  * @param {string} parameters.section - The section to update
2246
- * @param {string} [parameters.notification_email] - An email address to receive an email notification if the task fails
2286
+ * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2247
2287
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2248
2288
  * @param {file} [parameters.tarArchive] - The tar file that includes csv files
2249
2289
  * @param {object} [networkParameters] - Parameters relevant to the network request
@@ -2253,7 +2293,7 @@ class Catalog {
2253
2293
  * @example
2254
2294
  * constructorio.catalog.replaceCatalogUsingTarArchive({
2255
2295
  * section: 'Products',
2256
- * notification_email: 'notifications@example.com',
2296
+ * notificationEmail: 'notifications@example.com',
2257
2297
  * tarArchive: tarArchiveBufferOrStream,
2258
2298
  * });
2259
2299
  */
@@ -2292,7 +2332,7 @@ class Catalog {
2292
2332
  * @function updateCatalogUsingTarArchive
2293
2333
  * @param {object} parameters - Additional parameters for catalog details
2294
2334
  * @param {string} parameters.section - The section to update
2295
- * @param {string} [parameters.notification_email] - An email address to receive an email notification if the task fails
2335
+ * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2296
2336
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2297
2337
  * @param {file} [parameters.tarArchive] - The tar file that includes csv files
2298
2338
  * @param {object} [networkParameters] - Parameters relevant to the network request
@@ -2302,7 +2342,7 @@ class Catalog {
2302
2342
  * @example
2303
2343
  * constructorio.catalog.updateCatalogUsingTarArchive({
2304
2344
  * section: 'Products',
2305
- * notification_email: 'notifications@example.com',
2345
+ * notificationEmail: 'notifications@example.com',
2306
2346
  * tarArchive: tarArchiveBufferOrStream,
2307
2347
  * });
2308
2348
  */
@@ -2342,8 +2382,9 @@ class Catalog {
2342
2382
  * @function patchCatalogUsingTarArchive
2343
2383
  * @param {object} parameters - Additional parameters for catalog details
2344
2384
  * @param {string} parameters.section - The section to update
2345
- * @param {string} [parameters.notification_email] - An email address to receive an email notification if the task fails
2385
+ * @param {string} [parameters.notificationEmail] - An email address to receive an email notification if the task fails
2346
2386
  * @param {boolean} [parameters.force=false] - Process the catalog even if it will invalidate a large number of existing items
2387
+ * @param {string} [parameters.onMissing] - Defines the strategy for handling items which are present in the file and missing in the system. IGNORE silently prevents adding them to the system, CREATE creates them, FAIL fails the ingestion in case of their presence. Defaults to FAIL
2347
2388
  * @param {file} [parameters.tarArchive] - The tar file that includes csv files
2348
2389
  * @param {object} [networkParameters] - Parameters relevant to the network request
2349
2390
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -2352,7 +2393,7 @@ class Catalog {
2352
2393
  * @example
2353
2394
  * constructorio.catalog.patchCatalogUsingTarArchive({
2354
2395
  * section: 'Products',
2355
- * notification_email: 'notifications@example.com',
2396
+ * notificationEmail: 'notifications@example.com',
2356
2397
  * tarArchive: tarArchiveBufferOrStream,
2357
2398
  * });
2358
2399
  */
@@ -2363,7 +2404,7 @@ class Catalog {
2363
2404
  const controller = new AbortController();
2364
2405
  const { signal } = controller;
2365
2406
  const { queryParams, formData } = await createQueryParamsAndFormData(parameters);
2366
- const formDataWithTarArchive = await addTarArchiveToFormData(parameters, formData, 'delta', apiKey);
2407
+ const formDataWithTarArchive = await addTarArchiveToFormData(parameters, formData, 'patchdelta', apiKey);
2367
2408
  const requestUrl = createCatalogUrl('catalog', this.options, { ...queryParams, patch_delta: true });
2368
2409
 
2369
2410
  // Handle network timeout if specified
@@ -2393,15 +2434,15 @@ class Catalog {
2393
2434
  * @param {object} parameters - Additional parameters for facet configuration details
2394
2435
  * @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
2395
2436
  * @param {string} parameters.type - Type of facet. Must be one of multiple or range (numerical).
2396
- * @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.
2397
- * @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.
2398
- * @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.
2399
- * @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.
2400
- * @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).
2401
- * @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).
2402
- * @param {number} [parameters.bucket_size] - Specifies the size of generated buckets. Default is null. Either this or range_limits are required for facet type range, format options, and range_type static
2403
- * @param {number[]} [parameters.range_limits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
2404
- * @param {string} [parameters.match_type] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
2437
+ * @param {string} [parameters.displayName] - The name of the facet presented to the end users. Defaults to null, in which case the name will be presented.
2438
+ * @param {string} [parameters.sortOrder] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, numMatches. Defaults to relevance. Can be overridden by setting position attribute on facet options.
2439
+ * @param {boolean} [parameters.sortDescending] - Set to true if the options should be sorted in descending order, false to sort ascending. Default value is true if sortOrder is relevance and false for others.
2440
+ * @param {string} [parameters.rangeType] - 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 rangeFormat is options.
2441
+ * @param {string} [parameters.rangeFormat] - 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).
2442
+ * @param {string} [parameters.rangeInclusive] - 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).
2443
+ * @param {number} [parameters.bucketSize] - Specifies the size of generated buckets. Default is null. Either this or rangeLimits are required for facet type range, format options, and rangeType static
2444
+ * @param {json} [parameters.rangeLimits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
2445
+ * @param {string} [parameters.matchType] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
2405
2446
  * @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
2406
2447
  * @param {boolean} [parameters.hidden] - Specifies whether the facet is hidden from users. Used for non-sensitive data that you don't want to show to end users. Default value is false.
2407
2448
  * @param {boolean} [parameters.protected] - Specifies whether the facet is protected from users. Setting to true will require authentication to view the facet. Default value is false.
@@ -2416,9 +2457,9 @@ class Catalog {
2416
2457
  * constructorio.catalog.addFacetConfiguration({
2417
2458
  * name: 'color',
2418
2459
  * type: 'multiple',
2419
- * display_name: 'Color',
2420
- * sort_order: 'value',
2421
- * sort_descending: false,
2460
+ * displayName: 'Color',
2461
+ * sortOrder: 'value',
2462
+ * sortDescending: false,
2422
2463
  * position: 1,
2423
2464
  * });
2424
2465
  */
@@ -2442,7 +2483,7 @@ class Catalog {
2442
2483
  helpers.applyNetworkTimeout(this.options, networkParameters, controller);
2443
2484
  return fetch(requestUrl, {
2444
2485
  method: 'POST',
2445
- body: JSON.stringify(rest),
2486
+ body: JSON.stringify(toSnakeCaseKeys(rest)),
2446
2487
  headers: {
2447
2488
  'Content-Type': 'application/json',
2448
2489
  ...helpers.createAuthHeader(this.options),
@@ -2463,7 +2504,7 @@ class Catalog {
2463
2504
  * @function getFacetConfigurations
2464
2505
  * @param {object} parameters - Additional parameters for retrieving facet configurations.
2465
2506
  * @param {number} [parameters.page] - Page number you'd like to request. Defaults to 1.
2466
- * @param {number} [parameters.num_results_per_page] - Number of facets per page in paginated response. Default value is 100.
2507
+ * @param {number} [parameters.numResultsPerPage] - Number of facets per page in paginated response. Default value is 100.
2467
2508
  * @param {string} [parameters.section] - The section in which your facet is defined. Default value is Products.
2468
2509
  * @param {object} [networkParameters] - Parameters relevant to the network request
2469
2510
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -2472,7 +2513,7 @@ class Catalog {
2472
2513
  * @example
2473
2514
  * constructorio.catalog.getFacetConfigurations({
2474
2515
  * page: 2,
2475
- * num_results_per_page: 50,
2516
+ * numResultsPerPage: 50,
2476
2517
  * });
2477
2518
  */
2478
2519
  getFacetConfigurations(parameters = {}, networkParameters = {}) {
@@ -2480,10 +2521,19 @@ class Catalog {
2480
2521
  const { fetch } = this.options;
2481
2522
  const controller = new AbortController();
2482
2523
  const { signal } = controller;
2524
+ const { num_results_per_page, numResultsPerPage = num_results_per_page, page } = parameters;
2483
2525
  const additionalQueryParams = {
2484
2526
  section: parameters.section || 'Products',
2485
2527
  };
2486
2528
 
2529
+ if (numResultsPerPage) {
2530
+ additionalQueryParams.num_results_per_page = numResultsPerPage;
2531
+ }
2532
+
2533
+ if (page) {
2534
+ additionalQueryParams.page = page;
2535
+ }
2536
+
2487
2537
  try {
2488
2538
  requestUrl = createCatalogUrl('facets', this.options, additionalQueryParams);
2489
2539
  } catch (e) {
@@ -2576,9 +2626,9 @@ class Catalog {
2576
2626
  * {
2577
2627
  * name: 'color',
2578
2628
  * type: 'multiple',
2579
- * display_name: 'Color',
2580
- * sort_order: 'value',
2581
- * sort_descending: false,
2629
+ * displayName: 'Color',
2630
+ * sortOrder: 'value',
2631
+ * sortDescending: false,
2582
2632
  * position: 1,
2583
2633
  * },
2584
2634
  * {
@@ -2593,7 +2643,8 @@ class Catalog {
2593
2643
  const { fetch } = this.options;
2594
2644
  const controller = new AbortController();
2595
2645
  const { signal } = controller;
2596
- const { section, facetConfigurations } = parameters;
2646
+ const { section, facetConfigurations: facetConfigurationsRaw } = parameters;
2647
+ const facetConfigurations = facetConfigurationsRaw.map((config) => toSnakeCaseKeys(config));
2597
2648
  const additionalQueryParams = {
2598
2649
  section: section || 'Products',
2599
2650
  };
@@ -2633,15 +2684,15 @@ class Catalog {
2633
2684
  * @param {object} parameters - Additional parameters for facet configuration details
2634
2685
  * @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
2635
2686
  * @param {string} parameters.type - Type of facet. Must be one of multiple or range (numerical).
2636
- * @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.
2637
- * @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.
2638
- * @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.
2639
- * @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.
2640
- * @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).
2641
- * @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).
2642
- * @param {number} [parameters.bucket_size] - Specifies the size of generated buckets. Default is null. Either this or range_limits are required for facet type range, format options, and range_type static
2643
- * @param {number[]} [parameters.range_limits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
2644
- * @param {string} [parameters.match_type] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
2687
+ * @param {string} [parameters.displayName] - The name of the facet presented to the end users. Defaults to null, in which case the name will be presented.
2688
+ * @param {string} [parameters.sortOrder] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, numMatches. Defaults to relevance. Can be overridden by setting position attribute on facet options.
2689
+ * @param {boolean} [parameters.sortDescending] - Set to true if the options should be sorted in descending order, false to sort ascending. Default value is true if sortOrder is relevance and false for others.
2690
+ * @param {string} [parameters.rangeType] - 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 rangeFormat is options.
2691
+ * @param {string} [parameters.rangeFormat] - 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).
2692
+ * @param {string} [parameters.rangeInclusive] - 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).
2693
+ * @param {number} [parameters.bucketSize] - Specifies the size of generated buckets. Default is null. Either this or rangeLimits are required for facet type range, format options, and rangeType static
2694
+ * @param {json} [parameters.rangeLimits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
2695
+ * @param {string} [parameters.matchType] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
2645
2696
  * @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
2646
2697
  * @param {boolean} [parameters.hidden] - Specifies whether the facet is hidden from users. Used for non-sensitive data that you don't want to show to end users. Default value is false.
2647
2698
  * @param {boolean} [parameters.protected] - Specifies whether the facet is protected from users. Setting to true will require authentication to view the facet. Default value is false.
@@ -2656,9 +2707,9 @@ class Catalog {
2656
2707
  * constructorio.catalog.replaceFacetConfiguration({
2657
2708
  * name: 'color',
2658
2709
  * type: 'multiple',
2659
- * display_name: 'Color',
2660
- * sort_order: 'value',
2661
- * sort_descending: false,
2710
+ * displayName: 'Color',
2711
+ * sortOrder: 'value',
2712
+ * sortDescending: false,
2662
2713
  * position: 1,
2663
2714
  * });
2664
2715
  */
@@ -2683,7 +2734,7 @@ class Catalog {
2683
2734
 
2684
2735
  return fetch(requestUrl, {
2685
2736
  method: 'PUT',
2686
- body: JSON.stringify({ name, ...rest }),
2737
+ body: JSON.stringify(toSnakeCaseKeys({ name, ...rest })),
2687
2738
  headers: {
2688
2739
  'Content-Type': 'application/json',
2689
2740
  ...helpers.createAuthHeader(this.options),
@@ -2705,15 +2756,15 @@ class Catalog {
2705
2756
  * @param {object} parameters - Additional parameters for facet configuration details
2706
2757
  * @param {string} parameters.name - Unique facet name used to refer to the facet in your catalog
2707
2758
  * @param {string} parameters.type - Type of facet. Must be one of multiple or range (numerical).
2708
- * @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.
2709
- * @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.
2710
- * @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.
2711
- * @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.
2712
- * @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).
2713
- * @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).
2714
- * @param {number} [parameters.bucket_size] - Specifies the size of generated buckets. Default is null. Either this or range_limits are required for facet type range, format options, and range_type static
2715
- * @param {number[]} [parameters.range_limits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
2716
- * @param {string} [parameters.match_type] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
2759
+ * @param {string} [parameters.displayName] - The name of the facet presented to the end users. Defaults to null, in which case the name will be presented.
2760
+ * @param {string} [parameters.sortOrder] - Defines the criterion by which the options of this facet group are sorted. Must be one of relevance, value, numMatches. Defaults to relevance. Can be overridden by setting position attribute on facet options.
2761
+ * @param {boolean} [parameters.sortDescending] - Set to true if the options should be sorted in descending order, false to sort ascending. Default value is true if sortOrder is relevance and false for others.
2762
+ * @param {string} [parameters.rangeType] - 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 rangeFormat is options.
2763
+ * @param {string} [parameters.rangeFormat] - 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).
2764
+ * @param {string} [parameters.rangeInclusive] - 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).
2765
+ * @param {number} [parameters.bucketSize] - Specifies the size of generated buckets. Default is null. Either this or rangeLimits are required for facet type range, format options, and rangeType static
2766
+ * @param {json} [parameters.rangeLimits] - Defines the cut-off points for generating static range buckets. Should be a list of sorted numbers (i.e. [10, 25, 40]). Default value is null.
2767
+ * @param {string} [parameters.matchType] - Specifies the behavior of filters when multiple options of the same facet group are selected. Must be one of any, all, or none. Default value is any.
2717
2768
  * @param {number} [parameters.position] - Slot facet groups to fixed positions. Default value is null.
2718
2769
  * @param {boolean} [parameters.hidden] - Specifies whether the facet is hidden from users. Used for non-sensitive data that you don't want to show to end users. Default value is false.
2719
2770
  * @param {boolean} [parameters.protected] - Specifies whether the facet is protected from users. Setting to true will require authentication to view the facet. Default value is false.
@@ -2728,9 +2779,9 @@ class Catalog {
2728
2779
  * constructorio.catalog.modifyFacetConfiguration({
2729
2780
  * name: 'color',
2730
2781
  * type: 'multiple',
2731
- * display_name: 'Color',
2732
- * sort_order: 'num_matches',
2733
- * sort_descending: true,
2782
+ * displayName: 'Color',
2783
+ * sortOrder: 'num_matches',
2784
+ * sortDescending: true,
2734
2785
  * position: 1,
2735
2786
  * });
2736
2787
  */
@@ -2755,7 +2806,7 @@ class Catalog {
2755
2806
 
2756
2807
  return fetch(requestUrl, {
2757
2808
  method: 'PATCH',
2758
- body: JSON.stringify({ name, ...rest }),
2809
+ body: JSON.stringify(toSnakeCaseKeys({ name, ...rest })),
2759
2810
  headers: {
2760
2811
  'Content-Type': 'application/json',
2761
2812
  ...helpers.createAuthHeader(this.options),
@@ -2829,7 +2880,7 @@ class Catalog {
2829
2880
  * @param {object} parameters - Additional parameters for facet option configuration details
2830
2881
  * @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
2831
2882
  * @param {string} parameters.value - A unique value for the facet option
2832
- * @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
2883
+ * @param {string} [parameters.displayName=null] - The name of the facet presented to the end users - if none is supplied, the value from name will be used
2833
2884
  * @param {number} [parameters.position=null] - Slot facet groups to fixed positions
2834
2885
  * @param {boolean} [parameters.hidden=false] - Specifies whether the facet option is hidden from users
2835
2886
  * @param {object} [parameters.data={}] - Dictionary/Object with any extra facet data
@@ -2842,7 +2893,7 @@ class Catalog {
2842
2893
  * constructorio.catalog.addFacetOptionConfiguration({
2843
2894
  * facetGroupName: 'color',
2844
2895
  * value: 'blue',
2845
- * display_name: 'Blue',
2896
+ * displayName: 'Blue',
2846
2897
  * position: 5,
2847
2898
  * });
2848
2899
  */
@@ -2867,7 +2918,7 @@ class Catalog {
2867
2918
 
2868
2919
  return fetch(requestUrl, {
2869
2920
  method: 'POST',
2870
- body: JSON.stringify(rest),
2921
+ body: JSON.stringify(toSnakeCaseKeys(rest)),
2871
2922
  headers: {
2872
2923
  'Content-Type': 'application/json',
2873
2924
  ...helpers.createAuthHeader(this.options),
@@ -2900,12 +2951,12 @@ class Catalog {
2900
2951
  * facetOptionConfigurations: [
2901
2952
  * {
2902
2953
  * value: 'blue',
2903
- * display_name: 'Blue',
2954
+ * displayName: 'Blue',
2904
2955
  * position: 5,
2905
2956
  * },
2906
2957
  * {
2907
2958
  * value: 'red',
2908
- * display_name: 'Red',
2959
+ * displayName: 'Red',
2909
2960
  * position: 3,
2910
2961
  * },
2911
2962
  * ],
@@ -2916,7 +2967,8 @@ class Catalog {
2916
2967
  const { fetch } = this.options;
2917
2968
  const controller = new AbortController();
2918
2969
  const { signal } = controller;
2919
- const { facetGroupName, section, facetOptionConfigurations } = parameters;
2970
+ const { facetGroupName, section, facetOptionConfigurations: facetOptionConfigurationsRaw } = parameters;
2971
+ const facetOptionConfigurations = facetOptionConfigurationsRaw.map((config) => toSnakeCaseKeys(config));
2920
2972
  const additionalQueryParams = {
2921
2973
  section: section || 'Products',
2922
2974
  };
@@ -2954,7 +3006,7 @@ class Catalog {
2954
3006
  * @param {object} parameters - Additional parameters for facet option configuration details
2955
3007
  * @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
2956
3008
  * @param {number} [parameters.page=1] - Page number you'd like to request
2957
- * @param {number} [parameters.num_results_per_page=100] - Number of facets per page in paginated response
3009
+ * @param {number} [parameters.numResultsPerPage=100] - Number of facets per page in paginated response
2958
3010
  * @param {string} [parameters.section='Products'] - The section in which your facet is defined
2959
3011
  * @param {object} [networkParameters] - Parameters relevant to the network request
2960
3012
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -2964,7 +3016,7 @@ class Catalog {
2964
3016
  * constructorio.catalog.getFacetOptionConfigurations({
2965
3017
  * facetGroupName: 'color',
2966
3018
  * page: 3,
2967
- * num_results_per_page: 50
3019
+ * numResultsPerPage: 50
2968
3020
  * });
2969
3021
  */
2970
3022
  getFacetOptionConfigurations(parameters = {}, networkParameters = {}) {
@@ -2972,11 +3024,25 @@ class Catalog {
2972
3024
  const { fetch } = this.options;
2973
3025
  const controller = new AbortController();
2974
3026
  const { signal } = controller;
2975
- const { facetGroupName, section } = parameters;
3027
+ const {
3028
+ facetGroupName,
3029
+ section,
3030
+ num_results_per_page,
3031
+ numResultsPerPage = num_results_per_page,
3032
+ page,
3033
+ } = parameters;
2976
3034
  const additionalQueryParams = {
2977
3035
  section: section || 'Products',
2978
3036
  };
2979
3037
 
3038
+ if (numResultsPerPage) {
3039
+ additionalQueryParams.num_results_per_page = numResultsPerPage;
3040
+ }
3041
+
3042
+ if (page) {
3043
+ additionalQueryParams.page = page;
3044
+ }
3045
+
2980
3046
  try {
2981
3047
  requestUrl = createCatalogUrl(`facets/${facetGroupName}/options`, this.options, additionalQueryParams);
2982
3048
  } catch (e) {
@@ -3062,7 +3128,7 @@ class Catalog {
3062
3128
  * @param {object} parameters - Additional parameters for facet option configuration details
3063
3129
  * @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
3064
3130
  * @param {string} parameters.value - A unique facet option value
3065
- * @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
3131
+ * @param {string} [parameters.displayName=null] - The name of the facet presented to the end users - if none is supplied, the value from name will be used
3066
3132
  * @param {number} [parameters.position=null] - Slot facet groups to fixed positions
3067
3133
  * @param {boolean} [parameters.hidden=false] - Specifies whether the facet option is hidden from users
3068
3134
  * @param {object} [parameters.data={}] - Dictionary/Object with any extra facet data
@@ -3075,7 +3141,7 @@ class Catalog {
3075
3141
  * constructorio.catalog.replaceFacetOptionConfiguration({
3076
3142
  * facetGroupName: 'color',
3077
3143
  * value: 'blue',
3078
- * display_name: 'Midnight Blue',
3144
+ * displayName: 'Midnight Blue',
3079
3145
  * position: 9,
3080
3146
  * });
3081
3147
  */
@@ -3100,7 +3166,7 @@ class Catalog {
3100
3166
 
3101
3167
  return fetch(requestUrl, {
3102
3168
  method: 'PUT',
3103
- body: JSON.stringify({ value, ...rest }),
3169
+ body: JSON.stringify(toSnakeCaseKeys({ value, ...rest })),
3104
3170
  headers: {
3105
3171
  'Content-Type': 'application/json',
3106
3172
  ...helpers.createAuthHeader(this.options),
@@ -3122,7 +3188,7 @@ class Catalog {
3122
3188
  * @param {object} parameters - Additional parameters for facet option configuration details
3123
3189
  * @param {string} parameters.facetGroupName - Unique facet name used to refer to the facet in your catalog
3124
3190
  * @param {string} parameters.value - A unique facet option value
3125
- * @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
3191
+ * @param {string} [parameters.displayName=null] - The name of the facet presented to the end users - if none is supplied, the value from name will be used
3126
3192
  * @param {number} [parameters.position=null] - Slot facet groups to fixed positions
3127
3193
  * @param {boolean} [parameters.hidden=false] - Specifies whether the facet option is hidden from users
3128
3194
  * @param {object} [parameters.data={}] - Dictionary/Object with any extra facet data
@@ -3135,7 +3201,7 @@ class Catalog {
3135
3201
  * constructorio.catalog.modifyFacetOptionConfiguration({
3136
3202
  * facetGroupName: 'color',
3137
3203
  * value: 'blue',
3138
- * display_name: 'Midnight Blue',
3204
+ * displayName: 'Midnight Blue',
3139
3205
  * position: 9,
3140
3206
  * });
3141
3207
  */
@@ -3160,7 +3226,7 @@ class Catalog {
3160
3226
 
3161
3227
  return fetch(requestUrl, {
3162
3228
  method: 'PATCH',
3163
- body: JSON.stringify({ value, ...rest }),
3229
+ body: JSON.stringify(toSnakeCaseKeys({ value, ...rest })),
3164
3230
  headers: {
3165
3231
  'Content-Type': 'application/json',
3166
3232
  ...helpers.createAuthHeader(this.options),