@revenexx/sdk 0.0.9 → 0.0.10

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/dist/cjs/sdk.js CHANGED
@@ -657,7 +657,7 @@ class Client {
657
657
  'x-sdk-name': 'Revenexx Web',
658
658
  'x-sdk-platform': '',
659
659
  'x-sdk-language': 'web',
660
- 'x-sdk-version': '0.0.9'
660
+ 'x-sdk-version': '0.0.10'
661
661
  };
662
662
 
663
663
  /**
@@ -1137,6 +1137,29 @@ class Client {
1137
1137
  }
1138
1138
  return data;
1139
1139
  }
1140
+
1141
+ /**
1142
+ * Recursively renames an argument's DECLARED keys to their snake_case wire
1143
+ * names, using a map generated from the API contract. Free-form subtrees
1144
+ * (metadata / user_data — keys absent from the map, with no `children`) are
1145
+ * passed through untouched, so user data is never mangled. For arrays the
1146
+ * same element map is applied to every item.
1147
+ */
1148
+ static toWireKeys(value, map) {
1149
+ if (Array.isArray(value)) {
1150
+ return value.map(item => Client.toWireKeys(item, map));
1151
+ }
1152
+ if (value === null || typeof value !== 'object' || value instanceof File || value instanceof Blob || value instanceof Date) {
1153
+ return value;
1154
+ }
1155
+ const output = {};
1156
+ for (const [key, item] of Object.entries(value)) {
1157
+ const entry = map[key];
1158
+ const wireKey = entry ? entry.wire : key;
1159
+ output[wireKey] = entry && entry.children ? Client.toWireKeys(item, entry.children) : item;
1160
+ }
1161
+ return output;
1162
+ }
1140
1163
  static flatten(data, prefix = '') {
1141
1164
  let output = {};
1142
1165
  for (const [key, value] of Object.entries(data)) {
@@ -4508,7 +4531,20 @@ class Carts {
4508
4531
  const apiPath = '/v1/carts/{cart_id}/items'.replace('{cart_id}', cartId);
4509
4532
  const apiPayload = {};
4510
4533
  if (typeof items !== 'undefined') {
4511
- apiPayload['items'] = items;
4534
+ apiPayload['items'] = Client.toWireKeys(items, {
4535
+ "productId": {
4536
+ "wire": "product_id",
4537
+ "children": null
4538
+ },
4539
+ "taxRate": {
4540
+ "wire": "tax_rate",
4541
+ "children": null
4542
+ },
4543
+ "unitPrice": {
4544
+ "wire": "unit_price",
4545
+ "children": null
4546
+ }
4547
+ });
4512
4548
  }
4513
4549
  const uri = new URL(this.client.config.endpoint + apiPath);
4514
4550
  const apiHeaders = {
@@ -6797,7 +6833,12 @@ class Inventories {
6797
6833
  const apiPath = '/v1/inventories/adjust';
6798
6834
  const apiPayload = {};
6799
6835
  if (typeof items !== 'undefined') {
6800
- apiPayload['items'] = items;
6836
+ apiPayload['items'] = Client.toWireKeys(items, {
6837
+ "productId": {
6838
+ "wire": "product_id",
6839
+ "children": null
6840
+ }
6841
+ });
6801
6842
  }
6802
6843
  if (typeof locationCode !== 'undefined') {
6803
6844
  apiPayload['location_code'] = locationCode;
@@ -6847,7 +6888,12 @@ class Inventories {
6847
6888
  const apiPath = '/v1/inventories/availability';
6848
6889
  const apiPayload = {};
6849
6890
  if (typeof items !== 'undefined') {
6850
- apiPayload['items'] = items;
6891
+ apiPayload['items'] = Client.toWireKeys(items, {
6892
+ "productId": {
6893
+ "wire": "product_id",
6894
+ "children": null
6895
+ }
6896
+ });
6851
6897
  }
6852
6898
  if (typeof locationCode !== 'undefined') {
6853
6899
  apiPayload['location_code'] = locationCode;
@@ -7267,7 +7313,12 @@ class Inventories {
7267
7313
  const apiPath = '/v1/inventories/receive';
7268
7314
  const apiPayload = {};
7269
7315
  if (typeof items !== 'undefined') {
7270
- apiPayload['items'] = items;
7316
+ apiPayload['items'] = Client.toWireKeys(items, {
7317
+ "productId": {
7318
+ "wire": "product_id",
7319
+ "children": null
7320
+ }
7321
+ });
7271
7322
  }
7272
7323
  if (typeof locationCode !== 'undefined') {
7273
7324
  apiPayload['location_code'] = locationCode;
@@ -7415,7 +7466,12 @@ class Inventories {
7415
7466
  apiPayload['expires_at'] = expiresAt;
7416
7467
  }
7417
7468
  if (typeof items !== 'undefined') {
7418
- apiPayload['items'] = items;
7469
+ apiPayload['items'] = Client.toWireKeys(items, {
7470
+ "productId": {
7471
+ "wire": "product_id",
7472
+ "children": null
7473
+ }
7474
+ });
7419
7475
  }
7420
7476
  if (typeof orderRef !== 'undefined') {
7421
7477
  apiPayload['order_ref'] = orderRef;
@@ -7470,7 +7526,12 @@ class Inventories {
7470
7526
  const apiPath = '/v1/inventories/restock';
7471
7527
  const apiPayload = {};
7472
7528
  if (typeof items !== 'undefined') {
7473
- apiPayload['items'] = items;
7529
+ apiPayload['items'] = Client.toWireKeys(items, {
7530
+ "productId": {
7531
+ "wire": "product_id",
7532
+ "children": null
7533
+ }
7534
+ });
7474
7535
  }
7475
7536
  if (typeof locationCode !== 'undefined') {
7476
7537
  apiPayload['location_code'] = locationCode;
@@ -11941,7 +12002,36 @@ class Orderlists {
11941
12002
  const apiPath = '/v1/orderlists';
11942
12003
  const apiPayload = {};
11943
12004
  if (typeof items !== 'undefined') {
11944
- apiPayload['items'] = items;
12005
+ apiPayload['items'] = Client.toWireKeys(items, {
12006
+ "categorySlug": {
12007
+ "wire": "category_slug",
12008
+ "children": null
12009
+ },
12010
+ "costCenterId": {
12011
+ "wire": "cost_center_id",
12012
+ "children": null
12013
+ },
12014
+ "customSku": {
12015
+ "wire": "custom_sku",
12016
+ "children": null
12017
+ },
12018
+ "positionTexts": {
12019
+ "wire": "position_texts",
12020
+ "children": null
12021
+ },
12022
+ "productId": {
12023
+ "wire": "product_id",
12024
+ "children": null
12025
+ },
12026
+ "subcategorySlug": {
12027
+ "wire": "subcategory_slug",
12028
+ "children": null
12029
+ },
12030
+ "taxRate": {
12031
+ "wire": "tax_rate",
12032
+ "children": null
12033
+ }
12034
+ });
11945
12035
  }
11946
12036
  if (typeof kind !== 'undefined') {
11947
12037
  apiPayload['kind'] = kind;
@@ -12337,7 +12427,36 @@ class Orderlists {
12337
12427
  const apiPath = '/v1/orderlists/{list_id}/items'.replace('{list_id}', listId);
12338
12428
  const apiPayload = {};
12339
12429
  if (typeof items !== 'undefined') {
12340
- apiPayload['items'] = items;
12430
+ apiPayload['items'] = Client.toWireKeys(items, {
12431
+ "categorySlug": {
12432
+ "wire": "category_slug",
12433
+ "children": null
12434
+ },
12435
+ "costCenterId": {
12436
+ "wire": "cost_center_id",
12437
+ "children": null
12438
+ },
12439
+ "customSku": {
12440
+ "wire": "custom_sku",
12441
+ "children": null
12442
+ },
12443
+ "positionTexts": {
12444
+ "wire": "position_texts",
12445
+ "children": null
12446
+ },
12447
+ "productId": {
12448
+ "wire": "product_id",
12449
+ "children": null
12450
+ },
12451
+ "subcategorySlug": {
12452
+ "wire": "subcategory_slug",
12453
+ "children": null
12454
+ },
12455
+ "taxRate": {
12456
+ "wire": "tax_rate",
12457
+ "children": null
12458
+ }
12459
+ });
12341
12460
  }
12342
12461
  const uri = new URL(this.client.config.endpoint + apiPath);
12343
12462
  const apiHeaders = {
@@ -12588,9 +12707,9 @@ class Orders {
12588
12707
 
12589
12708
  /**
12590
12709
  *
12591
- * @param {string} params.status - Filter by order status (exact match): pending | placed | in_fulfillment | completed | cancelled.
12592
- * @param {string} params.paymentStatus - Filter by payment status (exact match): open | pending | authorized | paid | partially_paid | refunded | failed.
12593
- * @param {string} params.fulfillmentStatus - Filter by fulfillment status (exact match): unfulfilled | partial | fulfilled.
12710
+ * @param {OrderStatus} params.status - Filter by order status (exact match).
12711
+ * @param {OrderPaymentStatus} params.paymentStatus - Filter by payment status (exact match).
12712
+ * @param {OrderFulfillmentStatus} params.fulfillmentStatus - Filter by fulfillment status (exact match).
12594
12713
  * @param {string} params.contactId - Filter to one ordering contact.
12595
12714
  * @param {string} params.organizationId - Filter to one B2B organization.
12596
12715
  * @param {string} params.channelId - Filter to one sales channel.
@@ -12605,9 +12724,9 @@ class Orders {
12605
12724
 
12606
12725
  /**
12607
12726
  *
12608
- * @param {string} status - Filter by order status (exact match): pending | placed | in_fulfillment | completed | cancelled.
12609
- * @param {string} paymentStatus - Filter by payment status (exact match): open | pending | authorized | paid | partially_paid | refunded | failed.
12610
- * @param {string} fulfillmentStatus - Filter by fulfillment status (exact match): unfulfilled | partial | fulfilled.
12727
+ * @param {OrderStatus} status - Filter by order status (exact match).
12728
+ * @param {OrderPaymentStatus} paymentStatus - Filter by payment status (exact match).
12729
+ * @param {OrderFulfillmentStatus} fulfillmentStatus - Filter by fulfillment status (exact match).
12611
12730
  * @param {string} contactId - Filter to one ordering contact.
12612
12731
  * @param {string} organizationId - Filter to one B2B organization.
12613
12732
  * @param {string} channelId - Filter to one sales channel.
@@ -12623,7 +12742,7 @@ class Orders {
12623
12742
 
12624
12743
  ordersList(paramsOrFirst, ...rest) {
12625
12744
  let params;
12626
- if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst)) {
12745
+ if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('status' in paramsOrFirst || 'paymentStatus' in paramsOrFirst || 'fulfillmentStatus' in paramsOrFirst || 'contactId' in paramsOrFirst || 'organizationId' in paramsOrFirst || 'channelId' in paramsOrFirst || 'marketId' in paramsOrFirst || 'number' in paramsOrFirst || 'limit' in paramsOrFirst || 'offset' in paramsOrFirst || 'order' in paramsOrFirst)) {
12627
12746
  params = paramsOrFirst || {};
12628
12747
  } else {
12629
12748
  params = {
@@ -13102,7 +13221,36 @@ class Orders {
13102
13221
  apiPayload['grand_total'] = grandTotal;
13103
13222
  }
13104
13223
  if (typeof items !== 'undefined') {
13105
- apiPayload['items'] = items;
13224
+ apiPayload['items'] = Client.toWireKeys(items, {
13225
+ "costCenter": {
13226
+ "wire": "cost_center",
13227
+ "children": null
13228
+ },
13229
+ "positionText": {
13230
+ "wire": "position_text",
13231
+ "children": null
13232
+ },
13233
+ "productId": {
13234
+ "wire": "product_id",
13235
+ "children": null
13236
+ },
13237
+ "taxAmount": {
13238
+ "wire": "tax_amount",
13239
+ "children": null
13240
+ },
13241
+ "taxRate": {
13242
+ "wire": "tax_rate",
13243
+ "children": null
13244
+ },
13245
+ "unitPrice": {
13246
+ "wire": "unit_price",
13247
+ "children": null
13248
+ },
13249
+ "userData": {
13250
+ "wire": "user_data",
13251
+ "children": null
13252
+ }
13253
+ });
13106
13254
  }
13107
13255
  if (typeof marketId !== 'undefined') {
13108
13256
  apiPayload['market_id'] = marketId;
@@ -13568,7 +13716,12 @@ class Orders {
13568
13716
  apiPayload['cancelled_by'] = cancelledBy;
13569
13717
  }
13570
13718
  if (typeof positions !== 'undefined') {
13571
- apiPayload['positions'] = positions;
13719
+ apiPayload['positions'] = Client.toWireKeys(positions, {
13720
+ "orderItemId": {
13721
+ "wire": "order_item_id",
13722
+ "children": null
13723
+ }
13724
+ });
13572
13725
  }
13573
13726
  if (typeof reason !== 'undefined') {
13574
13727
  apiPayload['reason'] = reason;
@@ -13683,7 +13836,12 @@ class Orders {
13683
13836
  apiPayload['metadata'] = metadata;
13684
13837
  }
13685
13838
  if (typeof positions !== 'undefined') {
13686
- apiPayload['positions'] = positions;
13839
+ apiPayload['positions'] = Client.toWireKeys(positions, {
13840
+ "orderItemId": {
13841
+ "wire": "order_item_id",
13842
+ "children": null
13843
+ }
13844
+ });
13687
13845
  }
13688
13846
  if (typeof reason !== 'undefined') {
13689
13847
  apiPayload['reason'] = reason;
@@ -13926,7 +14084,12 @@ class Orders {
13926
14084
  apiPayload['number'] = number;
13927
14085
  }
13928
14086
  if (typeof positions !== 'undefined') {
13929
- apiPayload['positions'] = positions;
14087
+ apiPayload['positions'] = Client.toWireKeys(positions, {
14088
+ "orderItemId": {
14089
+ "wire": "order_item_id",
14090
+ "children": null
14091
+ }
14092
+ });
13930
14093
  }
13931
14094
  if (typeof shippedAt !== 'undefined') {
13932
14095
  apiPayload['shipped_at'] = shippedAt;
@@ -17569,7 +17732,32 @@ class Prices {
17569
17732
  const apiPath = '/v1/prices/lists/{list_id}/entries'.replace('{list_id}', listId);
17570
17733
  const apiPayload = {};
17571
17734
  if (typeof entries !== 'undefined') {
17572
- apiPayload['entries'] = entries;
17735
+ apiPayload['entries'] = Client.toWireKeys(entries, {
17736
+ "priceType": {
17737
+ "wire": "price_type",
17738
+ "children": null
17739
+ },
17740
+ "productId": {
17741
+ "wire": "product_id",
17742
+ "children": null
17743
+ },
17744
+ "quantityMin": {
17745
+ "wire": "quantity_min",
17746
+ "children": null
17747
+ },
17748
+ "unitPrice": {
17749
+ "wire": "unit_price",
17750
+ "children": null
17751
+ },
17752
+ "validFrom": {
17753
+ "wire": "valid_from",
17754
+ "children": null
17755
+ },
17756
+ "validUntil": {
17757
+ "wire": "valid_until",
17758
+ "children": null
17759
+ }
17760
+ });
17573
17761
  }
17574
17762
  const uri = new URL(this.client.config.endpoint + apiPath);
17575
17763
  const apiHeaders = {
@@ -17616,7 +17804,32 @@ class Prices {
17616
17804
  const apiPath = '/v1/prices/lists/{list_id}/entries/bulk'.replace('{list_id}', listId);
17617
17805
  const apiPayload = {};
17618
17806
  if (typeof entries !== 'undefined') {
17619
- apiPayload['entries'] = entries;
17807
+ apiPayload['entries'] = Client.toWireKeys(entries, {
17808
+ "priceType": {
17809
+ "wire": "price_type",
17810
+ "children": null
17811
+ },
17812
+ "productId": {
17813
+ "wire": "product_id",
17814
+ "children": null
17815
+ },
17816
+ "quantityMin": {
17817
+ "wire": "quantity_min",
17818
+ "children": null
17819
+ },
17820
+ "unitPrice": {
17821
+ "wire": "unit_price",
17822
+ "children": null
17823
+ },
17824
+ "validFrom": {
17825
+ "wire": "valid_from",
17826
+ "children": null
17827
+ },
17828
+ "validUntil": {
17829
+ "wire": "valid_until",
17830
+ "children": null
17831
+ }
17832
+ });
17620
17833
  }
17621
17834
  const uri = new URL(this.client.config.endpoint + apiPath);
17622
17835
  const apiHeaders = {
@@ -17883,7 +18096,12 @@ class Prices {
17883
18096
  apiPayload['currency'] = currency;
17884
18097
  }
17885
18098
  if (typeof items !== 'undefined') {
17886
- apiPayload['items'] = items;
18099
+ apiPayload['items'] = Client.toWireKeys(items, {
18100
+ "productId": {
18101
+ "wire": "product_id",
18102
+ "children": null
18103
+ }
18104
+ });
17887
18105
  }
17888
18106
  if (typeof marketId !== 'undefined') {
17889
18107
  apiPayload['market_id'] = marketId;
@@ -21840,7 +22058,28 @@ class Search {
21840
22058
  const apiPath = '/v1/search/multi_search';
21841
22059
  const apiPayload = {};
21842
22060
  if (typeof searches !== 'undefined') {
21843
- apiPayload['searches'] = searches;
22061
+ apiPayload['searches'] = Client.toWireKeys(searches, {
22062
+ "facetBy": {
22063
+ "wire": "facet_by",
22064
+ "children": null
22065
+ },
22066
+ "filterBy": {
22067
+ "wire": "filter_by",
22068
+ "children": null
22069
+ },
22070
+ "perPage": {
22071
+ "wire": "per_page",
22072
+ "children": null
22073
+ },
22074
+ "queryBy": {
22075
+ "wire": "query_by",
22076
+ "children": null
22077
+ },
22078
+ "sortBy": {
22079
+ "wire": "sort_by",
22080
+ "children": null
22081
+ }
22082
+ });
21844
22083
  }
21845
22084
  const uri = new URL(this.client.config.endpoint + apiPath);
21846
22085
  const apiHeaders = {
@@ -22394,7 +22633,12 @@ class Shipping {
22394
22633
  const apiPath = '/v1/shipping/methods/{method_id}/tiers'.replace('{method_id}', methodId);
22395
22634
  const apiPayload = {};
22396
22635
  if (typeof tiers !== 'undefined') {
22397
- apiPayload['tiers'] = tiers;
22636
+ apiPayload['tiers'] = Client.toWireKeys(tiers, {
22637
+ "fromValue": {
22638
+ "wire": "from_value",
22639
+ "children": null
22640
+ }
22641
+ });
22398
22642
  }
22399
22643
  const uri = new URL(this.client.config.endpoint + apiPath);
22400
22644
  const apiHeaders = {
@@ -27275,10 +27519,13 @@ let OrderListKind = /*#__PURE__*/function (OrderListKind) {
27275
27519
  return OrderListKind;
27276
27520
  }({});
27277
27521
 
27278
- let OrderCommentVisibility = /*#__PURE__*/function (OrderCommentVisibility) {
27279
- OrderCommentVisibility["Internal"] = "internal";
27280
- OrderCommentVisibility["Customer"] = "customer";
27281
- return OrderCommentVisibility;
27522
+ let OrderStatus = /*#__PURE__*/function (OrderStatus) {
27523
+ OrderStatus["Pending"] = "pending";
27524
+ OrderStatus["Placed"] = "placed";
27525
+ OrderStatus["InFulfillment"] = "in_fulfillment";
27526
+ OrderStatus["Completed"] = "completed";
27527
+ OrderStatus["Cancelled"] = "cancelled";
27528
+ return OrderStatus;
27282
27529
  }({});
27283
27530
 
27284
27531
  let OrderPaymentStatus = /*#__PURE__*/function (OrderPaymentStatus) {
@@ -27292,6 +27539,19 @@ let OrderPaymentStatus = /*#__PURE__*/function (OrderPaymentStatus) {
27292
27539
  return OrderPaymentStatus;
27293
27540
  }({});
27294
27541
 
27542
+ let OrderFulfillmentStatus = /*#__PURE__*/function (OrderFulfillmentStatus) {
27543
+ OrderFulfillmentStatus["Unfulfilled"] = "unfulfilled";
27544
+ OrderFulfillmentStatus["Partial"] = "partial";
27545
+ OrderFulfillmentStatus["Fulfilled"] = "fulfilled";
27546
+ return OrderFulfillmentStatus;
27547
+ }({});
27548
+
27549
+ let OrderCommentVisibility = /*#__PURE__*/function (OrderCommentVisibility) {
27550
+ OrderCommentVisibility["Internal"] = "internal";
27551
+ OrderCommentVisibility["Customer"] = "customer";
27552
+ return OrderCommentVisibility;
27553
+ }({});
27554
+
27295
27555
  let PageStatus = /*#__PURE__*/function (PageStatus) {
27296
27556
  PageStatus["Draft"] = "draft";
27297
27557
  PageStatus["Published"] = "published";
@@ -27910,9 +28170,11 @@ exports.Messaging = Messaging;
27910
28170
  exports.Method = Method;
27911
28171
  exports.Operator = Operator;
27912
28172
  exports.OrderCommentVisibility = OrderCommentVisibility;
28173
+ exports.OrderFulfillmentStatus = OrderFulfillmentStatus;
27913
28174
  exports.OrderItemType = OrderItemType;
27914
28175
  exports.OrderListKind = OrderListKind;
27915
28176
  exports.OrderPaymentStatus = OrderPaymentStatus;
28177
+ exports.OrderStatus = OrderStatus;
27916
28178
  exports.Orderlists = Orderlists;
27917
28179
  exports.Orders = Orders;
27918
28180
  exports.OrganizationStatus = OrganizationStatus;