@djust-b2b/djust-front-sdk 1.11.0 → 1.11.1
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/lib/index.d.ts +1 -1
- package/lib/services/cart/index.d.ts +2 -2
- package/lib/services/cart/index.js +3 -2
- package/lib/services/product-variant/definitions.d.ts +145 -0
- package/lib/services/product-variant/definitions.js +7 -0
- package/lib/services/product-variant/index.d.ts +200 -0
- package/lib/services/product-variant/index.js +238 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export declare const DjustSDK: {
|
|
|
116
116
|
updateCustomerAccountOrganisationUser({ organisationId, customerUserId, civility, customFieldValues, firstName, lastName, phone, }: import("./interfaces").UpdateCustomerAccountOrganisationUserParameters): Promise<import("./interfaces").UpdateCustomerAccountOrganisationUserResponse>;
|
|
117
117
|
deleteCarts(): Promise<import("./interfaces").DeleteCartsResponse>;
|
|
118
118
|
getCarts(params: import("./interfaces").GetCartsParameters): Promise<import("./interfaces").GetCartsResponse>;
|
|
119
|
-
createCart(params: import("./interfaces").CreateCartParameters): Promise<
|
|
119
|
+
createCart(params: import("./interfaces").CreateCartParameters): Promise<import("./interfaces").GetCartResponse>;
|
|
120
120
|
deleteCart(params: import("./interfaces").DeleteCartParameters): Promise<void>;
|
|
121
121
|
getCart(params: import("./interfaces").GetCartParameters): Promise<import("./interfaces").GetCartResponse>;
|
|
122
122
|
updateCart(params: import("./interfaces").UpdateCartParameters): Promise<void>;
|
|
@@ -93,7 +93,7 @@ export declare function getCarts(params: GetCartsParameters): Promise<GetCartsRe
|
|
|
93
93
|
*
|
|
94
94
|
* The name of the cart to create.
|
|
95
95
|
*
|
|
96
|
-
* @returns {Promise<
|
|
96
|
+
* @returns {Promise<GetCartResponse>} - A promise that resolves when the cart is created.
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* #### input
|
|
@@ -107,7 +107,7 @@ export declare function getCarts(params: GetCartsParameters): Promise<GetCartsRe
|
|
|
107
107
|
* }
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
|
-
export declare function createCart(params: CreateCartParameters): Promise<
|
|
110
|
+
export declare function createCart(params: CreateCartParameters): Promise<GetCartResponse>;
|
|
111
111
|
/**
|
|
112
112
|
* APICODE(cART300)
|
|
113
113
|
* Deletes a specific cart.
|
|
@@ -127,7 +127,7 @@ async function getCarts(params) {
|
|
|
127
127
|
*
|
|
128
128
|
* The name of the cart to create.
|
|
129
129
|
*
|
|
130
|
-
* @returns {Promise<
|
|
130
|
+
* @returns {Promise<GetCartResponse>} - A promise that resolves when the cart is created.
|
|
131
131
|
*
|
|
132
132
|
* @example
|
|
133
133
|
* #### input
|
|
@@ -143,11 +143,12 @@ async function getCarts(params) {
|
|
|
143
143
|
*/
|
|
144
144
|
async function createCart(params) {
|
|
145
145
|
const { name } = params;
|
|
146
|
-
(0, fetch_instance_1.enhancedFetch)({
|
|
146
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
147
147
|
method: "POST",
|
|
148
148
|
path: `/v2/shop/carts`,
|
|
149
149
|
body: JSON.stringify({ name }),
|
|
150
150
|
});
|
|
151
|
+
return data;
|
|
151
152
|
}
|
|
152
153
|
/**
|
|
153
154
|
* APICODE(cART300)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { AttributeObject } from "../../interfaces/models/attribute";
|
|
2
|
+
import { PageableParameters } from "../../interfaces/models/common";
|
|
3
|
+
import { OfferResponse } from "../../interfaces/models/offer";
|
|
4
|
+
import { PageProductVariantResponse, Product, ProductAutocomplete, ProductReviewDto, ProductReviewRatings, ProductReviewsSummary, SearchThumbnailsAndAggregation } from "../../interfaces/models/product";
|
|
5
|
+
import { SearchProduct } from "../../interfaces/models/searchProduct";
|
|
6
|
+
import { SupplierSimpleView } from "../../interfaces/models/supplier";
|
|
7
|
+
import { Order, PageableObject } from "../../interfaces/models/common";
|
|
8
|
+
/**
|
|
9
|
+
* Requests parameters type definitions
|
|
10
|
+
*/
|
|
11
|
+
export interface CreateProductReviewParameters {
|
|
12
|
+
message: string;
|
|
13
|
+
productSku: string;
|
|
14
|
+
rating: number;
|
|
15
|
+
}
|
|
16
|
+
export interface UpdateProductReviewParameters {
|
|
17
|
+
productReviewId: string;
|
|
18
|
+
message: string;
|
|
19
|
+
rating: number;
|
|
20
|
+
}
|
|
21
|
+
declare enum AggregationType {
|
|
22
|
+
PRODUCT = "PRODUCT",
|
|
23
|
+
VARIANT = "VARIANT"
|
|
24
|
+
}
|
|
25
|
+
export interface GetProductsListParameters {
|
|
26
|
+
locale: string;
|
|
27
|
+
filters?: {
|
|
28
|
+
currency: string;
|
|
29
|
+
categoryIds?: string[];
|
|
30
|
+
skus?: string[];
|
|
31
|
+
brand?: string[];
|
|
32
|
+
query?: string;
|
|
33
|
+
productTags?: string[];
|
|
34
|
+
aggregation?: AggregationType;
|
|
35
|
+
attributes?: string[];
|
|
36
|
+
suppliers?: string[];
|
|
37
|
+
customFields?: string[];
|
|
38
|
+
offerUpdatedTime?: string;
|
|
39
|
+
productUpdatedTime?: string;
|
|
40
|
+
};
|
|
41
|
+
pageable?: PageableParameters;
|
|
42
|
+
}
|
|
43
|
+
export interface GetProductStatReviewsParameters {
|
|
44
|
+
productIdentifier: string;
|
|
45
|
+
productIdType: string;
|
|
46
|
+
}
|
|
47
|
+
export interface GetProductReviewsParameters {
|
|
48
|
+
productIdentifier: string;
|
|
49
|
+
productIdType: string;
|
|
50
|
+
}
|
|
51
|
+
export interface GetProductParameters {
|
|
52
|
+
productIdentifier: string;
|
|
53
|
+
productIdType: string;
|
|
54
|
+
locale?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface GetProductOffersParameters {
|
|
57
|
+
productIdentifier: string;
|
|
58
|
+
productIdType: string;
|
|
59
|
+
locale?: string;
|
|
60
|
+
currency?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface GetProductVariantsListParameters {
|
|
63
|
+
productSku: string;
|
|
64
|
+
locale?: string;
|
|
65
|
+
pageable?: PageableParameters;
|
|
66
|
+
}
|
|
67
|
+
export interface GetProductVariantAttributesParameters {
|
|
68
|
+
productIdentifier: string;
|
|
69
|
+
productIdType: string;
|
|
70
|
+
locale?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface AutoCompleteSearchProductsParameters {
|
|
73
|
+
input: string;
|
|
74
|
+
locale: string;
|
|
75
|
+
currency: string;
|
|
76
|
+
aggregation?: AggregationType;
|
|
77
|
+
productTags?: string[];
|
|
78
|
+
pageable?: PageableParameters;
|
|
79
|
+
}
|
|
80
|
+
export interface GetProductVariantSuppliersParameters {
|
|
81
|
+
productVariantId: string;
|
|
82
|
+
}
|
|
83
|
+
export interface GetProductVariantOffersParameters {
|
|
84
|
+
productIdentifier: string;
|
|
85
|
+
productIdType: string;
|
|
86
|
+
currency?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface GetRelatedProductsParameters {
|
|
89
|
+
productIdentifier: string;
|
|
90
|
+
productIdType: string;
|
|
91
|
+
locale?: string;
|
|
92
|
+
currency?: string;
|
|
93
|
+
pageable?: PageableParameters;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Responses type definitions
|
|
97
|
+
*/
|
|
98
|
+
export interface CreateProductReviewResponse extends ProductReviewsSummary {
|
|
99
|
+
}
|
|
100
|
+
export interface UpdateProductReviewResponse extends ProductReviewDto {
|
|
101
|
+
}
|
|
102
|
+
export interface GetProductsListResponse extends SearchProduct {
|
|
103
|
+
}
|
|
104
|
+
export interface GetProductStatReviewsResponse extends ProductReviewRatings {
|
|
105
|
+
}
|
|
106
|
+
export interface GetProductReviewsResponse extends Array<ProductReviewsSummary> {
|
|
107
|
+
}
|
|
108
|
+
export interface GetProductResponse extends Product {
|
|
109
|
+
}
|
|
110
|
+
export interface GetProductOffersResponse extends Array<OfferResponse> {
|
|
111
|
+
}
|
|
112
|
+
export interface GetProductVariantsListResponse extends PageProductVariantResponse {
|
|
113
|
+
}
|
|
114
|
+
export interface GetProductVariantAttributesResponse extends Array<AttributeObject> {
|
|
115
|
+
}
|
|
116
|
+
export interface SearchProductsResponse extends Array<ProductAutocomplete> {
|
|
117
|
+
}
|
|
118
|
+
export interface GetProductVariantSuppliersResponse extends Array<SupplierSimpleView> {
|
|
119
|
+
}
|
|
120
|
+
export interface GetProductVariantOffersResponse extends Array<OfferResponse> {
|
|
121
|
+
}
|
|
122
|
+
export interface GetRelatedProductsResponse extends SearchThumbnailsAndAggregation {
|
|
123
|
+
}
|
|
124
|
+
export interface GetProductPaginatedOffersParameters {
|
|
125
|
+
productIdentifier: string;
|
|
126
|
+
productIdType?: string;
|
|
127
|
+
locale?: string;
|
|
128
|
+
currency?: string;
|
|
129
|
+
withoutPrices?: boolean;
|
|
130
|
+
pageable?: PageableParameters;
|
|
131
|
+
}
|
|
132
|
+
export interface GetProductPaginatedOffersResponse {
|
|
133
|
+
content: OfferResponse[];
|
|
134
|
+
empty: boolean;
|
|
135
|
+
first: boolean;
|
|
136
|
+
last: boolean;
|
|
137
|
+
number: number;
|
|
138
|
+
numberOfElements: number;
|
|
139
|
+
pageable: PageableObject;
|
|
140
|
+
size: number;
|
|
141
|
+
sort: Order[];
|
|
142
|
+
totalElements: number;
|
|
143
|
+
totalPages: number;
|
|
144
|
+
}
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { GetProductVariantAttributesParameters, GetProductVariantAttributesResponse, GetProductVariantSuppliersParameters, GetProductVariantSuppliersResponse, GetProductVariantsListParameters, GetProductVariantsListResponse } from "./definitions";
|
|
2
|
+
/**
|
|
3
|
+
* APICODE(pVAR300)
|
|
4
|
+
* Retrieves a paginated list of product variants.
|
|
5
|
+
*
|
|
6
|
+
* This function fetches a list of product variants associated with a specific product SKU.
|
|
7
|
+
*
|
|
8
|
+
* @param {GetProductVariantsListParameters} params - The parameters to filter the product variants list, including:
|
|
9
|
+
* #### productSku - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
10
|
+
* The SKU of the product to fetch variants for.
|
|
11
|
+
*
|
|
12
|
+
* #### locale - `string` | optional
|
|
13
|
+
* The locale for the product variants.
|
|
14
|
+
*
|
|
15
|
+
* #### pageable - `object` | optional
|
|
16
|
+
* Pagination details, including:
|
|
17
|
+
* - `page`: The page number.
|
|
18
|
+
* - `size`: The number of items per page.
|
|
19
|
+
* - `sort`: Sorting criteria.
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<GetProductVariantsListResponse>} - A promise that resolves with the paginated list of product variants.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* #### input
|
|
25
|
+
* ```typescript
|
|
26
|
+
* await getProductVariantsList({
|
|
27
|
+
* productSku: 'product123',
|
|
28
|
+
* locale: 'en-US',
|
|
29
|
+
* pageable: { page: 1, size: 10, sort: 'name,asc' },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
* #### output
|
|
33
|
+
* ```json
|
|
34
|
+
* {
|
|
35
|
+
* "content": [
|
|
36
|
+
* { "id": "variant1", "name": "Variant 1" },
|
|
37
|
+
* { "id": "variant2", "name": "Variant 2" }
|
|
38
|
+
* ],
|
|
39
|
+
* "pageable": {
|
|
40
|
+
* "page": 1,
|
|
41
|
+
* "size": 10,
|
|
42
|
+
* "totalPages": 5
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function getProductVariantsList({ productSku, locale, pageable, }: GetProductVariantsListParameters): Promise<GetProductVariantsListResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* APICODE(vSUP300)
|
|
50
|
+
* Retrieves suppliers of a specific product variant.
|
|
51
|
+
*
|
|
52
|
+
* This function fetches a list of suppliers associated with a product variant.
|
|
53
|
+
*
|
|
54
|
+
* @param {GetProductVariantSuppliersParameters} params - The parameters to identify the product variant, including:
|
|
55
|
+
* #### productVariantId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
56
|
+
* The ID of the product variant to fetch suppliers for.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Promise<GetProductVariantSuppliersResponse>} - A promise that resolves with the suppliers of the product variant.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* #### input
|
|
62
|
+
* ```typescript
|
|
63
|
+
* await getProductVariantSuppliers({ productVariantId: 'variant123' });
|
|
64
|
+
* ```
|
|
65
|
+
* #### output
|
|
66
|
+
* ```json
|
|
67
|
+
* {
|
|
68
|
+
* "suppliers": [
|
|
69
|
+
* { "id": "supplier1", "name": "Supplier 1" },
|
|
70
|
+
* { "id": "supplier2", "name": "Supplier 2" }
|
|
71
|
+
* ]
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function getProductVariantSuppliers({ productVariantId, }: GetProductVariantSuppliersParameters): Promise<GetProductVariantSuppliersResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* ## 🛒 APICODE(vATT300) - Fetch Product Variant Attributes
|
|
78
|
+
*
|
|
79
|
+
* Retrieves detailed attributes of a product variant identified by SKU, ID, or external ID.
|
|
80
|
+
* This metadata includes key details such as **color**, **size**, and **material**, making it easier to describe the variant.
|
|
81
|
+
*
|
|
82
|
+
* ---
|
|
83
|
+
*
|
|
84
|
+
* ### 📥 Parameters
|
|
85
|
+
*
|
|
86
|
+
* | Parameter | Type | Required | Description |
|
|
87
|
+
* |---------------------|----------|----------|-----------------------------------------------------------------------------|
|
|
88
|
+
* | `productIdentifier` | `string` | ✅ Yes | The unique identifier of the product variant (e.g., SKU, ID, external ID). |
|
|
89
|
+
* | `productIdType` | `string` | ✅ Yes | The type of the identifier: `"sku"`, `"id"`, or `"externalId"`. |
|
|
90
|
+
* | `locale` | `string` | ❌ No | The locale for localized data (e.g., `"en-US"`, `"fr-FR"`). Defaults to the system locale. |
|
|
91
|
+
*
|
|
92
|
+
* ---
|
|
93
|
+
*
|
|
94
|
+
* ### 📤 Returns
|
|
95
|
+
* **Type:** `Promise<GetProductVariantAttributesResponse>`
|
|
96
|
+
* Resolves with the following structure:
|
|
97
|
+
*
|
|
98
|
+
* ```typescript
|
|
99
|
+
* {
|
|
100
|
+
* attributes: Array<{
|
|
101
|
+
* id: string;
|
|
102
|
+
* name: string;
|
|
103
|
+
* value: string | number;
|
|
104
|
+
* type: string;
|
|
105
|
+
* isRequired: boolean;
|
|
106
|
+
* description: string;
|
|
107
|
+
* }>;
|
|
108
|
+
* locale: string;
|
|
109
|
+
* productIdentifier: string;
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* ---
|
|
114
|
+
*
|
|
115
|
+
* ### 🧑💻 Example Usage
|
|
116
|
+
*
|
|
117
|
+
* **Basic Example:**
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const attributes = await getProductVariantAttributes({
|
|
120
|
+
* productIdentifier: 'sku123',
|
|
121
|
+
* productIdType: 'sku',
|
|
122
|
+
* locale: 'en-US',
|
|
123
|
+
* });
|
|
124
|
+
* console.log(attributes);
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* **Alternative Locale:**
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const attributes = await getProductVariantAttributes({
|
|
130
|
+
* productIdentifier: 'prod789',
|
|
131
|
+
* productIdType: 'externalId',
|
|
132
|
+
* locale: 'fr-FR',
|
|
133
|
+
* });
|
|
134
|
+
* console.log(attributes);
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* ---
|
|
138
|
+
*
|
|
139
|
+
* ### 📝 Example Input
|
|
140
|
+
* ```json
|
|
141
|
+
* {
|
|
142
|
+
* "productIdentifier": "sku123",
|
|
143
|
+
* "productIdType": "sku",
|
|
144
|
+
* "locale": "en-US"
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* ---
|
|
149
|
+
*
|
|
150
|
+
* ### 📦 Example Output
|
|
151
|
+
* ```json
|
|
152
|
+
* {
|
|
153
|
+
* "attributes": [
|
|
154
|
+
* {
|
|
155
|
+
* "id": "attr1",
|
|
156
|
+
* "name": "Color",
|
|
157
|
+
* "value": "Red",
|
|
158
|
+
* "type": "text",
|
|
159
|
+
* "isRequired": true,
|
|
160
|
+
* "description": "The color of the product variant."
|
|
161
|
+
* },
|
|
162
|
+
* {
|
|
163
|
+
* "id": "attr2",
|
|
164
|
+
* "name": "Size",
|
|
165
|
+
* "value": "M",
|
|
166
|
+
* "type": "text",
|
|
167
|
+
* "isRequired": false,
|
|
168
|
+
* "description": "The size of the product variant."
|
|
169
|
+
* }
|
|
170
|
+
* ],
|
|
171
|
+
* "locale": "en-US",
|
|
172
|
+
* "productIdentifier": "sku123"
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* ---
|
|
177
|
+
*
|
|
178
|
+
* ### 🚨 Error Responses
|
|
179
|
+
*
|
|
180
|
+
* | Code | Message | Description |
|
|
181
|
+
* |-------|------------------------------------------|------------------------------------------------------|
|
|
182
|
+
* | `400` | `Bad Request` | Missing or invalid `productIdentifier` or `productIdType`. |
|
|
183
|
+
* | `404` | `Not Found` | The specified product variant does not exist. |
|
|
184
|
+
* | `500` | `Internal Server Error` | Unexpected error on the server. |
|
|
185
|
+
*
|
|
186
|
+
* ---
|
|
187
|
+
*
|
|
188
|
+
* ### 📚 Notes
|
|
189
|
+
* - Ensure the `productIdType` matches the `productIdentifier` value to avoid mismatched requests.
|
|
190
|
+
* - Providing a valid `locale` is recommended for fetching localized attribute data when applicable.
|
|
191
|
+
* - This API version supports strict versioning; ensure compatibility with your application's requirements.
|
|
192
|
+
*
|
|
193
|
+
* ---
|
|
194
|
+
*
|
|
195
|
+
* ### 🔗 Additional Resources
|
|
196
|
+
* - [API Authentication Guide](https://docs.example.com/api-authentication)
|
|
197
|
+
* - [Product Variants Documentation](https://docs.example.com/product-variants)
|
|
198
|
+
* - [Common Error Codes](https://docs.example.com/error-codes)
|
|
199
|
+
*/
|
|
200
|
+
export declare function getProductVariantAttributes({ productIdentifier, productIdType, locale, }: GetProductVariantAttributesParameters): Promise<GetProductVariantAttributesResponse>;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProductVariantsList = getProductVariantsList;
|
|
4
|
+
exports.getProductVariantSuppliers = getProductVariantSuppliers;
|
|
5
|
+
exports.getProductVariantAttributes = getProductVariantAttributes;
|
|
6
|
+
const parameters_validation_1 = require("../../helpers/parameters-validation");
|
|
7
|
+
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
8
|
+
/**
|
|
9
|
+
* APICODE(pVAR300)
|
|
10
|
+
* Retrieves a paginated list of product variants.
|
|
11
|
+
*
|
|
12
|
+
* This function fetches a list of product variants associated with a specific product SKU.
|
|
13
|
+
*
|
|
14
|
+
* @param {GetProductVariantsListParameters} params - The parameters to filter the product variants list, including:
|
|
15
|
+
* #### productSku - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
16
|
+
* The SKU of the product to fetch variants for.
|
|
17
|
+
*
|
|
18
|
+
* #### locale - `string` | optional
|
|
19
|
+
* The locale for the product variants.
|
|
20
|
+
*
|
|
21
|
+
* #### pageable - `object` | optional
|
|
22
|
+
* Pagination details, including:
|
|
23
|
+
* - `page`: The page number.
|
|
24
|
+
* - `size`: The number of items per page.
|
|
25
|
+
* - `sort`: Sorting criteria.
|
|
26
|
+
*
|
|
27
|
+
* @returns {Promise<GetProductVariantsListResponse>} - A promise that resolves with the paginated list of product variants.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* #### input
|
|
31
|
+
* ```typescript
|
|
32
|
+
* await getProductVariantsList({
|
|
33
|
+
* productSku: 'product123',
|
|
34
|
+
* locale: 'en-US',
|
|
35
|
+
* pageable: { page: 1, size: 10, sort: 'name,asc' },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
* #### output
|
|
39
|
+
* ```json
|
|
40
|
+
* {
|
|
41
|
+
* "content": [
|
|
42
|
+
* { "id": "variant1", "name": "Variant 1" },
|
|
43
|
+
* { "id": "variant2", "name": "Variant 2" }
|
|
44
|
+
* ],
|
|
45
|
+
* "pageable": {
|
|
46
|
+
* "page": 1,
|
|
47
|
+
* "size": 10,
|
|
48
|
+
* "totalPages": 5
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async function getProductVariantsList({ productSku, locale, pageable, }) {
|
|
54
|
+
(0, parameters_validation_1.required)({ productSku });
|
|
55
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
56
|
+
method: "GET",
|
|
57
|
+
path: `/v1/shop/product-variants`,
|
|
58
|
+
params: {
|
|
59
|
+
productSku,
|
|
60
|
+
locale,
|
|
61
|
+
page: pageable === null || pageable === void 0 ? void 0 : pageable.page,
|
|
62
|
+
size: pageable === null || pageable === void 0 ? void 0 : pageable.size,
|
|
63
|
+
sort: pageable === null || pageable === void 0 ? void 0 : pageable.sort,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* APICODE(vSUP300)
|
|
70
|
+
* Retrieves suppliers of a specific product variant.
|
|
71
|
+
*
|
|
72
|
+
* This function fetches a list of suppliers associated with a product variant.
|
|
73
|
+
*
|
|
74
|
+
* @param {GetProductVariantSuppliersParameters} params - The parameters to identify the product variant, including:
|
|
75
|
+
* #### productVariantId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
76
|
+
* The ID of the product variant to fetch suppliers for.
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<GetProductVariantSuppliersResponse>} - A promise that resolves with the suppliers of the product variant.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* #### input
|
|
82
|
+
* ```typescript
|
|
83
|
+
* await getProductVariantSuppliers({ productVariantId: 'variant123' });
|
|
84
|
+
* ```
|
|
85
|
+
* #### output
|
|
86
|
+
* ```json
|
|
87
|
+
* {
|
|
88
|
+
* "suppliers": [
|
|
89
|
+
* { "id": "supplier1", "name": "Supplier 1" },
|
|
90
|
+
* { "id": "supplier2", "name": "Supplier 2" }
|
|
91
|
+
* ]
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
async function getProductVariantSuppliers({ productVariantId, }) {
|
|
96
|
+
(0, parameters_validation_1.required)({ productVariantId });
|
|
97
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
98
|
+
method: "GET",
|
|
99
|
+
path: `/v1/shop/product-variants/${productVariantId}/suppliers`,
|
|
100
|
+
});
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* ## 🛒 APICODE(vATT300) - Fetch Product Variant Attributes
|
|
105
|
+
*
|
|
106
|
+
* Retrieves detailed attributes of a product variant identified by SKU, ID, or external ID.
|
|
107
|
+
* This metadata includes key details such as **color**, **size**, and **material**, making it easier to describe the variant.
|
|
108
|
+
*
|
|
109
|
+
* ---
|
|
110
|
+
*
|
|
111
|
+
* ### 📥 Parameters
|
|
112
|
+
*
|
|
113
|
+
* | Parameter | Type | Required | Description |
|
|
114
|
+
* |---------------------|----------|----------|-----------------------------------------------------------------------------|
|
|
115
|
+
* | `productIdentifier` | `string` | ✅ Yes | The unique identifier of the product variant (e.g., SKU, ID, external ID). |
|
|
116
|
+
* | `productIdType` | `string` | ✅ Yes | The type of the identifier: `"sku"`, `"id"`, or `"externalId"`. |
|
|
117
|
+
* | `locale` | `string` | ❌ No | The locale for localized data (e.g., `"en-US"`, `"fr-FR"`). Defaults to the system locale. |
|
|
118
|
+
*
|
|
119
|
+
* ---
|
|
120
|
+
*
|
|
121
|
+
* ### 📤 Returns
|
|
122
|
+
* **Type:** `Promise<GetProductVariantAttributesResponse>`
|
|
123
|
+
* Resolves with the following structure:
|
|
124
|
+
*
|
|
125
|
+
* ```typescript
|
|
126
|
+
* {
|
|
127
|
+
* attributes: Array<{
|
|
128
|
+
* id: string;
|
|
129
|
+
* name: string;
|
|
130
|
+
* value: string | number;
|
|
131
|
+
* type: string;
|
|
132
|
+
* isRequired: boolean;
|
|
133
|
+
* description: string;
|
|
134
|
+
* }>;
|
|
135
|
+
* locale: string;
|
|
136
|
+
* productIdentifier: string;
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* ---
|
|
141
|
+
*
|
|
142
|
+
* ### 🧑💻 Example Usage
|
|
143
|
+
*
|
|
144
|
+
* **Basic Example:**
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const attributes = await getProductVariantAttributes({
|
|
147
|
+
* productIdentifier: 'sku123',
|
|
148
|
+
* productIdType: 'sku',
|
|
149
|
+
* locale: 'en-US',
|
|
150
|
+
* });
|
|
151
|
+
* console.log(attributes);
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* **Alternative Locale:**
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const attributes = await getProductVariantAttributes({
|
|
157
|
+
* productIdentifier: 'prod789',
|
|
158
|
+
* productIdType: 'externalId',
|
|
159
|
+
* locale: 'fr-FR',
|
|
160
|
+
* });
|
|
161
|
+
* console.log(attributes);
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* ---
|
|
165
|
+
*
|
|
166
|
+
* ### 📝 Example Input
|
|
167
|
+
* ```json
|
|
168
|
+
* {
|
|
169
|
+
* "productIdentifier": "sku123",
|
|
170
|
+
* "productIdType": "sku",
|
|
171
|
+
* "locale": "en-US"
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* ---
|
|
176
|
+
*
|
|
177
|
+
* ### 📦 Example Output
|
|
178
|
+
* ```json
|
|
179
|
+
* {
|
|
180
|
+
* "attributes": [
|
|
181
|
+
* {
|
|
182
|
+
* "id": "attr1",
|
|
183
|
+
* "name": "Color",
|
|
184
|
+
* "value": "Red",
|
|
185
|
+
* "type": "text",
|
|
186
|
+
* "isRequired": true,
|
|
187
|
+
* "description": "The color of the product variant."
|
|
188
|
+
* },
|
|
189
|
+
* {
|
|
190
|
+
* "id": "attr2",
|
|
191
|
+
* "name": "Size",
|
|
192
|
+
* "value": "M",
|
|
193
|
+
* "type": "text",
|
|
194
|
+
* "isRequired": false,
|
|
195
|
+
* "description": "The size of the product variant."
|
|
196
|
+
* }
|
|
197
|
+
* ],
|
|
198
|
+
* "locale": "en-US",
|
|
199
|
+
* "productIdentifier": "sku123"
|
|
200
|
+
* }
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* ---
|
|
204
|
+
*
|
|
205
|
+
* ### 🚨 Error Responses
|
|
206
|
+
*
|
|
207
|
+
* | Code | Message | Description |
|
|
208
|
+
* |-------|------------------------------------------|------------------------------------------------------|
|
|
209
|
+
* | `400` | `Bad Request` | Missing or invalid `productIdentifier` or `productIdType`. |
|
|
210
|
+
* | `404` | `Not Found` | The specified product variant does not exist. |
|
|
211
|
+
* | `500` | `Internal Server Error` | Unexpected error on the server. |
|
|
212
|
+
*
|
|
213
|
+
* ---
|
|
214
|
+
*
|
|
215
|
+
* ### 📚 Notes
|
|
216
|
+
* - Ensure the `productIdType` matches the `productIdentifier` value to avoid mismatched requests.
|
|
217
|
+
* - Providing a valid `locale` is recommended for fetching localized attribute data when applicable.
|
|
218
|
+
* - This API version supports strict versioning; ensure compatibility with your application's requirements.
|
|
219
|
+
*
|
|
220
|
+
* ---
|
|
221
|
+
*
|
|
222
|
+
* ### 🔗 Additional Resources
|
|
223
|
+
* - [API Authentication Guide](https://docs.example.com/api-authentication)
|
|
224
|
+
* - [Product Variants Documentation](https://docs.example.com/product-variants)
|
|
225
|
+
* - [Common Error Codes](https://docs.example.com/error-codes)
|
|
226
|
+
*/
|
|
227
|
+
async function getProductVariantAttributes({ productIdentifier, productIdType, locale, }) {
|
|
228
|
+
(0, parameters_validation_1.required)({ productIdentifier, productIdType });
|
|
229
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
230
|
+
method: "GET",
|
|
231
|
+
path: `/v1/shop/products/${productIdentifier}/variant-attributes`,
|
|
232
|
+
params: {
|
|
233
|
+
productIdType,
|
|
234
|
+
locale,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
return data;
|
|
238
|
+
}
|