idosell 0.4.34 → 0.4.38
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/changelog.md +8 -0
- package/dist/enums.d.ts +175 -0
- package/dist/enums.js +175 -0
- package/dist/gateways.d.ts +42 -43
- package/dist/methods/getProductsAttachmentsGetContent.js +1 -0
- package/dist/methods/searchProductsCategoriesIdosell.js +1 -2
- package/dist/reqparams.d.ts +241 -206
- package/dist/responses.d.ts +71 -43
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +20 -1
- package/package.json +2 -2
- package/tests/utilMapProductParameters.test.js +97 -0
- package/tests/utilTestData.ts +238 -1
package/dist/responses.d.ts
CHANGED
|
@@ -8404,7 +8404,7 @@ export type GetProductsResponse = {
|
|
|
8404
8404
|
productSizeQuantity: number;
|
|
8405
8405
|
}[];
|
|
8406
8406
|
/** @description Size data */
|
|
8407
|
-
productSizesStocksLocations
|
|
8407
|
+
productSizesStocksLocations?: {
|
|
8408
8408
|
/** @description Stock ID */
|
|
8409
8409
|
stockId: number;
|
|
8410
8410
|
productSizesLocation: {
|
|
@@ -8489,11 +8489,11 @@ export type GetProductsResponse = {
|
|
|
8489
8489
|
/** @description Gross price */
|
|
8490
8490
|
productRetailPrice: number;
|
|
8491
8491
|
/** @description Gross price after promotion. The item is returned when the 'showPromotionsPrices' parameter is specified in the request */
|
|
8492
|
-
productPromoRetailPrice
|
|
8492
|
+
productPromoRetailPrice?: number;
|
|
8493
8493
|
/** @description Wholesale price */
|
|
8494
8494
|
productWholesalePrice: number;
|
|
8495
8495
|
/** @description Wholesale price after promotion. The item is returned when the 'showPromotionsPrices' parameter is specified in the request */
|
|
8496
|
-
productPromoWholesalePrice
|
|
8496
|
+
productPromoWholesalePrice?: number;
|
|
8497
8497
|
/** @description Minimal price */
|
|
8498
8498
|
productMinimalPrice: number;
|
|
8499
8499
|
/** @description Price for automatic calculations */
|
|
@@ -8771,7 +8771,7 @@ export type GetProductsResponse = {
|
|
|
8771
8771
|
sizePanelName: string;
|
|
8772
8772
|
}[];
|
|
8773
8773
|
/** @description Available sizes of products in a set or collection for marketplaces */
|
|
8774
|
-
bundledAvailableSizesInAuctions
|
|
8774
|
+
bundledAvailableSizesInAuctions?: {
|
|
8775
8775
|
/** @description Size identifier */
|
|
8776
8776
|
sizeId: string;
|
|
8777
8777
|
/** @description Size name */
|
|
@@ -8805,7 +8805,7 @@ export type GetProductsResponse = {
|
|
|
8805
8805
|
}[];
|
|
8806
8806
|
}[];
|
|
8807
8807
|
/** @description Parameter values */
|
|
8808
|
-
parameterValues?: {
|
|
8808
|
+
parameterValues?: null | {
|
|
8809
8809
|
/** @description Parameter value ID */
|
|
8810
8810
|
parameterValueId: number;
|
|
8811
8811
|
/** @description Language data */
|
|
@@ -8972,7 +8972,7 @@ export type GetProductsResponse = {
|
|
|
8972
8972
|
/** @description Minimum stock level */
|
|
8973
8973
|
minStockLevel?: number;
|
|
8974
8974
|
}[];
|
|
8975
|
-
} & { resultsLimit: number
|
|
8975
|
+
} & { resultsLimit: number };
|
|
8976
8976
|
|
|
8977
8977
|
export type GetOrdersResponse = {
|
|
8978
8978
|
Results: {
|
|
@@ -8997,7 +8997,7 @@ export type GetOrdersResponse = {
|
|
|
8997
8997
|
/** @description Customer's company name. */
|
|
8998
8998
|
clientFirm: string;
|
|
8999
8999
|
/** @description Product suggestion. */
|
|
9000
|
-
clientAdditional
|
|
9000
|
+
clientAdditional?: string;
|
|
9001
9001
|
/** @description Street and number. */
|
|
9002
9002
|
clientStreet: string;
|
|
9003
9003
|
/** @description Customer's postal code. */
|
|
@@ -9007,7 +9007,7 @@ export type GetOrdersResponse = {
|
|
|
9007
9007
|
/** @description Region name takes priority over clientCountryId. */
|
|
9008
9008
|
clientCountryName: string;
|
|
9009
9009
|
/** @description Client NIP verification status */
|
|
9010
|
-
clientNipUeVerified: string;
|
|
9010
|
+
clientNipUeVerified: string | null;
|
|
9011
9011
|
/** @description Country ID in accordance with ISO-3166. */
|
|
9012
9012
|
clientCountryId: string;
|
|
9013
9013
|
/** @description Cell phone. */
|
|
@@ -9052,9 +9052,10 @@ export type GetOrdersResponse = {
|
|
|
9052
9052
|
/** @description Internal Receiving Point Identifier. */
|
|
9053
9053
|
clientDeliveryAddressPickupPointInternalId: number;
|
|
9054
9054
|
};
|
|
9055
|
-
clientPickupPointAddress
|
|
9055
|
+
clientPickupPointAddress?: {
|
|
9056
9056
|
/** @description Collection point ID. */
|
|
9057
|
-
pickupPointId:
|
|
9057
|
+
pickupPointId: number;
|
|
9058
|
+
externalPickupPointId?: string;
|
|
9058
9059
|
/** @description External service collection point ID. */
|
|
9059
9060
|
externalPickupPointId: string;
|
|
9060
9061
|
/** @description Town / City. */
|
|
@@ -9071,9 +9072,11 @@ export type GetOrdersResponse = {
|
|
|
9071
9072
|
longitude: number;
|
|
9072
9073
|
/** @description Name. */
|
|
9073
9074
|
name: string;
|
|
9075
|
+
/** @description Country (2 letter country code). */
|
|
9076
|
+
country: string;
|
|
9074
9077
|
};
|
|
9075
9078
|
/** @description Buyer's address data. */
|
|
9076
|
-
payerAddress
|
|
9079
|
+
payerAddress?: {
|
|
9077
9080
|
/** @description Buyer's address id. */
|
|
9078
9081
|
payerAddressId: string;
|
|
9079
9082
|
/** @description Buyer's first name. */
|
|
@@ -9137,9 +9140,13 @@ export type GetOrdersResponse = {
|
|
|
9137
9140
|
/** @description Order status. Allowed values: "finished_ext" - order status: completed in FA application, "finished" - completed, "new" - not handled, "payment_waiting" - awaiting payment, "delivery_waiting" - awaiting delivery, "on_order" - in progress, "packed" - being picked, "packed_fulfillment" - being picked - fulfilment, "packed_ready" - packed, "ready" - ready, "wait_for_dispatch" - awaiting dispatch date, "suspended" - on hold, "joined" - merged, "missing" - missing, "lost" - lost, "false" - false, "canceled" - Customer canceled. */
|
|
9138
9141
|
orderStatus: string;
|
|
9139
9142
|
/** @description Order status id */
|
|
9140
|
-
orderStatusId
|
|
9143
|
+
orderStatusId?: number;
|
|
9141
9144
|
/** @description Date of change of status to the currently set status in YYYY-MM-DD HH:MM:SS format. */
|
|
9142
9145
|
orderStatusChangeDate: string;
|
|
9146
|
+
/** @description Split payment MPP marking */
|
|
9147
|
+
splitPayment: boolean;
|
|
9148
|
+
/** @description Transaction type. */
|
|
9149
|
+
transactionType: null |"national" | "oss" | "export" | "intra";
|
|
9143
9150
|
/** @example dropshippingOrderStatus */
|
|
9144
9151
|
dropshippingOrderStatus: string;
|
|
9145
9152
|
/** @description Type of order confirmation. Confirmations listing: "none" - order unconfirmed , "email" - order confirmed by e-mail, "phone_client" - order confirmed by phone call made by client, "phone_service" - order confirmed by phone call made by staff, "postauction" - order confirmed by auction return page, "willingness" - confirmed by willingness to buy letter, "auctionfod" - confirmed by after-sales form Allegro. */
|
|
@@ -9147,11 +9154,11 @@ export type GetOrdersResponse = {
|
|
|
9147
9154
|
/** @description Date of order placing in YYYY-MM-DD HH:MM:SS format. */
|
|
9148
9155
|
orderAddDate: string;
|
|
9149
9156
|
/** @description Date of order sending in YYYY-MM-DD HH:MM:SS format. */
|
|
9150
|
-
orderDispatchDate: string | null;
|
|
9157
|
+
orderDispatchDate: 0 | string | null;
|
|
9151
9158
|
/** @example receivedDate */
|
|
9152
9159
|
receivedDate: string;
|
|
9153
9160
|
/** @description Order handling time in seconds. */
|
|
9154
|
-
orderPrepareTime:
|
|
9161
|
+
orderPrepareTime: number | null;
|
|
9155
9162
|
/** @description Customer comments on order. */
|
|
9156
9163
|
clientNoteToOrder: string;
|
|
9157
9164
|
/** @description Customer remarks for courier. */
|
|
@@ -9171,7 +9178,7 @@ export type GetOrdersResponse = {
|
|
|
9171
9178
|
/** @description Currency average rate set for order (by default, an average rate of order adding date, if it wasn't manually changed). */
|
|
9172
9179
|
orderCurrencyValue: number;
|
|
9173
9180
|
/** @description Currency scaler. */
|
|
9174
|
-
orderCurrencyScale
|
|
9181
|
+
orderCurrencyScale?: number;
|
|
9175
9182
|
/** @description Panel billing currency exchange rate in relation to billing currency in the shop . */
|
|
9176
9183
|
billingCurrencyRate: number;
|
|
9177
9184
|
/** @description Products cost. */
|
|
@@ -9204,7 +9211,7 @@ export type GetOrdersResponse = {
|
|
|
9204
9211
|
};
|
|
9205
9212
|
/** @description Order currency squaring method. "gross" - calculated in gross prices, "net" - squared in net prices. */
|
|
9206
9213
|
orderWorthCalculateType: "gross" | "net";
|
|
9207
|
-
/** @description Information if the VAT for the current order was calculated: "y" - yes, "n" - no. */
|
|
9214
|
+
/** @description Information if the VAT for the current order was calculated: "y" - yes, "n" - no, "p" – requires approval by the store staff. */
|
|
9208
9215
|
orderVatExists: string;
|
|
9209
9216
|
};
|
|
9210
9217
|
/** @description Information about prepayment for the order. */
|
|
@@ -9236,9 +9243,9 @@ export type GetOrdersResponse = {
|
|
|
9236
9243
|
/** @description Currency ID */
|
|
9237
9244
|
currencyId: string;
|
|
9238
9245
|
/** @description Number of voucher used in a payment. */
|
|
9239
|
-
voucherNumber
|
|
9246
|
+
voucherNumber?: string;
|
|
9240
9247
|
/** @description Number of gift card used in a payment. */
|
|
9241
|
-
giftCardNumber
|
|
9248
|
+
giftCardNumber?: string;
|
|
9242
9249
|
}[];
|
|
9243
9250
|
/** @description Order source data. */
|
|
9244
9251
|
orderSourceResults: {
|
|
@@ -9247,7 +9254,7 @@ export type GetOrdersResponse = {
|
|
|
9247
9254
|
/** @description Shop Id */
|
|
9248
9255
|
shopId: number;
|
|
9249
9256
|
/** @description Auction site order comes from. Auction sites listing: "allegro" - Allegro.pl, "testwebapi" - Allegro.pl test site, "ebay" - eBay. */
|
|
9250
|
-
auctionsServiceName: string;
|
|
9257
|
+
auctionsServiceName: string | null;
|
|
9251
9258
|
/** @description Detailed information on order source. */
|
|
9252
9259
|
orderSourceDetails: {
|
|
9253
9260
|
/** @description order source type - possible values:. "self_added" - Orders from panel, "shop" - Orders from shop, "search_engine" - Orders from search engines, "auction" - Orders from auctions, "advertisement_campaign" - Advertisement campaigns, "price_comparer" - Price comparison sites, "affiliate_program" - Affiliate programme, "api" - Order from API, "eletronic_offer" - Order from ODT price lst, "cpa" - Order from CPA program, "refferer_site" - Order from reference sites, "pos" - Orders from POS, "marketplace" - Order from the Marketplace, "iai_ads" - Orders from IAI Ads */
|
|
@@ -9259,11 +9266,11 @@ export type GetOrdersResponse = {
|
|
|
9259
9266
|
/** @description Numerical ID of order source. */
|
|
9260
9267
|
orderSourceId: number;
|
|
9261
9268
|
/** @example 1 */
|
|
9262
|
-
entryProductIdBeforeOrder
|
|
9269
|
+
entryProductIdBeforeOrder?: number;
|
|
9263
9270
|
/** @example sourcePageUrl */
|
|
9264
|
-
sourcePageUrl
|
|
9271
|
+
sourcePageUrl?: string;
|
|
9265
9272
|
/** @description The order ID of the external service */
|
|
9266
|
-
orderExternalId: string;
|
|
9273
|
+
orderExternalId: string | null;
|
|
9267
9274
|
/** @description Order from the InPost Fresh marketplace */
|
|
9268
9275
|
fresh: "y" | "n";
|
|
9269
9276
|
/** @description Order supported by InPost fulfillment */
|
|
@@ -9285,16 +9292,16 @@ export type GetOrdersResponse = {
|
|
|
9285
9292
|
/** @description Data of auction, order comes from (only if it comes from auction). */
|
|
9286
9293
|
auctionInfo: {
|
|
9287
9294
|
/** @description Account ID on auction site. */
|
|
9288
|
-
auctionClientId
|
|
9295
|
+
auctionClientId?: string;
|
|
9289
9296
|
/** @description Account login on auction site. */
|
|
9290
|
-
auctionClientLogin
|
|
9297
|
+
auctionClientLogin?: string;
|
|
9291
9298
|
/** @description #!TablicaNumerowAukcjiDoZamowienia!#. */
|
|
9292
|
-
auctionItemsIds
|
|
9299
|
+
auctionItemsIds?: {
|
|
9293
9300
|
/** @description Auction number. */
|
|
9294
9301
|
auctionItemId: string;
|
|
9295
9302
|
}[];
|
|
9296
9303
|
/** @description The customer's email address at the auction service. */
|
|
9297
|
-
auctionClientEmail
|
|
9304
|
+
auctionClientEmail?: string;
|
|
9298
9305
|
};
|
|
9299
9306
|
/** @description Consignment data. */
|
|
9300
9307
|
dispatch: {
|
|
@@ -9324,7 +9331,7 @@ export type GetOrdersResponse = {
|
|
|
9324
9331
|
/** @description External product system code */
|
|
9325
9332
|
productCode: string;
|
|
9326
9333
|
/** @description Name of the parameter value, e.g. orange, green, red */
|
|
9327
|
-
versionName
|
|
9334
|
+
versionName?: string;
|
|
9328
9335
|
/** @description Size identifier */
|
|
9329
9336
|
sizeId: string;
|
|
9330
9337
|
/** @description Size name */
|
|
@@ -9334,7 +9341,7 @@ export type GetOrdersResponse = {
|
|
|
9334
9341
|
/** @description Stock ID */
|
|
9335
9342
|
stockId: number;
|
|
9336
9343
|
/** @description Serial number of the product. */
|
|
9337
|
-
productSerialNumber
|
|
9344
|
+
productSerialNumber?: string;
|
|
9338
9345
|
/** @description Product quantity. */
|
|
9339
9346
|
productQuantity: number;
|
|
9340
9347
|
/** @description Weight. */
|
|
@@ -9342,7 +9349,7 @@ export type GetOrdersResponse = {
|
|
|
9342
9349
|
/** @description Value of VAT */
|
|
9343
9350
|
productVat: number;
|
|
9344
9351
|
/** @description Is product VAT free Allowed values "y" - yes, "n" - no. */
|
|
9345
|
-
productVatFree
|
|
9352
|
+
productVatFree?: string;
|
|
9346
9353
|
/** @description Gross price of the product in the currency of the administration panel. */
|
|
9347
9354
|
productPanelPrice: number;
|
|
9348
9355
|
/** @description Net price of the product in the currency of the administration panel. */
|
|
@@ -9356,7 +9363,7 @@ export type GetOrdersResponse = {
|
|
|
9356
9363
|
/** @description Product net price of order in shop account currency. */
|
|
9357
9364
|
productOrderPriceNetBaseCurrency: number;
|
|
9358
9365
|
/** @description List of product suggestions . */
|
|
9359
|
-
orderAdditionalList
|
|
9366
|
+
orderAdditionalList?: {
|
|
9360
9367
|
/** @description Product suggestion. */
|
|
9361
9368
|
orderAdditional: {
|
|
9362
9369
|
/** @description Name of suggestion. */
|
|
@@ -9368,13 +9375,13 @@ export type GetOrdersResponse = {
|
|
|
9368
9375
|
/** @description Client's remarks on product. */
|
|
9369
9376
|
remarksToProduct: string;
|
|
9370
9377
|
/** @description Label for grouping products. */
|
|
9371
|
-
label: string;
|
|
9378
|
+
label: string | null;
|
|
9372
9379
|
/** @description Product selling mode. Available values: "money", "gift", "points". */
|
|
9373
9380
|
orderSalesMode: "money" | "gift" | "points";
|
|
9374
9381
|
/** @description A set's ID. */
|
|
9375
9382
|
bundleId: number;
|
|
9376
9383
|
/** @description Serial numbers. */
|
|
9377
|
-
productSerialNumbers: string;
|
|
9384
|
+
productSerialNumbers: string | null;
|
|
9378
9385
|
/** @description Additional information. */
|
|
9379
9386
|
productOrderAdditional: string;
|
|
9380
9387
|
/** @description Item in basket. */
|
|
@@ -9382,7 +9389,7 @@ export type GetOrdersResponse = {
|
|
|
9382
9389
|
/** @description price information. */
|
|
9383
9390
|
productPriceLog: string;
|
|
9384
9391
|
/** @description Information about the selected parameters in the configurator. */
|
|
9385
|
-
priceFormulaParameters
|
|
9392
|
+
priceFormulaParameters?: {
|
|
9386
9393
|
/** @description Parameter ID */
|
|
9387
9394
|
parameterId: string;
|
|
9388
9395
|
/** @description Parameter name. */
|
|
@@ -9409,7 +9416,7 @@ export type GetOrdersResponse = {
|
|
|
9409
9416
|
/** @description Note to the order. */
|
|
9410
9417
|
orderNote: string;
|
|
9411
9418
|
/** @description Information on used discount code. */
|
|
9412
|
-
discountCode
|
|
9419
|
+
discountCode?: {
|
|
9413
9420
|
/** @description Campaign ID. */
|
|
9414
9421
|
campaignId: string;
|
|
9415
9422
|
/** @description Name of code. */
|
|
@@ -9418,14 +9425,14 @@ export type GetOrdersResponse = {
|
|
|
9418
9425
|
discountCodeValue: string;
|
|
9419
9426
|
};
|
|
9420
9427
|
/** @description Discount card */
|
|
9421
|
-
discountCard
|
|
9428
|
+
discountCard?: {
|
|
9422
9429
|
/** @description Name of card */
|
|
9423
9430
|
discountCardName: string;
|
|
9424
9431
|
};
|
|
9425
9432
|
/** @description Order handler. */
|
|
9426
9433
|
orderOperatorLogin: string;
|
|
9427
9434
|
/** @description Order picker. */
|
|
9428
|
-
orderPackingPersonLogin: string;
|
|
9435
|
+
orderPackingPersonLogin: string | null;
|
|
9429
9436
|
/** @description Sale date. ISO 8602 format. */
|
|
9430
9437
|
purchaseDate: string;
|
|
9431
9438
|
/** @description Modification date in YYYY-MM-DD HH:MM:SS format . */
|
|
@@ -9440,14 +9447,9 @@ export type GetOrdersResponse = {
|
|
|
9440
9447
|
verified: boolean;
|
|
9441
9448
|
};
|
|
9442
9449
|
/** @description Information on error that occurred during gate call. */
|
|
9443
|
-
errors:
|
|
9444
|
-
/** @description Error code. */
|
|
9445
|
-
faultCode: number;
|
|
9446
|
-
/** @description Error description. */
|
|
9447
|
-
faultString: string;
|
|
9448
|
-
}[];
|
|
9450
|
+
errors: FaultCodeString[];
|
|
9449
9451
|
}[];
|
|
9450
|
-
};
|
|
9452
|
+
} & { resultsNumberAll: number };
|
|
9451
9453
|
|
|
9452
9454
|
type PromotionErrorEntry = {
|
|
9453
9455
|
/** @description Error code. */
|
|
@@ -9583,4 +9585,30 @@ export type GetRegulationsHistoryResponse = {
|
|
|
9583
9585
|
pagination: PagedResponse;
|
|
9584
9586
|
};
|
|
9585
9587
|
|
|
9588
|
+
export type GetProductsAttachmentsGetContentResponse = {
|
|
9589
|
+
/** @description Product attachment content */
|
|
9590
|
+
data: {
|
|
9591
|
+
/** @description Product attachment content */
|
|
9592
|
+
attachmentContent: string | null;
|
|
9593
|
+
/** @description Product attachment content representation
|
|
9594
|
+
|null} */
|
|
9595
|
+
attachmentContentRepresentation: "base64" | "url" | null;
|
|
9596
|
+
/** @description Product attachment file extension */
|
|
9597
|
+
attachmentContentFileExtension: string | null;
|
|
9598
|
+
};
|
|
9599
|
+
isError: boolean;
|
|
9600
|
+
errors: {
|
|
9601
|
+
/** @description Error code. */
|
|
9602
|
+
code: string;
|
|
9603
|
+
/** @description Field associated with the error. */
|
|
9604
|
+
field: string | null;
|
|
9605
|
+
/** @description Error description. */
|
|
9606
|
+
message: string | null;
|
|
9607
|
+
/** @description Value associated with the error. */
|
|
9608
|
+
value: string | null;
|
|
9609
|
+
/** @description Unique identifier of the error (for support). */
|
|
9610
|
+
uid: string | null;
|
|
9611
|
+
}[];
|
|
9612
|
+
};
|
|
9613
|
+
|
|
9586
9614
|
export { };
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ type GetLangDataFunction = <T extends {
|
|
|
11
11
|
langId: string;
|
|
12
12
|
}>(_array: T[], _langId?: string) => T | undefined;
|
|
13
13
|
type ClearParametersLangDataFunction = (_products: SearchProductsResponse['results'], _langId?: string) => SearchProductsResponse['results'];
|
|
14
|
+
type MappedParameterValue = {
|
|
15
|
+
valueId: number;
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
type MappedParameter = {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
values: MappedParameterValue[];
|
|
22
|
+
};
|
|
23
|
+
type MapProductParametersFunction = (_product: IdosellProduct, _langId?: string) => MappedParameter[];
|
|
14
24
|
declare const _default: {
|
|
15
25
|
/** @description The method allows you to build an IAI code from the product ID and size ID. */
|
|
16
26
|
getIaiCode: GetIaICodeFunction;
|
|
@@ -30,5 +40,7 @@ declare const _default: {
|
|
|
30
40
|
clearParametersLangData: ClearParametersLangDataFunction;
|
|
31
41
|
/** @description Removes attachments to RMA that are returned by default, helps to reduce data if serialized or forwarded */
|
|
32
42
|
removeRmaAttachments: (rmaResponse: GetRmaResponse) => GetRmaResponse;
|
|
43
|
+
/** @description Maps product parameters to a simplified structure for a given language. Skips parameters with no values. */
|
|
44
|
+
mapProductParameters: MapProductParametersFunction;
|
|
33
45
|
};
|
|
34
46
|
export default _default;
|
package/dist/utils.js
CHANGED
|
@@ -269,6 +269,23 @@ const removeRmaAttachments = (rmaResponse) => {
|
|
|
269
269
|
}
|
|
270
270
|
return rmaResponse;
|
|
271
271
|
};
|
|
272
|
+
const mapProductParameters = (product, langId = 'pol') => {
|
|
273
|
+
if (!product.productParameters)
|
|
274
|
+
return [];
|
|
275
|
+
return product.productParameters.reduce((acc, param) => {
|
|
276
|
+
if (!param.parameterValues?.length)
|
|
277
|
+
return acc;
|
|
278
|
+
const name = param.parameterDescriptionsLangData.find((l) => l.langId === langId)?.parameterName ?? '';
|
|
279
|
+
const values = param.parameterValues.reduce((valAcc, pv) => {
|
|
280
|
+
const value = pv.parameterValueDescriptionsLangData.find((l) => l.langId === langId)
|
|
281
|
+
?.parameterValueName ?? '';
|
|
282
|
+
valAcc.push({ valueId: pv.parameterValueId, value });
|
|
283
|
+
return valAcc;
|
|
284
|
+
}, []);
|
|
285
|
+
acc.push({ id: param.parameterId, name, values });
|
|
286
|
+
return acc;
|
|
287
|
+
}, []);
|
|
288
|
+
};
|
|
272
289
|
export default {
|
|
273
290
|
/** @description The method allows you to build an IAI code from the product ID and size ID. */
|
|
274
291
|
getIaiCode,
|
|
@@ -287,5 +304,7 @@ export default {
|
|
|
287
304
|
/** @description Modifies product response by removing all parameter names nad values that are not in selected langId */
|
|
288
305
|
clearParametersLangData,
|
|
289
306
|
/** @description Removes attachments to RMA that are returned by default, helps to reduce data if serialized or forwarded */
|
|
290
|
-
removeRmaAttachments
|
|
307
|
+
removeRmaAttachments,
|
|
308
|
+
/** @description Maps product parameters to a simplified structure for a given language. Skips parameters with no values. */
|
|
309
|
+
mapProductParameters,
|
|
291
310
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idosell",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.38",
|
|
4
4
|
"description": "Idosell 3 REST connector",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/gateways.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://idosell-converter.vercel.app",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"axios": "^1.
|
|
26
|
+
"axios": "^1.17.0"
|
|
27
27
|
},
|
|
28
28
|
"type": "module"
|
|
29
29
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { utils } from '../dist/index';
|
|
2
|
+
import { PARAMETER_PRODUCT, PARAMETER_PRODUCT_RESULT } from './utilTestData';
|
|
3
|
+
|
|
4
|
+
// mapProductParameters.test.ts
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
|
|
7
|
+
const makeLangData = (langId, name) => ({
|
|
8
|
+
langId,
|
|
9
|
+
parameterName: name,
|
|
10
|
+
parameterDescription: '',
|
|
11
|
+
parameterShopsData: [],
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const makeValueLangData = (langId, valueName) => ({
|
|
15
|
+
langId,
|
|
16
|
+
parameterValueName: valueName,
|
|
17
|
+
parameterValueDescription: '',
|
|
18
|
+
parameterValueShopsData: [],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const makeParam = (id, name, values, langId = 'pol') => ({
|
|
22
|
+
parameterId: id,
|
|
23
|
+
parameterType: 'parameter',
|
|
24
|
+
parameterDescriptionsLangData: [makeLangData(langId, name)],
|
|
25
|
+
parameterValues: values.map((v) => ({
|
|
26
|
+
parameterValueId: v.id,
|
|
27
|
+
parameterValueDescriptionsLangData: [makeValueLangData(langId, v.name)],
|
|
28
|
+
})),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('mapProductParameters', () => {
|
|
32
|
+
it('returns [] when productParameters is undefined', () => {
|
|
33
|
+
expect(utils.mapProductParameters({})).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns [] when productParameters is empty', () => {
|
|
37
|
+
expect(utils.mapProductParameters({ productParameters: [] })).toEqual([]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('skips parameters with null parameterValues', () => {
|
|
41
|
+
const product = {
|
|
42
|
+
productParameters: [
|
|
43
|
+
{ ...makeParam(1, 'Color', [{ id: 10, name: 'Red' }]), parameterValues: null },
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
expect(utils.mapProductParameters(product)).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('skips parameters with empty parameterValues', () => {
|
|
50
|
+
const product = {
|
|
51
|
+
productParameters: [{ ...makeParam(1, 'Color', []), parameterValues: [] }],
|
|
52
|
+
};
|
|
53
|
+
expect(utils.mapProductParameters(product)).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('maps a single parameter with values using default lang (pol)', () => {
|
|
57
|
+
const product = {
|
|
58
|
+
productParameters: [makeParam(1, 'Color', [{ id: 10, name: 'Red' }])],
|
|
59
|
+
};
|
|
60
|
+
expect(utils.mapProductParameters(product)).toEqual([
|
|
61
|
+
{ id: 1, name: 'Color', values: [{ valueId: 10, value: 'Red' }] },
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('maps multiple parameters and multiple values', () => {
|
|
66
|
+
const product = {
|
|
67
|
+
productParameters: [
|
|
68
|
+
makeParam(1, 'Color', [{ id: 10, name: 'Red' }, { id: 11, name: 'Blue' }]),
|
|
69
|
+
makeParam(2, 'Size', [{ id: 20, name: 'M' }, { id: 21, name: 'L' }]),
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
expect(utils.mapProductParameters(product)).toEqual([
|
|
73
|
+
{ id: 1, name: 'Color', values: [{ valueId: 10, value: 'Red' }, { valueId: 11, value: 'Blue' }] },
|
|
74
|
+
{ id: 2, name: 'Size', values: [{ valueId: 20, value: 'M' }, { valueId: 21, value: 'L' }] },
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('uses provided langId instead of default', () => {
|
|
79
|
+
const product = {
|
|
80
|
+
productParameters: [makeParam(1, 'Kolor', [{ id: 10, name: 'Czerwony' }], 'eng')],
|
|
81
|
+
};
|
|
82
|
+
expect(utils.mapProductParameters(product, 'eng')).toEqual([
|
|
83
|
+
{ id: 1, name: 'Kolor', values: [{ valueId: 10, value: 'Czerwony' }] },
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('falls back to empty string when langId has no matching entry', () => {
|
|
88
|
+
const product = {
|
|
89
|
+
productParameters: [makeParam(1, 'Color', [{ id: 10, name: 'Red' }], 'pol')],
|
|
90
|
+
};
|
|
91
|
+
expect(utils.mapProductParameters(product, 'deu')).toEqual([
|
|
92
|
+
{ id: 1, name: '', values: [{ valueId: 10, value: '' }] },
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(utils.mapProductParameters(PARAMETER_PRODUCT)).toEqual(PARAMETER_PRODUCT_RESULT)
|
|
97
|
+
});
|