idosell 0.4.24 → 0.4.25

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.
Files changed (54) hide show
  1. package/changelog.md +5 -0
  2. package/dist/app.d.ts +2 -1
  3. package/dist/gates.js +51 -15
  4. package/dist/gateways.d.ts +277 -20
  5. package/dist/helpers.js +18 -0
  6. package/dist/index.js +3 -1
  7. package/dist/methods/deletePromotions.js +6 -0
  8. package/dist/methods/deletePromotionsArchive.js +6 -0
  9. package/dist/methods/deletePromotionsElements.js +13 -0
  10. package/dist/methods/getPromotions.js +6 -0
  11. package/dist/methods/getPromotionsArchive.js +6 -0
  12. package/dist/methods/getPromotionsSettings.js +5 -0
  13. package/dist/methods/postPromotions.js +7 -0
  14. package/dist/methods/postPromotionsElements.js +13 -0
  15. package/dist/methods/postPromotionsEnd.js +7 -0
  16. package/dist/methods/postPromotionsStart.js +7 -0
  17. package/dist/methods/putPromotions.js +8 -0
  18. package/dist/methods/putPromotionsSettings.js +6 -0
  19. package/dist/methods/searchPromotionsArchive.js +14 -0
  20. package/dist/methods/searchPromotionsElements.js +15 -0
  21. package/dist/methods/searchPromotionsHistory.js +13 -0
  22. package/dist/methods/searchPromotionsListView.js +21 -0
  23. package/dist/params.js +15 -1
  24. package/dist/reqparams.d.ts +2 -2
  25. package/dist/request.js +33 -10
  26. package/package.json +1 -1
  27. package/tests/deleteProductsToFacebookCatalog.test.js +7 -0
  28. package/tests/deleteProductsToPromotion.test.js +7 -0
  29. package/tests/deletePromotions.test.js +7 -0
  30. package/tests/deletePromotionsArchive.test.js +7 -0
  31. package/tests/deletePromotionsElements.test.js +7 -0
  32. package/tests/getProductsToFacebookCatalog.test.js +8 -0
  33. package/tests/getPromotions.test.js +7 -0
  34. package/tests/getPromotionsArchive.test.js +7 -0
  35. package/tests/postProductsToFacebookCatalog.test.js +7 -0
  36. package/tests/postProductsToPromotion.test.js +7 -0
  37. package/tests/postPromotionsElements.test.js +7 -0
  38. package/tests/postPromotionsEnd.test.js +7 -0
  39. package/tests/postPromotionsStart.test.js +7 -0
  40. package/tests/putPromotions.test.js +7 -0
  41. package/tests/putPromotionsSettings.test.js +7 -0
  42. package/tests/searchPromotionsArchive.test.js +12 -0
  43. package/tests/searchPromotionsElements.test.js +12 -0
  44. package/tests/searchPromotionsHistory.test.js +7 -0
  45. package/tests/searchPromotionsListView.test.js +7 -0
  46. package/tests/deleteProductsProductsToFacebookCatalog.test.js +0 -7
  47. package/tests/deleteProductsProductsToPromotion.test.js +0 -7
  48. /package/dist/methods/{deleteProductsProductsToFacebookCatalog.js → deleteProductsToFacebookCatalog.js} +0 -0
  49. /package/dist/methods/{deleteProductsProductsToPromotion.js → deleteProductsToPromotion.js} +0 -0
  50. /package/dist/methods/{getProductsProductsToFacebookCatalog.js → getProductsToFacebookCatalog.js} +0 -0
  51. /package/dist/methods/{postProductsProductsToFacebookCatalog.js → postProductsToFacebookCatalog.js} +0 -0
  52. /package/dist/methods/{postProductsProductsToPromotion.js → postProductsToPromotion.js} +0 -0
  53. /package/dist/methods/{postSubscriptionsItemsList.js → searchSubscriptionsItems.js} +0 -0
  54. /package/dist/methods/{postSubscriptionsListViewList.js → searchSubscriptionsListView.js} +0 -0
package/changelog.md CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.25] - 2025-04-04
9
+ - Updated to v7.19
10
+ - Added promotion routes
11
+ - Changed routes that have ProductsProducts to Products like getProductsToFacebookCatalog (before: getProductsProductsToFacebookCatalog)
12
+
8
13
  ## [0.4.24] - 2025-03-21
9
14
  ### Changed
10
15
  - Updated to v7.13
package/dist/app.d.ts CHANGED
@@ -40,11 +40,12 @@ export type GatewayRequestProxyObject = {
40
40
  },
41
41
  custom?: Record<string,(..._: any) => false|Record<string,any>>,
42
42
  snakeCase?: boolean,
43
+ paginationObject?: boolean,
43
44
  next?: boolean,
44
45
  rootparams?: string|boolean,
45
46
  arrays?: string[],
46
47
  req?: RequirementType[],
47
- n?: Record<string,number>,
48
+ n?: Record<string,number>
48
49
  } & RequestProxyObject;
49
50
 
50
51
  export interface Gateway<R = JSObject, P = JSObject> {
package/dist/gates.js CHANGED
@@ -198,11 +198,11 @@ import getProducts from "./methods/getProducts.js";
198
198
  import postProducts from "./methods/postProducts.js";
199
199
  import putProducts from "./methods/putProducts.js";
200
200
  import searchProducts from "./methods/searchProducts.js";
201
- import deleteProductsProductsToFacebookCatalog from "./methods/deleteProductsProductsToFacebookCatalog.js";
202
- import getProductsProductsToFacebookCatalog from "./methods/getProductsProductsToFacebookCatalog.js";
203
- import postProductsProductsToFacebookCatalog from "./methods/postProductsProductsToFacebookCatalog.js";
204
- import deleteProductsProductsToPromotion from "./methods/deleteProductsProductsToPromotion.js";
205
- import postProductsProductsToPromotion from "./methods/postProductsProductsToPromotion.js";
201
+ import deleteProductsToFacebookCatalog from "./methods/deleteProductsToFacebookCatalog.js";
202
+ import getProductsToFacebookCatalog from "./methods/getProductsToFacebookCatalog.js";
203
+ import postProductsToFacebookCatalog from "./methods/postProductsToFacebookCatalog.js";
204
+ import deleteProductsToPromotion from "./methods/deleteProductsToPromotion.js";
205
+ import postProductsToPromotion from "./methods/postProductsToPromotion.js";
206
206
  import getProductsQuestions from "./methods/getProductsQuestions.js";
207
207
  import putProductsQuestions from "./methods/putProductsQuestions.js";
208
208
  import getProductsReservations from "./methods/getProductsReservations.js";
@@ -224,6 +224,22 @@ import putProductsSupplierCode from "./methods/putProductsSupplierCode.js";
224
224
  import putProductsSupplierProductData from "./methods/putProductsSupplierProductData.js";
225
225
  import postProductsSynchronizationFile from "./methods/postProductsSynchronizationFile.js";
226
226
  import putProductsSynchronizationFinishUpload from "./methods/putProductsSynchronizationFinishUpload.js";
227
+ import postPromotionsElements from "./methods/postPromotionsElements.js";
228
+ import searchPromotionsElements from "./methods/searchPromotionsElements.js";
229
+ import deletePromotionsElements from "./methods/deletePromotionsElements.js";
230
+ import searchPromotionsHistory from "./methods/searchPromotionsHistory.js";
231
+ import postPromotions from "./methods/postPromotions.js";
232
+ import deletePromotions from "./methods/deletePromotions.js";
233
+ import putPromotions from "./methods/putPromotions.js";
234
+ import postPromotionsEnd from "./methods/postPromotionsEnd.js";
235
+ import getPromotions from "./methods/getPromotions.js";
236
+ import searchPromotionsListView from "./methods/searchPromotionsListView.js";
237
+ import postPromotionsStart from "./methods/postPromotionsStart.js";
238
+ import deletePromotionsArchive from "./methods/deletePromotionsArchive.js";
239
+ import getPromotionsArchive from "./methods/getPromotionsArchive.js";
240
+ import searchPromotionsArchive from "./methods/searchPromotionsArchive.js";
241
+ import getPromotionsSettings from "./methods/getPromotionsSettings.js";
242
+ import putPromotionsSettings from "./methods/putPromotionsSettings.js";
227
243
  import postRefundsAddAutomaticRefund from "./methods/postRefundsAddAutomaticRefund.js";
228
244
  import postRefundsAddAutomaticRefundForOrder from "./methods/postRefundsAddAutomaticRefundForOrder.js";
229
245
  import postRefundsAddManualRefund from "./methods/postRefundsAddManualRefund.js";
@@ -271,9 +287,9 @@ import postSubscriptionsChangeStatus from "./methods/postSubscriptionsChangeStat
271
287
  import postSubscriptionsDeleteProduct from "./methods/postSubscriptionsDeleteProduct.js";
272
288
  import postSubscriptionsEdit from "./methods/postSubscriptionsEdit.js";
273
289
  import postSubscriptionsEditProduct from "./methods/postSubscriptionsEditProduct.js";
274
- import postSubscriptionsItemsList from "./methods/postSubscriptionsItemsList.js";
290
+ import searchSubscriptionsItems from "./methods/searchSubscriptionsItems.js";
275
291
  import postSubscriptionsListViewFetchIds from "./methods/postSubscriptionsListViewFetchIds.js";
276
- import postSubscriptionsListViewList from "./methods/postSubscriptionsListViewList.js";
292
+ import searchSubscriptionsListView from "./methods/searchSubscriptionsListView.js";
277
293
  import postSubscriptionsSetRebateCode from "./methods/postSubscriptionsSetRebateCode.js";
278
294
  import postSubscriptionsUnsetRebateCode from "./methods/postSubscriptionsUnsetRebateCode.js";
279
295
  import getSystemConfig from "./methods/getSystemConfig.js";
@@ -518,11 +534,11 @@ const gates = {
518
534
  postProducts,
519
535
  putProducts,
520
536
  searchProducts,
521
- deleteProductsProductsToFacebookCatalog,
522
- getProductsProductsToFacebookCatalog,
523
- postProductsProductsToFacebookCatalog,
524
- deleteProductsProductsToPromotion,
525
- postProductsProductsToPromotion,
537
+ deleteProductsToFacebookCatalog,
538
+ getProductsToFacebookCatalog,
539
+ postProductsToFacebookCatalog,
540
+ deleteProductsToPromotion,
541
+ postProductsToPromotion,
526
542
  getProductsQuestions,
527
543
  putProductsQuestions,
528
544
  getProductsReservations,
@@ -544,6 +560,22 @@ const gates = {
544
560
  putProductsSupplierProductData,
545
561
  postProductsSynchronizationFile,
546
562
  putProductsSynchronizationFinishUpload,
563
+ postPromotionsElements,
564
+ searchPromotionsElements,
565
+ deletePromotionsElements,
566
+ searchPromotionsHistory,
567
+ postPromotions,
568
+ deletePromotions,
569
+ putPromotions,
570
+ postPromotionsEnd,
571
+ getPromotions,
572
+ searchPromotionsListView,
573
+ postPromotionsStart,
574
+ deletePromotionsArchive,
575
+ getPromotionsArchive,
576
+ searchPromotionsArchive,
577
+ getPromotionsSettings,
578
+ putPromotionsSettings,
547
579
  postRefundsAddAutomaticRefund,
548
580
  postRefundsAddAutomaticRefundForOrder,
549
581
  postRefundsAddManualRefund,
@@ -591,9 +623,9 @@ const gates = {
591
623
  postSubscriptionsDeleteProduct,
592
624
  postSubscriptionsEdit,
593
625
  postSubscriptionsEditProduct,
594
- postSubscriptionsItemsList,
626
+ searchSubscriptionsItems,
595
627
  postSubscriptionsListViewFetchIds,
596
- postSubscriptionsListViewList,
628
+ searchSubscriptionsListView,
597
629
  postSubscriptionsSetRebateCode,
598
630
  postSubscriptionsUnsetRebateCode,
599
631
  getSystemConfig,
@@ -648,7 +680,11 @@ const gates = {
648
680
  getPackages: searchPackages,
649
681
  getProductsCategoriesIdosell: searchProductsCategoriesIdosell,
650
682
  getProductsDeliveryTime: searchProductsDeliveryTime,
651
- getProductsParameters: searchProductsParameters,
683
+ getProductsProductsProductsToFacebookCatalog: getProductsToFacebookCatalog,
684
+ postProductsProductsToPromotion: postProductsToPromotion,
685
+ postProductsProductsToFacebookCatalog: postProductsToFacebookCatalog,
686
+ deleteProductsProductsToFacebookCatalog: deleteProductsToFacebookCatalog,
687
+ deleteProductsProductsToPromotion: deleteProductsToPromotion,
652
688
  };
653
689
  export const gateProxy = {
654
690
  get: (object, property) => {
@@ -1664,10 +1664,8 @@ export interface PostOrdersRequest extends AppendableGateway<PostOrdersRequest,
1664
1664
  billingCurrencyRate: (billingCurrencyRate: number) => this
1665
1665
  /** Sale date. ISO 8602 format. */
1666
1666
  purchaseDate: (purchaseDate: string) => this
1667
- /** Planned date of packing */
1668
- plannedDateOfPacking: (plannedDateOfPacking: string) => this
1669
- /** Planned date of shipment */
1670
- estimatedDeliveryDate: (estimatedDeliveryDate: string) => this
1667
+ /** Split payment MPP marking */
1668
+ splitPayment: (splitPayment: boolean) => this
1671
1669
  }
1672
1670
 
1673
1671
  export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, PutOrdersResponse, RequestParams.PutOrdersParams> {
@@ -1681,6 +1679,8 @@ export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, Pu
1681
1679
  orderStatus: (orderStatus: string) => this
1682
1680
  /** Order status id . */
1683
1681
  orderStatusId: (orderStatusId: number|string) => this
1682
+ /** Transaction type. */
1683
+ transactionType: (transactionType: 'national'|'oss'|'export'|'intra') => this
1684
1684
  /** Flag informing on order registration or completion in external program through API. Allowed values. "none" - order was not registered in external program, "registered" - order was registered in external program, "realized" - order was completed in external program, "registered_pos" - order was registered in external program, "realized_pos" - order was completed in external program. */
1685
1685
  apiFlag: (apiFlag: 'none'|'registered'|'realized'|'registered_pos'|'realized_pos'|'registration_fault') => this
1686
1686
  /** API note added to order. */
@@ -1713,6 +1713,8 @@ export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, Pu
1713
1713
  purchaseDate: (purchaseDate: string) => this
1714
1714
  /** Estimated date of shipment of the order in format Y-m-d H:i */
1715
1715
  estimatedDeliveryDate: (estimatedDeliveryDate: string) => this
1716
+ /** Split payment MPP marking */
1717
+ splitPayment: (splitPayment: boolean) => this
1716
1718
  /** Planned date of packing */
1717
1719
  plannedDateOfPacking: (plannedDateOfPacking: string) => this
1718
1720
  }
@@ -1724,6 +1726,8 @@ export interface SearchOrdersRequest extends PagableGateway<SearchOrdersRequest,
1724
1726
  ordersStatuses: (value: string|string[]) => this;
1725
1727
  /** Order statusses ids. */
1726
1728
  ordersStatusesIds: (value: number|string|number[]|string[]) => this;
1729
+ /** Transaction type. */
1730
+ transactionType: (value: 'national'|'oss'|'export'|'intra') => this;
1727
1731
  shippmentStatus: (value: 'all'|'received'|'non-received') => this;
1728
1732
  /** Shipping companies (packages deliverers). */
1729
1733
  couriersName: (value: string|string[]) => this;
@@ -3272,7 +3276,7 @@ export interface SearchProductsRequest extends PagableGateway<SearchProductsRequ
3272
3276
  dispatchSettings: (value: RequestParams.SearchProductsParams["dispatchSettings"]) => this;
3273
3277
  /** Element determines which products should be returned by the gate. Undeleted products are returned by default. Available values: "active" - undeleted products, "deleted" - deleted products. "in_trash" - products in the trash. */
3274
3278
  returnProducts: (value: "active" | "deleted" | "in_trash") => this;
3275
- /** Elements to be returned by the endpoint. By default all elements are returned Available values: * lang_data * adding_time, * deleted, * code, * note, * taxcode, * inwrapper, * sellby_retail, * sellby_wholesale, * producer_id, * producer_name, * iaiCategoryId, * iaiCategoryName, * iaiCategoryPath, * category_id, * category_name, * size_group_id, * modification_time, * currency, * currency_shop, * bestseller, * new_product, * retail_price, * wholesale_price, * minimal_price, * automatic_calculation_price, * pos_price, * strikethrough_retail_price, * strikethrough_wholesale_price, * last_purchase_price, * purchase_price_net_average, * purchase_price_net_last, * purchase_price_gross_average, * purchase_price_gross_last, * vat, * vat_free, * rebate, * hotspots_zones, * profit_points, * points, * weight, * export_to_pricecomparers, * export_to_amazon_marketplace, * enable_in_pos, * complex_notes, * available_profile, * traits, * parameters, * version_data, * advance, * promotion, * discount, * distinguished, * special, * visible, * persistent, * priority, * shops_mask, * icon, * icon_for_auctions, * icon_for_group, * pictures, * unit, * warranty, * series, * products_associated, * shops, * quantities, * sizes_attributes, * shops_attributes, * auction_prices, * price_comparers_prices, * deliverer, * sizes, * size_group_name, * pictures_count, * product_type, * price_changed_time, * quantity_changed_time, * deliverer_name, * available_profile_name, * availability_management_type, * sum_in_basket, * menu, * auction_settings, * bundle, * sizeschart_id, * sizeschart_name, * serialnumbers, * producer_codes_standard, * javaScriptInTheItemCard, * productAuctionDescriptionsData, * priceFormula, * productIndividualDescriptionsData, * productIndividualUrlsData, * productServicesDescriptionsData, * cnTaricCode, * productIsGratis, * dimensions, * responsibleProducerCode, * responsiblePersonCode */
3279
+ /** Elements to be returned by the endpoint. By default all elements are returned Available values: * lang_data * adding_time, * deleted, * code, * note, * taxcode, * inwrapper, * sellby_retail, * sellby_wholesale, * producer_id, * producer_name, * iaiCategoryId, * iaiCategoryName, * iaiCategoryPath, * category_id, * category_name, * size_group_id, * modification_time, * currency, * currency_shop, * bestseller, * new_product, * retail_price, * wholesale_price, * minimal_price, * automatic_calculation_price, * pos_price, * strikethrough_retail_price, * strikethrough_wholesale_price, * last_purchase_price, * purchase_price_net_average, * purchase_price_net_last, * purchase_price_gross_average, * purchase_price_gross_last, * vat, * vat_free, * rebate, * hotspots_zones, * profit_points, * points, * weight, * export_to_pricecomparers, * export_to_amazon_marketplace, * enable_in_pos, * complex_notes, * available_profile, * traits, * parameters, * version_data, * advance, * promotion, * discount, * distinguished, * special, * visible, * persistent, * priority, * shops_mask, * icon, * icon_for_auctions, * icon_for_group, * pictures, * unit, * warranty, * series, * products_associated, * shops, * quantities, * sizes_attributes, * shops_attributes, * auction_prices, * price_comparers_prices, * deliverer, * sizes, * size_group_name, * pictures_count, * product_type, * price_changed_time, * quantity_changed_time, * deliverer_name, * available_profile_name, * availability_management_type, * sum_in_basket, * menu, * auction_settings, * bundle, * sizeschart_id, * sizeschart_name, * serialnumbers, * producer_codes_standard, * javaScriptInTheItemCard, * productAuctionDescriptionsData, * priceFormula, * productIndividualDescriptionsData, * productIndividualUrlsData, * productServicesDescriptionsData, * cnTaricCode, * productIsGratis, * dimensions, * responsibleProducerCode, * responsiblePersonCode, * dimensions, * depositProductId, * depositType, * depositCount, * minStockLevel, * productAttachments */
3276
3280
  returnElements: (value: string|string[]) => this;
3277
3281
  /** Product availability. Available values: "y" - available, "n" - unavailable. */
3278
3282
  productIsAvailable: (value: "y" | "n") => this;
@@ -3416,7 +3420,7 @@ export interface SearchProductsRequest extends PagableGateway<SearchProductsRequ
3416
3420
  inStock: (stockIds?: boolean|number|string|number[]|string[]) => this;
3417
3421
  }
3418
3422
 
3419
- export interface DeleteProductsProductsToFacebookCatalogRequest extends Gateway {
3423
+ export interface DeleteProductsToFacebookCatalogRequest extends Gateway {
3420
3424
  /** You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
3421
3425
  facebookCatalogId: (value: number|string) => this;
3422
3426
  /** Shop Id */
@@ -3425,14 +3429,14 @@ export interface DeleteProductsProductsToFacebookCatalogRequest extends Gateway
3425
3429
  products: (value: number|string|number[]|string[]) => this;
3426
3430
  }
3427
3431
 
3428
- export interface GetProductsProductsToFacebookCatalogRequest extends Gateway {
3432
+ export interface GetProductsToFacebookCatalogRequest extends Gateway {
3429
3433
  /** You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
3430
3434
  facebookCatalogId: (value: number|string) => this;
3431
3435
  /** Shop Id */
3432
3436
  shopId: (value: number|string) => this;
3433
3437
  }
3434
3438
 
3435
- export interface PostProductsProductsToFacebookCatalogRequest extends Gateway {
3439
+ export interface PostProductsToFacebookCatalogRequest extends Gateway {
3436
3440
  /** You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
3437
3441
  facebookCatalogId: (value: number|string) => this;
3438
3442
  /** Shop Id */
@@ -3441,14 +3445,14 @@ export interface PostProductsProductsToFacebookCatalogRequest extends Gateway {
3441
3445
  products: (value: number|string|number[]|string[]) => this;
3442
3446
  }
3443
3447
 
3444
- export interface DeleteProductsProductsToPromotionRequest extends Gateway {
3448
+ export interface DeleteProductsToPromotionRequest extends Gateway {
3445
3449
  /** Special offer ID */
3446
3450
  promotionId: (value: number|string) => this;
3447
3451
  /** Products list. */
3448
3452
  products: (value: number|string|number[]|string[]) => this;
3449
3453
  }
3450
3454
 
3451
- export interface PostProductsProductsToPromotionRequest extends Gateway<PutProductsMarketingPromotionResponse, RequestParams.PostProductsProductsToPromotionParams> {
3455
+ export interface PostProductsToPromotionRequest extends Gateway<PutProductsMarketingPromotionResponse, RequestParams.PostProductsToPromotionParams> {
3452
3456
  /** Special offer ID */
3453
3457
  promotionId: (value: number|string) => this;
3454
3458
  /** Products list. */
@@ -3715,6 +3719,235 @@ export interface PutProductsSynchronizationFinishUploadRequest extends Gateway {
3715
3719
  verifyFiles: (value: boolean) => this;
3716
3720
  }
3717
3721
 
3722
+ export interface PostPromotionsElementsRequest extends AppendableGateway<PostPromotionsElementsRequest> {
3723
+ /** Array of PromotionElement objects */
3724
+ elements: (value: Array<JSObject>) => this;
3725
+ /** ID */
3726
+ id: (id: string) => this
3727
+ /** Promotion element type */
3728
+ type: (type: 'product'|'series'|'producer'|'category'|'menu') => this
3729
+ /** Promotion element name */
3730
+ name: (name: string) => this
3731
+ /** Promotion ID */
3732
+ promotionId: (promotionId: number|string) => this
3733
+ /** Correlated elements id eg. product versions id */
3734
+ correlatedElementsId: (correlatedElementsId: number|string|number[]|string[]) => this
3735
+ }
3736
+
3737
+ export interface SearchPromotionsElementsRequest extends PagableGateway<SearchPromotionsElementsRequest> {
3738
+ filter: (value: JSObject) => this;
3739
+ /** Pagination settings. */
3740
+ pagination: (value: JSObject) => this;
3741
+ /** Order by settings. */
3742
+ orderBy: (value: JSObject) => this;
3743
+ /** Elements IDs */
3744
+ ids: (value: string|string[]) => this;
3745
+ /** Element types */
3746
+ types: (value: 'product'|'series'|'producer'|'category'|'menu'|Array<'product'|'series'|'producer'|'category'|'menu'>) => this;
3747
+ /** Promotion IDs */
3748
+ promotionIds: (value: number|string|number[]|string[]) => this;
3749
+ /** Define ordering of records */
3750
+ orderByProperty: (elementName: "promotion_id"|"type"|"element_id", descending?: boolean) => this;
3751
+ }
3752
+
3753
+ export interface DeletePromotionsElementsRequest extends AppendableGateway<DeletePromotionsElementsRequest> {
3754
+ /** Array of PromotionElement objects */
3755
+ elements: (value: Array<JSObject>) => this;
3756
+ /** ID */
3757
+ id: (id: string) => this
3758
+ /** Promotion element type */
3759
+ type: (type: 'product'|'series'|'producer'|'category'|'menu') => this
3760
+ /** Promotion element name */
3761
+ name: (name: string) => this
3762
+ /** Promotion ID */
3763
+ promotionId: (promotionId: number|string) => this
3764
+ /** Correlated elements id eg. product versions id */
3765
+ correlatedElementsId: (correlatedElementsId: number|string|number[]|string[]) => this
3766
+ }
3767
+
3768
+ export interface SearchPromotionsHistoryRequest extends PagableGateway<SearchPromotionsHistoryRequest> {
3769
+ /** Filters that limit the result of a customer query. */
3770
+ filter: (value: JSObject) => this;
3771
+ /** Pagination settings. */
3772
+ pagination: (value: JSObject) => this;
3773
+ /** Promotion ID */
3774
+ promotionId: (value: number|string) => this;
3775
+ }
3776
+
3777
+ export interface PostPromotionsRequest extends Gateway {
3778
+ /** Promotion name */
3779
+ name: (value: string) => this;
3780
+ /** Array of shop ids */
3781
+ activeInShops: (value: number|string|number[]|string[]) => this;
3782
+ /** Promotion zones */
3783
+ types: (value: string|string[]) => this;
3784
+ /** Promotion start datetime */
3785
+ startTime: (value: string) => this;
3786
+ /** Promotion end datetime */
3787
+ endTime: (value: string) => this;
3788
+ /** Change visibility */
3789
+ changeVisibility: (value: boolean) => this;
3790
+ /** Auto unpin */
3791
+ autoUnpin: (value: boolean) => this;
3792
+ /** Auto unpin own stocks */
3793
+ autoUnpinOwnStocks: (value: boolean) => this;
3794
+ /** Price type */
3795
+ priceType: (value: 'retail'|'wholesale'|'pos') => this;
3796
+ /** A representation of a floating-point number with precise accuracy. */
3797
+ newPriceValue: (value: JSObject) => this;
3798
+ /** Currency */
3799
+ currency: (value: string) => this;
3800
+ /** Discount type */
3801
+ newPriceDiscountType: (value: 'percent'|'minus'|'set') => this;
3802
+ /** New price round */
3803
+ newPriceRound: (value: 'whole'|'first'|'second') => this;
3804
+ /** New price end */
3805
+ newPriceEnd: (value: number|string) => this;
3806
+ /** Net or gross */
3807
+ netGross: (value: 'gross'|'net') => this;
3808
+ /** Charge type */
3809
+ chargeType: (value: 'lowest'|'sum') => this;
3810
+ /** Enable in marketplaces */
3811
+ enableInMarketplaces: (value: 'y'|'n'|'yes_for_dynamic_pricing_products') => this;
3812
+ /** Status */
3813
+ status: (value: 'waiting'|'active'|'closed') => this;
3814
+ }
3815
+
3816
+ export interface DeletePromotionsRequest extends Gateway {
3817
+ promotionId: (value: number|string) => this;
3818
+ }
3819
+
3820
+ export interface PutPromotionsRequest extends Gateway {
3821
+ /** Promotion name */
3822
+ name: (value: string) => this;
3823
+ /** Array of shop ids */
3824
+ activeInShops: (value: number|string|number[]|string[]) => this;
3825
+ /** Promotion zones */
3826
+ types: (value: string|string[]) => this;
3827
+ /** Promotion start datetime */
3828
+ startTime: (value: string) => this;
3829
+ /** Promotion end datetime */
3830
+ endTime: (value: string) => this;
3831
+ /** Change visibility */
3832
+ changeVisibility: (value: boolean) => this;
3833
+ /** Auto unpin */
3834
+ autoUnpin: (value: boolean) => this;
3835
+ /** Auto unpin own stocks */
3836
+ autoUnpinOwnStocks: (value: boolean) => this;
3837
+ /** Price type */
3838
+ priceType: (value: 'retail'|'wholesale'|'pos') => this;
3839
+ /** A representation of a floating-point number with precise accuracy. */
3840
+ newPriceValue: (value: JSObject) => this;
3841
+ /** Currency */
3842
+ currency: (value: string) => this;
3843
+ /** Discount type */
3844
+ newPriceDiscountType: (value: 'percent'|'minus'|'set') => this;
3845
+ /** New price round */
3846
+ newPriceRound: (value: 'whole'|'first'|'second') => this;
3847
+ /** New price end */
3848
+ newPriceEnd: (value: number|string) => this;
3849
+ /** Net or gross */
3850
+ netGross: (value: 'gross'|'net') => this;
3851
+ /** Charge type */
3852
+ chargeType: (value: 'lowest'|'sum') => this;
3853
+ /** Enable in marketplaces */
3854
+ enableInMarketplaces: (value: 'y'|'n'|'yes_for_dynamic_pricing_products') => this;
3855
+ /** Status */
3856
+ status: (value: 'waiting'|'active'|'closed') => this;
3857
+ /** Promotion ID */
3858
+ promotionId: (promotionId: number) => this;
3859
+ }
3860
+
3861
+ export interface PostPromotionsEndRequest extends Gateway {
3862
+ /** ID of promotion */
3863
+ promotionId: (value: number|string) => this;
3864
+ }
3865
+
3866
+ export interface GetPromotionsRequest extends Gateway {
3867
+ promotionId: (value: number|string) => this;
3868
+ }
3869
+
3870
+ export interface SearchPromotionsListViewRequest extends PagableGateway<SearchPromotionsListViewRequest> {
3871
+ /** Filters that limit the result of a customer query. */
3872
+ filter: (value: JSObject) => this;
3873
+ /** Pagination settings. */
3874
+ pagination: (value: JSObject) => this;
3875
+ /** Order by settings. */
3876
+ orderBy: (value: JSObject) => this;
3877
+ /** Promotion ID */
3878
+ ids: (value: number|string|number[]|string[]) => this;
3879
+ /** Promotion name */
3880
+ name: (value: string) => this;
3881
+ /** Change visibility */
3882
+ changeVisibility: (value: boolean) => this;
3883
+ /** Array of shop ids */
3884
+ activeInShops: (value: number|string|number[]|string[]) => this;
3885
+ /** Promotion zones */
3886
+ types: (value: 'promotion'|'special'|'discount'|'distinguished'|'bestseller'|'new'|Array<'promotion'|'special'|'discount'|'distinguished'|'bestseller'|'new'>) => this;
3887
+ /** Price types */
3888
+ priceTypes: (value: 'retail'|'wholesale'|'pos'|Array<'retail'|'wholesale'|'pos'>) => this;
3889
+ /** Promotion statuses */
3890
+ statuses: (value: 'waiting'|'active'|'closed'|Array<'waiting'|'active'|'closed'>) => this;
3891
+ /** Date range */
3892
+ dateRange: (value: JSObject) => this;
3893
+ /** Array of products in promotion */
3894
+ productsNotInPromotion: (value: number|string|number[]|string[]) => this;
3895
+ /** Define ordering of records */
3896
+ orderByProperty: (elementName: "id"|"name"|"start_time"|"end_time"|"new_price_value"|"new_price_end"|"elements_modification_date", descending?: boolean) => this;
3897
+ }
3898
+
3899
+ export interface PostPromotionsStartRequest extends Gateway {
3900
+ /** ID of promotion */
3901
+ promotionId: (value: number|string) => this;
3902
+ }
3903
+
3904
+ export interface DeletePromotionsArchiveRequest extends Gateway {
3905
+ promotionId: (value: number|string) => this;
3906
+ }
3907
+
3908
+ export interface GetPromotionsArchiveRequest extends Gateway {
3909
+ promotionId: (value: number|string) => this;
3910
+ }
3911
+
3912
+ export interface SearchPromotionsArchiveRequest extends PagableGateway<SearchPromotionsArchiveRequest> {
3913
+ /** Filters that limit the result of a customer query. */
3914
+ filter: (value: JSObject) => this;
3915
+ /** Pagination settings. */
3916
+ pagination: (value: JSObject) => this;
3917
+ /** Order by settings. */
3918
+ orderBy: (value: JSObject) => this;
3919
+ /** Shops IDs */
3920
+ shops: (value: number|string|number[]|string[]) => this;
3921
+ archivedDate: (value: JSObject) => this;
3922
+ /** Define ordering of records */
3923
+ orderByProperty: (elementName: "id"|"shop_mask"|"archived_date", descending?: boolean) => this;
3924
+ }
3925
+
3926
+ export interface GetPromotionsSettingsRequest extends Gateway {}
3927
+
3928
+ export interface PutPromotionsSettingsRequest extends Gateway {
3929
+ /** Days to archive */
3930
+ daysLeftToArchive: (value: number|string) => this;
3931
+ /** Days to remove from archive */
3932
+ daysLeftToRemove: (value: number|string) => this;
3933
+ /** Show promo price on products list */
3934
+ showPriceOnProductsList: (value: number|string) => this;
3935
+ /** Automatically suggest default start date */
3936
+ automaticallySuggestDefaultStartDate: (value: 'on'|'off') => this;
3937
+ /** Automatically suggest default end date */
3938
+ automaticallySuggestDefaultEndDate: (value: 'on'|'off') => this;
3939
+ /** Default start date */
3940
+ defaultStartDate: (value: number|string) => this;
3941
+ /** Default end date */
3942
+ defaultEndDate: (value: number|string) => this;
3943
+ /** Default start time */
3944
+ defaultStartTime: (value: number|string) => this;
3945
+ /** Default end time */
3946
+ defaultEndTime: (value: number|string) => this;
3947
+ /** Days to automatically close empty promotions */
3948
+ daysLeftToClose: (value: number|string) => this;
3949
+ }
3950
+
3718
3951
  export interface PostRefundsAddAutomaticRefundRequest extends Gateway {
3719
3952
  /** Source type.: "return" "rma". */
3720
3953
  sourceType: (value: 'return'|'rma') => this;
@@ -4324,7 +4557,7 @@ export interface PostSubscriptionsEditProductRequest extends Gateway {
4324
4557
  products: (value: Array<JSObject>) => this;
4325
4558
  }
4326
4559
 
4327
- export interface PostSubscriptionsItemsListRequest extends Gateway {
4560
+ export interface SearchSubscriptionsItemsRequest extends Gateway {
4328
4561
  filter: (value: JSObject) => this;
4329
4562
  orderBy: (value: JSObject) => this;
4330
4563
  /** Pagination settings. */
@@ -4354,7 +4587,7 @@ export interface PostSubscriptionsListViewFetchIdsRequest extends Gateway {
4354
4587
  textSearch: (value: string) => this;
4355
4588
  }
4356
4589
 
4357
- export interface PostSubscriptionsListViewListRequest extends Gateway {
4590
+ export interface SearchSubscriptionsListViewRequest extends Gateway {
4358
4591
  select: (value: JSObject) => this;
4359
4592
  /** Filters that limit the result of a customer query. */
4360
4593
  filter: (value: JSObject) => this;
@@ -5073,11 +5306,11 @@ export interface Gateways {
5073
5306
  postProducts: PostProductsRequest,
5074
5307
  putProducts: PutProductsRequest,
5075
5308
  searchProducts: SearchProductsRequest,
5076
- deleteProductsProductsToFacebookCatalog: DeleteProductsProductsToFacebookCatalogRequest,
5077
- getProductsProductsToFacebookCatalog: GetProductsProductsToFacebookCatalogRequest,
5078
- postProductsProductsToFacebookCatalog: PostProductsProductsToFacebookCatalogRequest,
5079
- deleteProductsProductsToPromotion: DeleteProductsProductsToPromotionRequest,
5080
- postProductsProductsToPromotion: PostProductsProductsToPromotionRequest,
5309
+ deleteProductsToFacebookCatalog: DeleteProductsToFacebookCatalogRequest,
5310
+ getProductsToFacebookCatalog: GetProductsToFacebookCatalogRequest,
5311
+ postProductsToFacebookCatalog: PostProductsToFacebookCatalogRequest,
5312
+ deleteProductsToPromotion: DeleteProductsToPromotionRequest,
5313
+ postProductsToPromotion: PostProductsToPromotionRequest,
5081
5314
  getProductsQuestions: GetProductsQuestionsRequest,
5082
5315
  putProductsQuestions: PutProductsQuestionsRequest,
5083
5316
  getProductsReservations: GetProductsReservationsRequest,
@@ -5099,6 +5332,22 @@ export interface Gateways {
5099
5332
  putProductsSupplierProductData: PutProductsSupplierProductDataRequest,
5100
5333
  postProductsSynchronizationFile: PostProductsSynchronizationFileRequest,
5101
5334
  putProductsSynchronizationFinishUpload: PutProductsSynchronizationFinishUploadRequest,
5335
+ postPromotionsElements: PostPromotionsElementsRequest,
5336
+ searchPromotionsElements: SearchPromotionsElementsRequest,
5337
+ deletePromotionsElements: DeletePromotionsElementsRequest,
5338
+ searchPromotionsHistory: SearchPromotionsHistoryRequest,
5339
+ postPromotions: PostPromotionsRequest,
5340
+ deletePromotions: DeletePromotionsRequest,
5341
+ putPromotions: PutPromotionsRequest,
5342
+ postPromotionsEnd: PostPromotionsEndRequest,
5343
+ getPromotions: GetPromotionsRequest,
5344
+ searchPromotionsListView: SearchPromotionsListViewRequest,
5345
+ postPromotionsStart: PostPromotionsStartRequest,
5346
+ deletePromotionsArchive: DeletePromotionsArchiveRequest,
5347
+ getPromotionsArchive: GetPromotionsArchiveRequest,
5348
+ searchPromotionsArchive: SearchPromotionsArchiveRequest,
5349
+ getPromotionsSettings: GetPromotionsSettingsRequest,
5350
+ putPromotionsSettings: PutPromotionsSettingsRequest,
5102
5351
  postRefundsAddAutomaticRefund: PostRefundsAddAutomaticRefundRequest,
5103
5352
  postRefundsAddAutomaticRefundForOrder: PostRefundsAddAutomaticRefundForOrderRequest,
5104
5353
  postRefundsAddManualRefund: PostRefundsAddManualRefundRequest,
@@ -5146,9 +5395,9 @@ export interface Gateways {
5146
5395
  postSubscriptionsDeleteProduct: PostSubscriptionsDeleteProductRequest,
5147
5396
  postSubscriptionsEdit: PostSubscriptionsEditRequest,
5148
5397
  postSubscriptionsEditProduct: PostSubscriptionsEditProductRequest,
5149
- postSubscriptionsItemsList: PostSubscriptionsItemsListRequest,
5398
+ searchSubscriptionsItems: SearchSubscriptionsItemsRequest,
5150
5399
  postSubscriptionsListViewFetchIds: PostSubscriptionsListViewFetchIdsRequest,
5151
- postSubscriptionsListViewList: PostSubscriptionsListViewListRequest,
5400
+ searchSubscriptionsListView: SearchSubscriptionsListViewRequest,
5152
5401
  postSubscriptionsSetRebateCode: PostSubscriptionsSetRebateCodeRequest,
5153
5402
  postSubscriptionsUnsetRebateCode: PostSubscriptionsUnsetRebateCodeRequest,
5154
5403
  getSystemConfig: GetSystemConfigRequest,
@@ -5215,7 +5464,15 @@ export interface Gateways {
5215
5464
  /** @deprecated */
5216
5465
  getProductsDeliveryTime: SearchProductsDeliveryTimeRequest
5217
5466
  /** @deprecated */
5218
- getProductsParameters: SearchProductsParametersRequest
5467
+ getProductsProductsProductsToFacebookCatalog: GetProductsToFacebookCatalogRequest
5468
+ /** @deprecated */
5469
+ postProductsProductsToPromotion: PostProductsToPromotionRequest
5470
+ /** @deprecated */
5471
+ postProductsProductsToFacebookCatalog: PostProductsToFacebookCatalogRequest
5472
+ /** @deprecated */
5473
+ deleteProductsProductsToFacebookCatalog: DeleteProductsToFacebookCatalogRequest
5474
+ /** @deprecated */
5475
+ deleteProductsProductsToPromotion: DeleteProductsToPromotionRequest
5219
5476
  }
5220
5477
 
5221
5478
  declare const defaultExport: (url: string, apiKey: string, version?: number | string) => Gateways;
package/dist/helpers.js CHANGED
@@ -53,6 +53,16 @@ export const page = (page = 0, limit, snakeCase = false) => {
53
53
  resultsLimit: limit
54
54
  };
55
55
  };
56
+ export const paginationObject = (page = 0, limit) => {
57
+ if (!limit)
58
+ limit = 100;
59
+ return {
60
+ pagination: {
61
+ page,
62
+ perPage: limit
63
+ }
64
+ };
65
+ };
56
66
  export const orderBy = (elementName, descending = true) => {
57
67
  return {
58
68
  ordersBy: [{
@@ -61,6 +71,14 @@ export const orderBy = (elementName, descending = true) => {
61
71
  }]
62
72
  };
63
73
  };
74
+ export const orderByProperty = (property, descending = true) => {
75
+ return {
76
+ orderBy: {
77
+ property,
78
+ orderByDirection: descending ? 'desc' : 'asc'
79
+ }
80
+ };
81
+ };
64
82
  export const date = ({ nodeName, format }) => (dateValue) => {
65
83
  const param = {};
66
84
  ;
package/dist/index.js CHANGED
@@ -3,7 +3,9 @@ import utils from "./utils.js";
3
3
  import { gateProxy } from "./gates.js";
4
4
  import { IdosellFaultStringError, catchEmptyList } from "./errors.js";
5
5
  export const DEFAULT_VERSION = 7;
6
- function normalizeUrl(input) {
6
+ function normalizeUrl(input = "") {
7
+ if (!input.length)
8
+ return "";
7
9
  const trimmed = input.trim();
8
10
  const withProtocol = trimmed
9
11
  .replace(/^https?:\/\//i, "") // strip existing protocol
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'delete', node: '/promotions/promotions/delete' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'delete', node: '/promotions/promotionsArchive/delete' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,13 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/elements/remove' };
4
+ object.rootparams = "request";
5
+ object.appendable = {
6
+ except: [],
7
+ arrayNode: "elements",
8
+ index: 0
9
+ };
10
+ object.req = ["promotionId", "type", "id"];
11
+ object.arrays = ["elements"];
12
+ return new Proxy(object, paramsProxy);
13
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/promotions/promotions/get' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/promotions/promotionsArchive/get' };
4
+ object.req = ["promotionId"];
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,5 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'get', node: '/promotions/settings/get' };
4
+ return new Proxy(object, paramsProxy);
5
+ };
@@ -0,0 +1,7 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/promotions/add' };
4
+ object.rootparams = "request";
5
+ object.arrays = ["activeInShops", "types"];
6
+ return new Proxy(object, paramsProxy);
7
+ };
@@ -0,0 +1,13 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/elements/add' };
4
+ object.rootparams = "request";
5
+ object.appendable = {
6
+ except: [],
7
+ arrayNode: "elements",
8
+ index: 0
9
+ };
10
+ object.req = ["promotionId", "id", "type"];
11
+ object.arrays = ["elements"];
12
+ return new Proxy(object, paramsProxy);
13
+ };
@@ -0,0 +1,7 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/promotions/end' };
4
+ object.rootparams = true;
5
+ object.req = ["promotionId"];
6
+ return new Proxy(object, paramsProxy);
7
+ };
@@ -0,0 +1,7 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'post', node: '/promotions/promotions/start' };
4
+ object.rootparams = true;
5
+ object.req = ["promotionId"];
6
+ return new Proxy(object, paramsProxy);
7
+ };
@@ -0,0 +1,8 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'put', node: '/promotions/promotions/edit' };
4
+ object.rootparams = "request";
5
+ object.req = ["promotionId"];
6
+ object.arrays = ["activeInShops", "types"];
7
+ return new Proxy(object, paramsProxy);
8
+ };
@@ -0,0 +1,6 @@
1
+ import { paramsProxy } from "../params.js";
2
+ export default (object) => {
3
+ object.gate = { method: 'put', node: '/promotions/settings/set' };
4
+ object.rootparams = "request";
5
+ return new Proxy(object, paramsProxy);
6
+ };
@@ -0,0 +1,14 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { orderByProperty, paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/promotionsArchive/list' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ orderByProperty,
8
+ page: paginationObject,
9
+ shops: nest("shops", "filter", {}, true),
10
+ archivedDate: nest("archivedDate", "filter", {}, false)
11
+ };
12
+ object.paginationObject = true;
13
+ return new Proxy(object, paramsProxy);
14
+ };
@@ -0,0 +1,15 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { orderByProperty, paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/elements/list' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ orderByProperty,
8
+ page: paginationObject,
9
+ ids: nest("ids", "filter", {}, true),
10
+ types: nest("types", "filter", {}, true),
11
+ promotionIds: nest("promotionIds", "filter", {}, true)
12
+ };
13
+ object.paginationObject = true;
14
+ return new Proxy(object, paramsProxy);
15
+ };
@@ -0,0 +1,13 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/history/get' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ page: paginationObject,
8
+ promotionId: nest("promotionId", "filter", {}, false)
9
+ };
10
+ object.paginationObject = true;
11
+ object.req = ["filter"];
12
+ return new Proxy(object, paramsProxy);
13
+ };
@@ -0,0 +1,21 @@
1
+ import { paramsProxy } from "../params.js";
2
+ import { orderByProperty, paginationObject, nest } from "../helpers.js";
3
+ export default (object) => {
4
+ object.gate = { method: 'post', node: '/promotions/promotions/listView/list' };
5
+ object.rootparams = "request";
6
+ object.custom = {
7
+ orderByProperty,
8
+ page: paginationObject,
9
+ ids: nest("ids", "filter", {}, true),
10
+ name: nest("name", "filter", {}, false),
11
+ changeVisibility: nest("changeVisibility", "filter", {}, false),
12
+ activeInShops: nest("activeInShops", "filter", {}, true),
13
+ types: nest("types", "filter", {}, true),
14
+ priceTypes: nest("priceTypes", "filter", {}, true),
15
+ statuses: nest("statuses", "filter", {}, true),
16
+ dateRange: nest("dateRange", "filter", {}, false),
17
+ productsNotInPromotion: nest("productsNotInPromotion", "filter", {}, true)
18
+ };
19
+ object.paginationObject = true;
20
+ return new Proxy(object, paramsProxy);
21
+ };
package/dist/params.js CHANGED
@@ -13,6 +13,19 @@ const requests = {
13
13
  return receiver;
14
14
  }
15
15
  };
16
+ function deepAssignSecondLevel(target, source) {
17
+ for (const key of Object.keys(source)) {
18
+ if (key in target &&
19
+ typeof target[key] === 'object' && target[key] !== null &&
20
+ typeof source[key] === 'object' && source[key] !== null) {
21
+ Object.assign(target[key], source[key]);
22
+ }
23
+ else {
24
+ target[key] = source[key];
25
+ }
26
+ }
27
+ return target;
28
+ }
16
29
  export const paramsProxy = {
17
30
  get: (object, property, receiver) => {
18
31
  if (property === 'then') {
@@ -48,7 +61,8 @@ export const paramsProxy = {
48
61
  values = [values[0] ?? 0, values[1] ?? 100, Boolean(object.snakeCase)];
49
62
  }
50
63
  const param = object.custom[property](...values);
51
- Object.assign(object.params, param);
64
+ if (param)
65
+ deepAssignSecondLevel(object.params, param);
52
66
  }
53
67
  else if (object.arrays && object.arrays.includes(property)) {
54
68
  if (Array.isArray(values[0]))
@@ -6312,7 +6312,7 @@ export type PostPackagesParams = {
6312
6312
  }[];
6313
6313
  };
6314
6314
 
6315
- export type PostProductsProductsToFacebookCatalogParams = {
6315
+ export type PostProductsToFacebookCatalogParams = {
6316
6316
  /** @description You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
6317
6317
  facebookCatalogId?: number;
6318
6318
  /** @description Shop Id */
@@ -6321,7 +6321,7 @@ export type PostProductsProductsToFacebookCatalogParams = {
6321
6321
  products?: number[];
6322
6322
  };
6323
6323
 
6324
- export type PostProductsProductsToPromotionParams = {
6324
+ export type PostProductsToPromotionParams = {
6325
6325
  /** @description Special offer ID */
6326
6326
  promotionId?: number;
6327
6327
  /** @description Products list. */
package/dist/request.js CHANGED
@@ -16,9 +16,20 @@ const catchIdosellError = (err) => {
16
16
  if (!err.response.headers['x-error'] && err.response.headers['content-type'].indexOf('json') < 0)
17
17
  throw new Error('500: Invalid response from Api gateway');
18
18
  let message = err.response.headers['x-error'];
19
- for (const [search, replace] of DECODE_TABLE) {
20
- message = message.replaceAll(search, replace);
19
+ if (err.response?.data?.errors) {
20
+ let errorObj = err.response?.data?.errors;
21
+ if (Array.isArray(errorObj))
22
+ errorObj = errorObj[0];
23
+ if (errorObj.message)
24
+ message = errorObj.message;
25
+ }
26
+ if (message) {
27
+ for (const [search, replace] of DECODE_TABLE) {
28
+ message = message.replaceAll(search, replace);
29
+ }
21
30
  }
31
+ else
32
+ message = 'Unknown error';
22
33
  if (err.response.status === 403) {
23
34
  const match = message.match(/Scope: ([a-z]+), level: ([rw]{1,2})/);
24
35
  if (match) {
@@ -41,17 +52,27 @@ const checkNext = (request, response, logPage) => {
41
52
  };
42
53
  throw new IdosellFaultStringError(response.errors.faultString, faultStructure);
43
54
  }
55
+ function handlePagination(currentPage, totalPages, request, paramsUpdate) {
56
+ request.next = currentPage + 1 < totalPages;
57
+ if (paramsUpdate)
58
+ Object.assign(request.params, paramsUpdate);
59
+ if (typeof logPage === 'function') {
60
+ logPage('Page: ' + currentPage + ' / ' + totalPages);
61
+ }
62
+ }
44
63
  if (response.resultsNumberPage) {
45
- request.next = response.resultsPage + 1 < response.resultsNumberPage;
46
- request.params.resultsPage = request.params.resultsPage ? request.params.resultsPage + 1 : 1;
47
- if (logPage)
48
- logPage('Page: ' + response.resultsPage + ' / ' + response.resultsNumberPage);
64
+ handlePagination(response.resultsPage, response.resultsNumberPage, request, { resultsPage: response.resultsPage + 1 });
49
65
  }
50
66
  else if (response.results_number_page) {
51
- request.next = response.results_page + 1 < response.results_number_page;
52
- request.params.results_page = request.params.results_page ? request.params.results_page + 1 : 1;
53
- if (logPage)
54
- logPage('Page: ' + response.results_page + ' / ' + response.results_page);
67
+ handlePagination(response.results_page, response.results_number_page, request, { results_page: response.results_page + 1 });
68
+ }
69
+ else if (response.pagination) {
70
+ request.params.pagination.page = response.pagination.resultsPage + 1;
71
+ handlePagination(response.pagination.resultsPage, response.pagination.resultsNumberPage, request);
72
+ }
73
+ else if (response.data?.pagination) {
74
+ request.params.pagination.page = response.data.pagination.resultsPage + 1;
75
+ handlePagination(response.data.pagination.resultsPage, response.data.pagination.resultsNumberPage, request);
55
76
  }
56
77
  return response;
57
78
  };
@@ -190,6 +211,8 @@ export const countResults = async (request, options) => {
190
211
  return 0;
191
212
  if (request.snakeCase)
192
213
  return parseInt(response.results_number_all);
214
+ else if (request.paginationObject)
215
+ return response.pagination.resultsNumberAll;
193
216
  else
194
217
  return response.resultsNumberAll;
195
218
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idosell",
3
- "version": "0.4.24",
3
+ "version": "0.4.25",
4
4
  "description": "Idosell 3 REST connector",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/gateways.d.ts",
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deleteProductsToFacebookCatalogFacebookCatalogId", () => {
5
+ const params = idosell().deleteProductsToFacebookCatalog.shopId(1).products([9]).facebookCatalogId(123).checkParams();
6
+ expect(params).toEqual({"shopId":1,"products":[9],"facebookCatalogId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deleteProductsToPromotionProducts", () => {
5
+ const params = idosell().deleteProductsToPromotion.promotionId(2).products([11]).checkParams();
6
+ expect(params).toEqual({"promotionId":2,"products":[11]});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deletePromotionsPromotionId", () => {
5
+ const params = idosell().deletePromotions.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deletePromotionsArchivePromotionId", () => {
5
+ const params = idosell().deletePromotionsArchive.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("deletePromotionsElementsId", () => {
5
+ const params = idosell().deletePromotionsElements.promotionId(4).type("product").id("288").checkParams();
6
+ expect(params).toEqual({"elements":[{"promotionId":4,"type":"product","id":"288"}]});
7
+ })
@@ -0,0 +1,8 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+
5
+ test("getProductsToFacebookCatalogFacebookCatalogId", () => {
6
+ const params = idosell().getProductsToFacebookCatalog.shopId(1).facebookCatalogId(123).checkParams();
7
+ expect(params).toEqual({"shopId":1,"facebookCatalogId":123});
8
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("getPromotionsPromotionId", () => {
5
+ const params = idosell().getPromotions.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("getPromotionsArchivePromotionId", () => {
5
+ const params = idosell().getPromotionsArchive.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("postProductsToFacebookCatalogProducts", () => {
5
+ const params = idosell().postProductsToFacebookCatalog.facebookCatalogId(1).shopId(1).products([9]).checkParams();
6
+ expect(params).toEqual({"facebookCatalogId":1,"shopId":1,"products":[9]});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("postProductsToPromotionProducts", () => {
5
+ const params = idosell().postProductsToPromotion.promotionId(2).products([11]).checkParams();
6
+ expect(params).toEqual({"promotionId":2,"products":[11]});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("postPromotionsElementsPromotionId", () => {
5
+ const params = idosell().postPromotionsElements.id("179").type("product").promotionId(4).checkParams();
6
+ expect(params).toEqual({"elements":[{"id":"179","type":"product","promotionId":4}]});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("postPromotionsEndPromotionId", () => {
5
+ const params = idosell().postPromotionsEnd.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("postPromotionsStartPromotionId", () => {
5
+ const params = idosell().postPromotionsStart.promotionId(123).checkParams();
6
+ expect(params).toEqual({"promotionId":123});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("putPromotionsName", () => {
5
+ const params = idosell().putPromotions.promotionId(4).name("Promotnion #4").checkParams();
6
+ expect(params).toEqual({"promotionId":4,"name":"Promotnion #4"});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("putPromotionsSettingsAutomaticallySuggestDefaultEndDate", () => {
5
+ const params = idosell().putPromotionsSettings.automaticallySuggestDefaultEndDate("on").checkParams();
6
+ expect(params).toEqual({"automaticallySuggestDefaultEndDate":"on"});
7
+ })
@@ -0,0 +1,12 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("searchPromotionsArchiveOrderByProperty", () => {
5
+ const params = idosell().searchPromotionsArchive.orderByProperty("id").checkParams();
6
+ expect(params).toEqual({"orderBy":{"property":"id","orderByDirection":"desc"}});
7
+ })
8
+
9
+ test("searchPromotionsArchiveShops", () => {
10
+ const params = idosell().searchPromotionsArchive.shops([1]).checkParams();
11
+ expect(params).toEqual({"filter":{"shops":[1]}});
12
+ })
@@ -0,0 +1,12 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("searchPromotionsElementsTypes", () => {
5
+ const params = idosell().searchPromotionsElements.ids(["288"]).types("product").checkParams();
6
+ expect(params).toEqual({"filter":{"ids":["288"],"types":["product"]}});
7
+ })
8
+
9
+ test("searchPromotionsElementsOrderByProperty", () => {
10
+ const params = idosell().searchPromotionsElements.orderByProperty("promotion_id").checkParams();
11
+ expect(params).toEqual({"orderBy":{"property":"promotion_id","orderByDirection":"desc"}});
12
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("searchPromotionsHistoryPage", () => {
5
+ const params = idosell().searchPromotionsHistory.promotionId(4).page(2,10).checkParams();
6
+ expect(params).toEqual({"filter":{"promotionId":4},"pagination":{"page":2,"perPage":10}});
7
+ })
@@ -0,0 +1,7 @@
1
+ import idosell from "./dist/index.ts"
2
+ import { expect, test } from "vitest"
3
+
4
+ test("searchPromotionsListViewOrderByProperty", () => {
5
+ const params = idosell().searchPromotionsListView.orderByProperty("id", false).checkParams();
6
+ expect(params).toEqual({"orderBy":{"property":"id","orderByDirection":"asc"}});
7
+ })
@@ -1,7 +0,0 @@
1
- import idosell from "./dist/index"
2
- import { expect, test } from "vitest"
3
-
4
- test("deleteProductsProductsToFacebookCatalogFacebookCatalogId", () => {
5
- const params = idosell().deleteProductsProductsToFacebookCatalog.shopId(1).products([9]).facebookCatalogId(123).checkParams();
6
- expect(params).toEqual({"shopId":1,"products":[9],"facebookCatalogId":123});
7
- })
@@ -1,7 +0,0 @@
1
- import idosell from "./dist/index"
2
- import { expect, test } from "vitest"
3
-
4
- test("deleteProductsProductsToPromotionProducts", () => {
5
- const params = idosell().deleteProductsProductsToPromotion.promotionId(2).products([11]).checkParams();
6
- expect(params).toEqual({"promotionId":2,"products":[11]});
7
- })