@revenexx/sdk 0.0.7 → 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.7'
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,12 +12707,104 @@ class Orders {
12588
12707
 
12589
12708
  /**
12590
12709
  *
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).
12713
+ * @param {string} params.contactId - Filter to one ordering contact.
12714
+ * @param {string} params.organizationId - Filter to one B2B organization.
12715
+ * @param {string} params.channelId - Filter to one sales channel.
12716
+ * @param {string} params.marketId - Filter to one market.
12717
+ * @param {string} params.number - Filter by exact order number.
12718
+ * @param {number} params.limit - Page size (default 50, max 200).
12719
+ * @param {number} params.offset - Row offset for pagination (default 0).
12720
+ * @param {string} params.order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
12721
+ * @throws {RevenexxException}
12722
+ * @returns {Promise<{}>}
12723
+ */
12724
+
12725
+ /**
12726
+ *
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).
12730
+ * @param {string} contactId - Filter to one ordering contact.
12731
+ * @param {string} organizationId - Filter to one B2B organization.
12732
+ * @param {string} channelId - Filter to one sales channel.
12733
+ * @param {string} marketId - Filter to one market.
12734
+ * @param {string} number - Filter by exact order number.
12735
+ * @param {number} limit - Page size (default 50, max 200).
12736
+ * @param {number} offset - Row offset for pagination (default 0).
12737
+ * @param {string} order - Sort as 'column.asc' | 'column.desc', e.g. 'created_at.desc'.
12591
12738
  * @throws {RevenexxException}
12592
12739
  * @returns {Promise<{}>}
12740
+ * @deprecated Use the object parameter style method for a better developer experience.
12593
12741
  */
12594
- ordersList() {
12742
+
12743
+ ordersList(paramsOrFirst, ...rest) {
12744
+ let params;
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)) {
12746
+ params = paramsOrFirst || {};
12747
+ } else {
12748
+ params = {
12749
+ status: paramsOrFirst,
12750
+ paymentStatus: rest[0],
12751
+ fulfillmentStatus: rest[1],
12752
+ contactId: rest[2],
12753
+ organizationId: rest[3],
12754
+ channelId: rest[4],
12755
+ marketId: rest[5],
12756
+ number: rest[6],
12757
+ limit: rest[7],
12758
+ offset: rest[8],
12759
+ order: rest[9]
12760
+ };
12761
+ }
12762
+ const status = params.status;
12763
+ const paymentStatus = params.paymentStatus;
12764
+ const fulfillmentStatus = params.fulfillmentStatus;
12765
+ const contactId = params.contactId;
12766
+ const organizationId = params.organizationId;
12767
+ const channelId = params.channelId;
12768
+ const marketId = params.marketId;
12769
+ const number = params.number;
12770
+ const limit = params.limit;
12771
+ const offset = params.offset;
12772
+ const order = params.order;
12595
12773
  const apiPath = '/v1/orders';
12596
12774
  const apiPayload = {};
12775
+ if (typeof status !== 'undefined') {
12776
+ apiPayload['status'] = status;
12777
+ }
12778
+ if (typeof paymentStatus !== 'undefined') {
12779
+ apiPayload['payment_status'] = paymentStatus;
12780
+ }
12781
+ if (typeof fulfillmentStatus !== 'undefined') {
12782
+ apiPayload['fulfillment_status'] = fulfillmentStatus;
12783
+ }
12784
+ if (typeof contactId !== 'undefined') {
12785
+ apiPayload['contact_id'] = contactId;
12786
+ }
12787
+ if (typeof organizationId !== 'undefined') {
12788
+ apiPayload['organization_id'] = organizationId;
12789
+ }
12790
+ if (typeof channelId !== 'undefined') {
12791
+ apiPayload['channel_id'] = channelId;
12792
+ }
12793
+ if (typeof marketId !== 'undefined') {
12794
+ apiPayload['market_id'] = marketId;
12795
+ }
12796
+ if (typeof number !== 'undefined') {
12797
+ apiPayload['number'] = number;
12798
+ }
12799
+ if (typeof limit !== 'undefined') {
12800
+ apiPayload['limit'] = limit;
12801
+ }
12802
+ if (typeof offset !== 'undefined') {
12803
+ apiPayload['offset'] = offset;
12804
+ }
12805
+ if (typeof order !== 'undefined') {
12806
+ apiPayload['order'] = order;
12807
+ }
12597
12808
  const uri = new URL(this.client.config.endpoint + apiPath);
12598
12809
  const apiHeaders = {};
12599
12810
  return this.client.call('get', uri, apiHeaders, apiPayload);
@@ -13010,7 +13221,36 @@ class Orders {
13010
13221
  apiPayload['grand_total'] = grandTotal;
13011
13222
  }
13012
13223
  if (typeof items !== 'undefined') {
13013
- 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
+ });
13014
13254
  }
13015
13255
  if (typeof marketId !== 'undefined') {
13016
13256
  apiPayload['market_id'] = marketId;
@@ -13476,7 +13716,12 @@ class Orders {
13476
13716
  apiPayload['cancelled_by'] = cancelledBy;
13477
13717
  }
13478
13718
  if (typeof positions !== 'undefined') {
13479
- apiPayload['positions'] = positions;
13719
+ apiPayload['positions'] = Client.toWireKeys(positions, {
13720
+ "orderItemId": {
13721
+ "wire": "order_item_id",
13722
+ "children": null
13723
+ }
13724
+ });
13480
13725
  }
13481
13726
  if (typeof reason !== 'undefined') {
13482
13727
  apiPayload['reason'] = reason;
@@ -13591,7 +13836,12 @@ class Orders {
13591
13836
  apiPayload['metadata'] = metadata;
13592
13837
  }
13593
13838
  if (typeof positions !== 'undefined') {
13594
- apiPayload['positions'] = positions;
13839
+ apiPayload['positions'] = Client.toWireKeys(positions, {
13840
+ "orderItemId": {
13841
+ "wire": "order_item_id",
13842
+ "children": null
13843
+ }
13844
+ });
13595
13845
  }
13596
13846
  if (typeof reason !== 'undefined') {
13597
13847
  apiPayload['reason'] = reason;
@@ -13834,7 +14084,12 @@ class Orders {
13834
14084
  apiPayload['number'] = number;
13835
14085
  }
13836
14086
  if (typeof positions !== 'undefined') {
13837
- apiPayload['positions'] = positions;
14087
+ apiPayload['positions'] = Client.toWireKeys(positions, {
14088
+ "orderItemId": {
14089
+ "wire": "order_item_id",
14090
+ "children": null
14091
+ }
14092
+ });
13838
14093
  }
13839
14094
  if (typeof shippedAt !== 'undefined') {
13840
14095
  apiPayload['shipped_at'] = shippedAt;
@@ -17477,7 +17732,32 @@ class Prices {
17477
17732
  const apiPath = '/v1/prices/lists/{list_id}/entries'.replace('{list_id}', listId);
17478
17733
  const apiPayload = {};
17479
17734
  if (typeof entries !== 'undefined') {
17480
- 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
+ });
17481
17761
  }
17482
17762
  const uri = new URL(this.client.config.endpoint + apiPath);
17483
17763
  const apiHeaders = {
@@ -17524,7 +17804,32 @@ class Prices {
17524
17804
  const apiPath = '/v1/prices/lists/{list_id}/entries/bulk'.replace('{list_id}', listId);
17525
17805
  const apiPayload = {};
17526
17806
  if (typeof entries !== 'undefined') {
17527
- 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
+ });
17528
17833
  }
17529
17834
  const uri = new URL(this.client.config.endpoint + apiPath);
17530
17835
  const apiHeaders = {
@@ -17791,7 +18096,12 @@ class Prices {
17791
18096
  apiPayload['currency'] = currency;
17792
18097
  }
17793
18098
  if (typeof items !== 'undefined') {
17794
- apiPayload['items'] = items;
18099
+ apiPayload['items'] = Client.toWireKeys(items, {
18100
+ "productId": {
18101
+ "wire": "product_id",
18102
+ "children": null
18103
+ }
18104
+ });
17795
18105
  }
17796
18106
  if (typeof marketId !== 'undefined') {
17797
18107
  apiPayload['market_id'] = marketId;
@@ -21748,7 +22058,28 @@ class Search {
21748
22058
  const apiPath = '/v1/search/multi_search';
21749
22059
  const apiPayload = {};
21750
22060
  if (typeof searches !== 'undefined') {
21751
- 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
+ });
21752
22083
  }
21753
22084
  const uri = new URL(this.client.config.endpoint + apiPath);
21754
22085
  const apiHeaders = {
@@ -22302,7 +22633,12 @@ class Shipping {
22302
22633
  const apiPath = '/v1/shipping/methods/{method_id}/tiers'.replace('{method_id}', methodId);
22303
22634
  const apiPayload = {};
22304
22635
  if (typeof tiers !== 'undefined') {
22305
- apiPayload['tiers'] = tiers;
22636
+ apiPayload['tiers'] = Client.toWireKeys(tiers, {
22637
+ "fromValue": {
22638
+ "wire": "from_value",
22639
+ "children": null
22640
+ }
22641
+ });
22306
22642
  }
22307
22643
  const uri = new URL(this.client.config.endpoint + apiPath);
22308
22644
  const apiHeaders = {
@@ -27183,10 +27519,13 @@ let OrderListKind = /*#__PURE__*/function (OrderListKind) {
27183
27519
  return OrderListKind;
27184
27520
  }({});
27185
27521
 
27186
- let OrderCommentVisibility = /*#__PURE__*/function (OrderCommentVisibility) {
27187
- OrderCommentVisibility["Internal"] = "internal";
27188
- OrderCommentVisibility["Customer"] = "customer";
27189
- 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;
27190
27529
  }({});
27191
27530
 
27192
27531
  let OrderPaymentStatus = /*#__PURE__*/function (OrderPaymentStatus) {
@@ -27200,6 +27539,19 @@ let OrderPaymentStatus = /*#__PURE__*/function (OrderPaymentStatus) {
27200
27539
  return OrderPaymentStatus;
27201
27540
  }({});
27202
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
+
27203
27555
  let PageStatus = /*#__PURE__*/function (PageStatus) {
27204
27556
  PageStatus["Draft"] = "draft";
27205
27557
  PageStatus["Published"] = "published";
@@ -27818,9 +28170,11 @@ exports.Messaging = Messaging;
27818
28170
  exports.Method = Method;
27819
28171
  exports.Operator = Operator;
27820
28172
  exports.OrderCommentVisibility = OrderCommentVisibility;
28173
+ exports.OrderFulfillmentStatus = OrderFulfillmentStatus;
27821
28174
  exports.OrderItemType = OrderItemType;
27822
28175
  exports.OrderListKind = OrderListKind;
27823
28176
  exports.OrderPaymentStatus = OrderPaymentStatus;
28177
+ exports.OrderStatus = OrderStatus;
27824
28178
  exports.Orderlists = Orderlists;
27825
28179
  exports.Orders = Orders;
27826
28180
  exports.OrganizationStatus = OrganizationStatus;