idosell 0.4.23 → 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.
- package/README.md +2 -0
- package/changelog.md +10 -0
- package/dist/app.d.ts +2 -1
- package/dist/gates.js +51 -15
- package/dist/gateways.d.ts +279 -16
- package/dist/helpers.js +18 -0
- package/dist/index.js +18 -1
- package/dist/methods/deletePromotions.js +6 -0
- package/dist/methods/deletePromotionsArchive.js +6 -0
- package/dist/methods/deletePromotionsElements.js +13 -0
- package/dist/methods/getPromotions.js +6 -0
- package/dist/methods/getPromotionsArchive.js +6 -0
- package/dist/methods/getPromotionsSettings.js +5 -0
- package/dist/methods/postPromotions.js +7 -0
- package/dist/methods/postPromotionsElements.js +13 -0
- package/dist/methods/postPromotionsEnd.js +7 -0
- package/dist/methods/postPromotionsStart.js +7 -0
- package/dist/methods/putPromotions.js +8 -0
- package/dist/methods/putPromotionsSettings.js +6 -0
- package/dist/methods/searchPromotionsArchive.js +14 -0
- package/dist/methods/searchPromotionsElements.js +15 -0
- package/dist/methods/searchPromotionsHistory.js +13 -0
- package/dist/methods/searchPromotionsListView.js +21 -0
- package/dist/params.js +15 -1
- package/dist/reqparams.d.ts +2 -2
- package/dist/request.js +33 -10
- package/dist/responses.d.ts +483 -0
- package/package.json +1 -1
- package/tests/deleteProductsToFacebookCatalog.test.js +7 -0
- package/tests/deleteProductsToPromotion.test.js +7 -0
- package/tests/deletePromotions.test.js +7 -0
- package/tests/deletePromotionsArchive.test.js +7 -0
- package/tests/deletePromotionsElements.test.js +7 -0
- package/tests/getProductsToFacebookCatalog.test.js +8 -0
- package/tests/getPromotions.test.js +7 -0
- package/tests/getPromotionsArchive.test.js +7 -0
- package/tests/postProductsToFacebookCatalog.test.js +7 -0
- package/tests/postProductsToPromotion.test.js +7 -0
- package/tests/postPromotionsElements.test.js +7 -0
- package/tests/postPromotionsEnd.test.js +7 -0
- package/tests/postPromotionsStart.test.js +7 -0
- package/tests/putPromotions.test.js +7 -0
- package/tests/putPromotionsSettings.test.js +7 -0
- package/tests/searchPromotionsArchive.test.js +12 -0
- package/tests/searchPromotionsElements.test.js +12 -0
- package/tests/searchPromotionsHistory.test.js +7 -0
- package/tests/searchPromotionsListView.test.js +7 -0
- package/tests/deleteProductsProductsToFacebookCatalog.test.js +0 -7
- package/tests/deleteProductsProductsToPromotion.test.js +0 -7
- /package/dist/methods/{deleteProductsProductsToFacebookCatalog.js → deleteProductsToFacebookCatalog.js} +0 -0
- /package/dist/methods/{deleteProductsProductsToPromotion.js → deleteProductsToPromotion.js} +0 -0
- /package/dist/methods/{getProductsProductsToFacebookCatalog.js → getProductsToFacebookCatalog.js} +0 -0
- /package/dist/methods/{postProductsProductsToFacebookCatalog.js → postProductsToFacebookCatalog.js} +0 -0
- /package/dist/methods/{postProductsProductsToPromotion.js → postProductsToPromotion.js} +0 -0
- /package/dist/methods/{postSubscriptionsItemsList.js → searchSubscriptionsItems.js} +0 -0
- /package/dist/methods/{postSubscriptionsListViewList.js → searchSubscriptionsListView.js} +0 -0
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ This package wraps around the Idosell REST Api to make it easier to use by imple
|
|
|
4
4
|
|
|
5
5
|
Visit [This page](https://idosell-converter.vercel.app/) for more detailed usage and examples.
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/idosell)
|
|
8
|
+
|
|
7
9
|
## Basic use
|
|
8
10
|
|
|
9
11
|
Package translates awkward gate names into more readable method names using REST verbs and gateways. Most of the possible methods are kept as is, only changed to camel case. For example:
|
package/changelog.md
CHANGED
|
@@ -5,6 +5,16 @@ 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
|
+
|
|
13
|
+
## [0.4.24] - 2025-03-21
|
|
14
|
+
### Changed
|
|
15
|
+
- Updated to v7.13
|
|
16
|
+
- Fixed url format
|
|
17
|
+
|
|
8
18
|
## [0.4.23] - 2025-03-11
|
|
9
19
|
### Changed
|
|
10
20
|
- Added custom error class
|
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
|
|
202
|
-
import
|
|
203
|
-
import
|
|
204
|
-
import
|
|
205
|
-
import
|
|
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
|
|
290
|
+
import searchSubscriptionsItems from "./methods/searchSubscriptionsItems.js";
|
|
275
291
|
import postSubscriptionsListViewFetchIds from "./methods/postSubscriptionsListViewFetchIds.js";
|
|
276
|
-
import
|
|
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
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
|
|
626
|
+
searchSubscriptionsItems,
|
|
595
627
|
postSubscriptionsListViewFetchIds,
|
|
596
|
-
|
|
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
|
-
|
|
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) => {
|
package/dist/gateways.d.ts
CHANGED
|
@@ -1664,6 +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
|
+
/** Split payment MPP marking */
|
|
1668
|
+
splitPayment: (splitPayment: boolean) => this
|
|
1667
1669
|
}
|
|
1668
1670
|
|
|
1669
1671
|
export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, PutOrdersResponse, RequestParams.PutOrdersParams> {
|
|
@@ -1677,6 +1679,8 @@ export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, Pu
|
|
|
1677
1679
|
orderStatus: (orderStatus: string) => this
|
|
1678
1680
|
/** Order status id . */
|
|
1679
1681
|
orderStatusId: (orderStatusId: number|string) => this
|
|
1682
|
+
/** Transaction type. */
|
|
1683
|
+
transactionType: (transactionType: 'national'|'oss'|'export'|'intra') => this
|
|
1680
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. */
|
|
1681
1685
|
apiFlag: (apiFlag: 'none'|'registered'|'realized'|'registered_pos'|'realized_pos'|'registration_fault') => this
|
|
1682
1686
|
/** API note added to order. */
|
|
@@ -1709,6 +1713,10 @@ export interface PutOrdersRequest extends AppendableGateway<PutOrdersRequest, Pu
|
|
|
1709
1713
|
purchaseDate: (purchaseDate: string) => this
|
|
1710
1714
|
/** Estimated date of shipment of the order in format Y-m-d H:i */
|
|
1711
1715
|
estimatedDeliveryDate: (estimatedDeliveryDate: string) => this
|
|
1716
|
+
/** Split payment MPP marking */
|
|
1717
|
+
splitPayment: (splitPayment: boolean) => this
|
|
1718
|
+
/** Planned date of packing */
|
|
1719
|
+
plannedDateOfPacking: (plannedDateOfPacking: string) => this
|
|
1712
1720
|
}
|
|
1713
1721
|
|
|
1714
1722
|
export interface SearchOrdersRequest extends PagableGateway<SearchOrdersRequest, SearchOrdersResponse, RequestParams.SearchOrdersParams> {
|
|
@@ -1718,6 +1726,8 @@ export interface SearchOrdersRequest extends PagableGateway<SearchOrdersRequest,
|
|
|
1718
1726
|
ordersStatuses: (value: string|string[]) => this;
|
|
1719
1727
|
/** Order statusses ids. */
|
|
1720
1728
|
ordersStatusesIds: (value: number|string|number[]|string[]) => this;
|
|
1729
|
+
/** Transaction type. */
|
|
1730
|
+
transactionType: (value: 'national'|'oss'|'export'|'intra') => this;
|
|
1721
1731
|
shippmentStatus: (value: 'all'|'received'|'non-received') => this;
|
|
1722
1732
|
/** Shipping companies (packages deliverers). */
|
|
1723
1733
|
couriersName: (value: string|string[]) => this;
|
|
@@ -3266,7 +3276,7 @@ export interface SearchProductsRequest extends PagableGateway<SearchProductsRequ
|
|
|
3266
3276
|
dispatchSettings: (value: RequestParams.SearchProductsParams["dispatchSettings"]) => this;
|
|
3267
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. */
|
|
3268
3278
|
returnProducts: (value: "active" | "deleted" | "in_trash") => this;
|
|
3269
|
-
/** 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 */
|
|
3270
3280
|
returnElements: (value: string|string[]) => this;
|
|
3271
3281
|
/** Product availability. Available values: "y" - available, "n" - unavailable. */
|
|
3272
3282
|
productIsAvailable: (value: "y" | "n") => this;
|
|
@@ -3410,7 +3420,7 @@ export interface SearchProductsRequest extends PagableGateway<SearchProductsRequ
|
|
|
3410
3420
|
inStock: (stockIds?: boolean|number|string|number[]|string[]) => this;
|
|
3411
3421
|
}
|
|
3412
3422
|
|
|
3413
|
-
export interface
|
|
3423
|
+
export interface DeleteProductsToFacebookCatalogRequest extends Gateway {
|
|
3414
3424
|
/** You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
|
|
3415
3425
|
facebookCatalogId: (value: number|string) => this;
|
|
3416
3426
|
/** Shop Id */
|
|
@@ -3419,14 +3429,14 @@ export interface DeleteProductsProductsToFacebookCatalogRequest extends Gateway
|
|
|
3419
3429
|
products: (value: number|string|number[]|string[]) => this;
|
|
3420
3430
|
}
|
|
3421
3431
|
|
|
3422
|
-
export interface
|
|
3432
|
+
export interface GetProductsToFacebookCatalogRequest extends Gateway {
|
|
3423
3433
|
/** You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
|
|
3424
3434
|
facebookCatalogId: (value: number|string) => this;
|
|
3425
3435
|
/** Shop Id */
|
|
3426
3436
|
shopId: (value: number|string) => this;
|
|
3427
3437
|
}
|
|
3428
3438
|
|
|
3429
|
-
export interface
|
|
3439
|
+
export interface PostProductsToFacebookCatalogRequest extends Gateway {
|
|
3430
3440
|
/** You can read the Facebook Catalog ID in the Marketing & Integrations/Facebook/Facebook Product Catalog admin panel */
|
|
3431
3441
|
facebookCatalogId: (value: number|string) => this;
|
|
3432
3442
|
/** Shop Id */
|
|
@@ -3435,14 +3445,14 @@ export interface PostProductsProductsToFacebookCatalogRequest extends Gateway {
|
|
|
3435
3445
|
products: (value: number|string|number[]|string[]) => this;
|
|
3436
3446
|
}
|
|
3437
3447
|
|
|
3438
|
-
export interface
|
|
3448
|
+
export interface DeleteProductsToPromotionRequest extends Gateway {
|
|
3439
3449
|
/** Special offer ID */
|
|
3440
3450
|
promotionId: (value: number|string) => this;
|
|
3441
3451
|
/** Products list. */
|
|
3442
3452
|
products: (value: number|string|number[]|string[]) => this;
|
|
3443
3453
|
}
|
|
3444
3454
|
|
|
3445
|
-
export interface
|
|
3455
|
+
export interface PostProductsToPromotionRequest extends Gateway<PutProductsMarketingPromotionResponse, RequestParams.PostProductsToPromotionParams> {
|
|
3446
3456
|
/** Special offer ID */
|
|
3447
3457
|
promotionId: (value: number|string) => this;
|
|
3448
3458
|
/** Products list. */
|
|
@@ -3709,6 +3719,235 @@ export interface PutProductsSynchronizationFinishUploadRequest extends Gateway {
|
|
|
3709
3719
|
verifyFiles: (value: boolean) => this;
|
|
3710
3720
|
}
|
|
3711
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
|
+
|
|
3712
3951
|
export interface PostRefundsAddAutomaticRefundRequest extends Gateway {
|
|
3713
3952
|
/** Source type.: "return" "rma". */
|
|
3714
3953
|
sourceType: (value: 'return'|'rma') => this;
|
|
@@ -4318,7 +4557,7 @@ export interface PostSubscriptionsEditProductRequest extends Gateway {
|
|
|
4318
4557
|
products: (value: Array<JSObject>) => this;
|
|
4319
4558
|
}
|
|
4320
4559
|
|
|
4321
|
-
export interface
|
|
4560
|
+
export interface SearchSubscriptionsItemsRequest extends Gateway {
|
|
4322
4561
|
filter: (value: JSObject) => this;
|
|
4323
4562
|
orderBy: (value: JSObject) => this;
|
|
4324
4563
|
/** Pagination settings. */
|
|
@@ -4348,7 +4587,7 @@ export interface PostSubscriptionsListViewFetchIdsRequest extends Gateway {
|
|
|
4348
4587
|
textSearch: (value: string) => this;
|
|
4349
4588
|
}
|
|
4350
4589
|
|
|
4351
|
-
export interface
|
|
4590
|
+
export interface SearchSubscriptionsListViewRequest extends Gateway {
|
|
4352
4591
|
select: (value: JSObject) => this;
|
|
4353
4592
|
/** Filters that limit the result of a customer query. */
|
|
4354
4593
|
filter: (value: JSObject) => this;
|
|
@@ -5067,11 +5306,11 @@ export interface Gateways {
|
|
|
5067
5306
|
postProducts: PostProductsRequest,
|
|
5068
5307
|
putProducts: PutProductsRequest,
|
|
5069
5308
|
searchProducts: SearchProductsRequest,
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5309
|
+
deleteProductsToFacebookCatalog: DeleteProductsToFacebookCatalogRequest,
|
|
5310
|
+
getProductsToFacebookCatalog: GetProductsToFacebookCatalogRequest,
|
|
5311
|
+
postProductsToFacebookCatalog: PostProductsToFacebookCatalogRequest,
|
|
5312
|
+
deleteProductsToPromotion: DeleteProductsToPromotionRequest,
|
|
5313
|
+
postProductsToPromotion: PostProductsToPromotionRequest,
|
|
5075
5314
|
getProductsQuestions: GetProductsQuestionsRequest,
|
|
5076
5315
|
putProductsQuestions: PutProductsQuestionsRequest,
|
|
5077
5316
|
getProductsReservations: GetProductsReservationsRequest,
|
|
@@ -5093,6 +5332,22 @@ export interface Gateways {
|
|
|
5093
5332
|
putProductsSupplierProductData: PutProductsSupplierProductDataRequest,
|
|
5094
5333
|
postProductsSynchronizationFile: PostProductsSynchronizationFileRequest,
|
|
5095
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,
|
|
5096
5351
|
postRefundsAddAutomaticRefund: PostRefundsAddAutomaticRefundRequest,
|
|
5097
5352
|
postRefundsAddAutomaticRefundForOrder: PostRefundsAddAutomaticRefundForOrderRequest,
|
|
5098
5353
|
postRefundsAddManualRefund: PostRefundsAddManualRefundRequest,
|
|
@@ -5140,9 +5395,9 @@ export interface Gateways {
|
|
|
5140
5395
|
postSubscriptionsDeleteProduct: PostSubscriptionsDeleteProductRequest,
|
|
5141
5396
|
postSubscriptionsEdit: PostSubscriptionsEditRequest,
|
|
5142
5397
|
postSubscriptionsEditProduct: PostSubscriptionsEditProductRequest,
|
|
5143
|
-
|
|
5398
|
+
searchSubscriptionsItems: SearchSubscriptionsItemsRequest,
|
|
5144
5399
|
postSubscriptionsListViewFetchIds: PostSubscriptionsListViewFetchIdsRequest,
|
|
5145
|
-
|
|
5400
|
+
searchSubscriptionsListView: SearchSubscriptionsListViewRequest,
|
|
5146
5401
|
postSubscriptionsSetRebateCode: PostSubscriptionsSetRebateCodeRequest,
|
|
5147
5402
|
postSubscriptionsUnsetRebateCode: PostSubscriptionsUnsetRebateCodeRequest,
|
|
5148
5403
|
getSystemConfig: GetSystemConfigRequest,
|
|
@@ -5209,7 +5464,15 @@ export interface Gateways {
|
|
|
5209
5464
|
/** @deprecated */
|
|
5210
5465
|
getProductsDeliveryTime: SearchProductsDeliveryTimeRequest
|
|
5211
5466
|
/** @deprecated */
|
|
5212
|
-
|
|
5467
|
+
getProductsProductsProductsToFacebookCatalog: GetProductsToFacebookCatalogRequest
|
|
5468
|
+
/** @deprecated */
|
|
5469
|
+
postProductsProductsToPromotion: PostProductsToPromotionRequest
|
|
5470
|
+
/** @deprecated */
|
|
5471
|
+
postProductsProductsToFacebookCatalog: PostProductsToFacebookCatalogRequest
|
|
5472
|
+
/** @deprecated */
|
|
5473
|
+
deleteProductsProductsToFacebookCatalog: DeleteProductsToFacebookCatalogRequest
|
|
5474
|
+
/** @deprecated */
|
|
5475
|
+
deleteProductsProductsToPromotion: DeleteProductsToPromotionRequest
|
|
5213
5476
|
}
|
|
5214
5477
|
|
|
5215
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,8 +3,25 @@ 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 = "") {
|
|
7
|
+
if (!input.length)
|
|
8
|
+
return "";
|
|
9
|
+
const trimmed = input.trim();
|
|
10
|
+
const withProtocol = trimmed
|
|
11
|
+
.replace(/^https?:\/\//i, "") // strip existing protocol
|
|
12
|
+
.replace(/^\/{2}/, ""); // strip bare // (protocol-relative)
|
|
13
|
+
const normalized = `https://${withProtocol}`;
|
|
14
|
+
let parsed;
|
|
15
|
+
try {
|
|
16
|
+
parsed = new URL(normalized);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new Error(`Invalid URL: "${input}"`);
|
|
20
|
+
}
|
|
21
|
+
return parsed.origin;
|
|
22
|
+
}
|
|
6
23
|
const idosell = (url, apiKey, version = DEFAULT_VERSION) => {
|
|
7
|
-
const auth = { url, apiKey, version, apikey: apiKey ? apiKey.slice(0, 6) + '*'.repeat(20) : "" };
|
|
24
|
+
const auth = { url: normalizeUrl(url), apiKey, version, apikey: apiKey ? apiKey.slice(0, 6) + '*'.repeat(20) : "" };
|
|
8
25
|
Object.defineProperty(auth, 'apiKey', { enumerable: false });
|
|
9
26
|
const element = { auth, params: {} };
|
|
10
27
|
return new Proxy(element, gateProxy);
|