@djust-b2b/djust-front-sdk 1.15.0 → 1.16.0
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 +7 -7
- package/lib/services/auth/definitions.requests.d.ts +21 -0
- package/lib/services/auth/definitions.requests.js +2 -0
- package/lib/services/auth/index.d.ts +146 -120
- package/lib/services/auth/index.js +144 -119
- package/lib/services/cart/index.d.ts +185 -254
- package/lib/services/cart/index.js +198 -257
- package/lib/services/custom-field/index.d.ts +55 -100
- package/lib/services/custom-field/index.js +55 -105
- package/lib/services/customer-user/index.d.ts +107 -125
- package/lib/services/customer-user/index.js +107 -125
- package/lib/services/navigation-category/index.d.ts +68 -119
- package/lib/services/navigation-category/index.js +68 -119
- package/lib/services/product/index.d.ts +296 -1687
- package/lib/services/product/index.js +312 -1706
- package/lib/services/product-variant/index.d.ts +53 -160
- package/lib/services/product-variant/index.js +53 -160
- package/package.json +1 -1
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @packageDocumentation
|
|
4
|
-
*
|
|
5
|
-
* @document documents/cart.md
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.deleteCarts = deleteCarts;
|
|
9
4
|
exports.getCarts = getCarts;
|
|
@@ -22,31 +17,21 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
|
22
17
|
* CART ENDPOINT
|
|
23
18
|
*/
|
|
24
19
|
/**
|
|
25
|
-
*
|
|
26
|
-
* Deletes all carts associated with the user.
|
|
20
|
+
* 🛒 Deletes all carts associated with the user.
|
|
27
21
|
*
|
|
28
22
|
* This function sends a request to delete all carts of the logged-in user.
|
|
29
23
|
*
|
|
30
|
-
*
|
|
24
|
+
* 🛠 **Endpoint**: `DELETE /v2/shop/carts [cART135]`
|
|
31
25
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
26
|
+
* 📤 **Returns**:
|
|
27
|
+
* A `Promise` resolving to an array of `DeleteCartsResponse` objects, containing the details of the deleted carts.
|
|
28
|
+
*
|
|
29
|
+
* 🛠 **Example usage**:
|
|
30
|
+
* ```ts
|
|
35
31
|
* const deletedCarts = await deleteCarts();
|
|
36
32
|
* ```
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* [
|
|
40
|
-
* {
|
|
41
|
-
* "id": "cart1",
|
|
42
|
-
* "detail": "Deleted successfully"
|
|
43
|
-
* },
|
|
44
|
-
* {
|
|
45
|
-
* "id": "cart2",
|
|
46
|
-
* "detail": "Deleted successfully"
|
|
47
|
-
* }
|
|
48
|
-
* ]
|
|
49
|
-
* ```
|
|
33
|
+
*
|
|
34
|
+
* @returns {Promise<DeleteCartsResponse>} - An array of objects containing the details of the deleted carts.
|
|
50
35
|
*/
|
|
51
36
|
async function deleteCarts() {
|
|
52
37
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
@@ -56,50 +41,34 @@ async function deleteCarts() {
|
|
|
56
41
|
return data;
|
|
57
42
|
}
|
|
58
43
|
/**
|
|
59
|
-
*
|
|
60
|
-
* Retrieves all active carts of the logged-in user.
|
|
44
|
+
* 🛒 Retrieves all active carts of the logged-in user.
|
|
61
45
|
*
|
|
62
46
|
* This function allows fetching the list of active carts based on the provided parameters.
|
|
63
47
|
*
|
|
64
|
-
*
|
|
65
|
-
* #### currency - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
48
|
+
* 🛠 **Endpoint**: `GET /v2/shop/carts [cART550]`
|
|
66
49
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
50
|
+
* | Parameter | Type | Required | Description |
|
|
51
|
+
* |------------------|----------------------|------------|------------------------------------------------------------|
|
|
52
|
+
* | `currency` | `string` | ✅ | The currency in which to display the carts. |
|
|
53
|
+
* | `pageable` | `object` | ✅ | The pagination parameters. |
|
|
54
|
+
* | `status` | `string[]` | ❌ | The status of the carts to retrieve. |
|
|
55
|
+
* | `type` | `string[]` | ❌ | The type of carts to retrieve. |
|
|
69
56
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
57
|
+
* 📤 **Returns**:
|
|
58
|
+
* A `Promise` resolving to a `GetCartsResponse` object, containing the list of carts and pagination information.
|
|
72
59
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
60
|
+
* 🛠 **Example usage**:
|
|
61
|
+
* ```ts
|
|
62
|
+
* const carts = await getCarts({ currency: 'USD', pageable: { page: 1, size: 10 } });
|
|
63
|
+
* ```
|
|
75
64
|
*
|
|
76
|
-
* The
|
|
65
|
+
* @param {GetCartsParameters} params - The parameters for retrieving the carts, including:
|
|
66
|
+
* - `currency` - The currency in which to display the carts.
|
|
67
|
+
* - `pageable` - The pagination parameters.
|
|
68
|
+
* - `status` - The status of the carts to retrieve.
|
|
69
|
+
* - `type` - The type of carts to retrieve.
|
|
77
70
|
*
|
|
78
71
|
* @returns {Promise<GetCartsResponse>} - An object containing the list of carts and pagination information.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* #### input
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const carts = await getCarts({ currency: 'USD', pageable: { page: 1, size: 10 } });
|
|
84
|
-
* ```
|
|
85
|
-
* #### output
|
|
86
|
-
* ```json
|
|
87
|
-
* {
|
|
88
|
-
* carts: [
|
|
89
|
-
* {
|
|
90
|
-
* id: 'cart1',
|
|
91
|
-
* name: 'My Cart'
|
|
92
|
-
* },
|
|
93
|
-
* {
|
|
94
|
-
* id: 'cart2',
|
|
95
|
-
* name: 'Another Cart'
|
|
96
|
-
* }
|
|
97
|
-
* ],
|
|
98
|
-
* page: 1,
|
|
99
|
-
* size: 10,
|
|
100
|
-
* totalElement: 2
|
|
101
|
-
* }
|
|
102
|
-
* ```
|
|
103
72
|
*/
|
|
104
73
|
async function getCarts(params) {
|
|
105
74
|
const { currency, pageable, status, type } = params;
|
|
@@ -117,32 +86,33 @@ async function getCarts(params) {
|
|
|
117
86
|
return data;
|
|
118
87
|
}
|
|
119
88
|
/**
|
|
120
|
-
*
|
|
121
|
-
* Creates a new cart.
|
|
89
|
+
* 🛒 Creates a new cart.
|
|
122
90
|
*
|
|
123
91
|
* This function sends a request to create a new cart with the specified name.
|
|
124
92
|
*
|
|
125
|
-
*
|
|
126
|
-
* #### name - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
93
|
+
* 🛠 **Endpoint**: `POST /v2/shop/carts [cART100]`
|
|
127
94
|
*
|
|
128
|
-
*
|
|
95
|
+
* | Parameter | Type | Required | Description |
|
|
96
|
+
* |------------|----------|------------|---------------------------------|
|
|
97
|
+
* | `name` | `string` | ✅ | The name of the cart to create. |
|
|
129
98
|
*
|
|
130
|
-
*
|
|
99
|
+
* 📤 **Returns**:
|
|
100
|
+
* A `Promise` resolving to a `GetCartResponse` object, confirming the creation of the cart.
|
|
131
101
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* ```typescript
|
|
102
|
+
* 🛠 **Example usage**:
|
|
103
|
+
* ```ts
|
|
135
104
|
* await createCart({ name: 'New Cart' });
|
|
136
105
|
* ```
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* }
|
|
142
|
-
* ```
|
|
106
|
+
*
|
|
107
|
+
* @param {CreateCartParameters} params - The parameters for creating the cart:
|
|
108
|
+
* - `name` - The name of the cart to create.
|
|
109
|
+
*
|
|
110
|
+
* @returns {Promise<GetCartResponse>} - A promise that resolves when the cart is created.
|
|
143
111
|
*/
|
|
144
112
|
async function createCart(params) {
|
|
145
113
|
const { name } = params;
|
|
114
|
+
// Ensure required parameter is present
|
|
115
|
+
(0, parameters_validation_1.required)({ name });
|
|
146
116
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
147
117
|
method: "POST",
|
|
148
118
|
path: `/v2/shop/carts`,
|
|
@@ -151,79 +121,69 @@ async function createCart(params) {
|
|
|
151
121
|
return data;
|
|
152
122
|
}
|
|
153
123
|
/**
|
|
154
|
-
*
|
|
155
|
-
* Deletes a specific cart.
|
|
124
|
+
* 🗑️ Deletes a specific cart.
|
|
156
125
|
*
|
|
157
126
|
* This function sends a request to delete the cart identified by its ID.
|
|
158
127
|
*
|
|
159
|
-
*
|
|
160
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
128
|
+
* 🛠 **Endpoint**: `DELETE /v2/shop/carts/{cartId} [cART300]`
|
|
161
129
|
*
|
|
162
|
-
*
|
|
130
|
+
* | Parameter | Type | Required | Description |
|
|
131
|
+
* |------------|----------|------------|----------------------------------|
|
|
132
|
+
* | `cartId` | `string` | ✅ | The ID of the cart to delete. |
|
|
163
133
|
*
|
|
164
|
-
*
|
|
134
|
+
* 📤 **Returns**:
|
|
135
|
+
* A `Promise<void>` that resolves when the cart is successfully deleted.
|
|
165
136
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* ```typescript
|
|
137
|
+
* 🛠 **Example usage**:
|
|
138
|
+
* ```ts
|
|
169
139
|
* await deleteCart({ cartId: 'cart1' });
|
|
170
140
|
* ```
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* }
|
|
176
|
-
* ```
|
|
141
|
+
*
|
|
142
|
+
* @param {DeleteCartParameters} params - The parameters to identify the cart to delete:
|
|
143
|
+
* - `cartId` - The ID of the cart to delete.
|
|
144
|
+
*
|
|
145
|
+
* @returns {Promise<void>} - A promise that resolves when the cart is deleted.
|
|
177
146
|
*/
|
|
178
147
|
async function deleteCart(params) {
|
|
179
148
|
const { cartId } = params;
|
|
149
|
+
// Ensure required parameter is present
|
|
180
150
|
(0, parameters_validation_1.required)({ cartId });
|
|
181
|
-
(0, fetch_instance_1.enhancedFetch)({
|
|
151
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
182
152
|
method: "DELETE",
|
|
183
153
|
path: `/v2/shop/carts/${cartId}`,
|
|
184
154
|
});
|
|
185
155
|
}
|
|
186
156
|
/**
|
|
187
|
-
*
|
|
188
|
-
* Retrieves the details of a specific cart.
|
|
157
|
+
* 🛒 Retrieves the details of a specific cart.
|
|
189
158
|
*
|
|
190
159
|
* This function allows fetching the information of a cart based on its ID.
|
|
191
160
|
*
|
|
192
|
-
*
|
|
193
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
161
|
+
* 🛠 **Endpoint**: `GET /v2/shop/carts/{cartId} [cART500]`
|
|
194
162
|
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
163
|
+
* | Parameter | Type | Required | Description |
|
|
164
|
+
* |-----------------|-----------|------------|-------------------------------------------------|
|
|
165
|
+
* | `cartId` | `string` | ✅ | The ID of the cart to retrieve. |
|
|
166
|
+
* | `currency` | `string` | ✅ | The currency in which to display the cart. |
|
|
167
|
+
* | `nbFirstLines` | `number[]`| ❌ | The number of lines to retrieve. |
|
|
197
168
|
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
169
|
+
* 📤 **Returns**:
|
|
170
|
+
* A `Promise<GetCartResponse>` containing the details of the requested cart.
|
|
200
171
|
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @returns {Promise<GetCartResponse>} - An object containing the details of the cart.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* #### input
|
|
207
|
-
* ```typescript
|
|
172
|
+
* 🛠 **Example usage**:
|
|
173
|
+
* ```ts
|
|
208
174
|
* const cartDetails = await getCart({ cartId: 'cart1', currency: 'USD' });
|
|
209
175
|
* ```
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* {
|
|
218
|
-
* "productName": "Product A",
|
|
219
|
-
* "quantity": 2
|
|
220
|
-
* }
|
|
221
|
-
* ]
|
|
222
|
-
* }
|
|
223
|
-
* ```
|
|
176
|
+
*
|
|
177
|
+
* @param {GetCartParameters} params - The parameters for identifying the cart:
|
|
178
|
+
* - `cartId` - The ID of the cart to retrieve.
|
|
179
|
+
* - `currency` - The currency in which to display the cart.
|
|
180
|
+
* - `nbFirstLines` - (Optional) The number of lines to retrieve.
|
|
181
|
+
*
|
|
182
|
+
* @returns {Promise<GetCartResponse>} - A promise resolving to the cart details.
|
|
224
183
|
*/
|
|
225
184
|
async function getCart(params) {
|
|
226
185
|
const { cartId, currency, nbFirstLines } = params;
|
|
186
|
+
// Ensure required parameters are present
|
|
227
187
|
(0, parameters_validation_1.required)({ cartId, currency });
|
|
228
188
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
229
189
|
method: "GET",
|
|
@@ -236,35 +196,34 @@ async function getCart(params) {
|
|
|
236
196
|
return data;
|
|
237
197
|
}
|
|
238
198
|
/**
|
|
239
|
-
*
|
|
240
|
-
* Updates an existing cart.
|
|
199
|
+
* ✏️ Updates an existing cart.
|
|
241
200
|
*
|
|
242
201
|
* This function sends a request to update the name of a cart identified by its ID.
|
|
243
202
|
*
|
|
244
|
-
*
|
|
245
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
203
|
+
* 🛠 **Endpoint**: `PUT /v2/shop/carts/{cartId} [cART200]`
|
|
246
204
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
205
|
+
* | Parameter | Type | Required | Description |
|
|
206
|
+
* |------------|----------|------------|---------------------------------------|
|
|
207
|
+
* | `cartId` | `string` | ✅ | The ID of the cart to update. |
|
|
208
|
+
* | `name` | `string` | ✅ | The new name of the cart. |
|
|
249
209
|
*
|
|
250
|
-
*
|
|
210
|
+
* 📤 **Returns**:
|
|
211
|
+
* A `Promise<void>` that resolves when the cart is successfully updated.
|
|
251
212
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* #### input
|
|
256
|
-
* ```typescript
|
|
213
|
+
* 🛠 **Example usage**:
|
|
214
|
+
* ```ts
|
|
257
215
|
* await updateCart({ cartId: 'cart1', name: 'Updated Cart Name' });
|
|
258
216
|
* ```
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
217
|
+
*
|
|
218
|
+
* @param {UpdateCartParameters} params - The parameters for updating the cart:
|
|
219
|
+
* - `cartId` - The ID of the cart to update.
|
|
220
|
+
* - `name` - The new name of the cart.
|
|
221
|
+
*
|
|
222
|
+
* @returns {Promise<void>} - A promise that resolves when the update is successful.
|
|
265
223
|
*/
|
|
266
224
|
async function updateCart(params) {
|
|
267
225
|
const { cartId, name } = params;
|
|
226
|
+
// Ensure required parameters are present
|
|
268
227
|
(0, parameters_validation_1.required)({ cartId, name });
|
|
269
228
|
(0, fetch_instance_1.enhancedFetch)({
|
|
270
229
|
method: "PUT",
|
|
@@ -273,32 +232,32 @@ async function updateCart(params) {
|
|
|
273
232
|
});
|
|
274
233
|
}
|
|
275
234
|
/**
|
|
276
|
-
*
|
|
277
|
-
* Initializes orders from a cart.
|
|
235
|
+
* 🛒 Initializes orders from a cart.
|
|
278
236
|
*
|
|
279
237
|
* This function sends a request to initialize an order from a specified cart.
|
|
280
238
|
*
|
|
281
|
-
*
|
|
282
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
239
|
+
* 🛠 **Endpoint**: `POST /v2/shop/carts/{cartId}/initialize-orders [cART101]`
|
|
283
240
|
*
|
|
284
|
-
*
|
|
241
|
+
* | Parameter | Type | Required | Description |
|
|
242
|
+
* |------------|----------|------------|------------------------------------------|
|
|
243
|
+
* | `cartId` | `string` | ✅ | The ID of the cart to initialize orders. |
|
|
285
244
|
*
|
|
286
|
-
*
|
|
245
|
+
* 📤 **Returns**:
|
|
246
|
+
* A `Promise<string>` containing the business ID of the created order.
|
|
287
247
|
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* ```typescript
|
|
248
|
+
* 🛠 **Example usage**:
|
|
249
|
+
* ```ts
|
|
291
250
|
* const orderId = await initializeOrdersFromCart({ cartId: 'cart1' });
|
|
292
251
|
* ```
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* }
|
|
298
|
-
* ```
|
|
252
|
+
*
|
|
253
|
+
* @param {InitializeOrdersFromCartParameters} params - Parameters for initializing orders:
|
|
254
|
+
* - `cartId` - The ID of the cart to initialize orders from.
|
|
255
|
+
*
|
|
256
|
+
* @returns {Promise<string>} - The business ID of the created order.
|
|
299
257
|
*/
|
|
300
258
|
async function initializeOrdersFromCart(params) {
|
|
301
259
|
const { cartId } = params;
|
|
260
|
+
// Ensure required parameters are present
|
|
302
261
|
(0, parameters_validation_1.required)({ cartId });
|
|
303
262
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
304
263
|
method: "POST",
|
|
@@ -307,39 +266,38 @@ async function initializeOrdersFromCart(params) {
|
|
|
307
266
|
return data;
|
|
308
267
|
}
|
|
309
268
|
/**
|
|
310
|
-
*
|
|
311
|
-
*/
|
|
312
|
-
/**
|
|
313
|
-
* APICODE(cART350)
|
|
314
|
-
* Deletes lines from a cart.
|
|
269
|
+
* 🗑️ Deletes lines from a cart.
|
|
315
270
|
*
|
|
316
271
|
* This function sends a request to delete specific lines from a cart.
|
|
317
272
|
*
|
|
318
|
-
*
|
|
319
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
273
|
+
* 🛠 **Endpoint**: `DELETE /v2/shop/carts/{cartId}/lines [cART350]`
|
|
320
274
|
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
275
|
+
* | Parameter | Type | Required | Description |
|
|
276
|
+
* |--------------------|------------|------------|--------------------------------------|
|
|
277
|
+
* | `cartId` | `string` | ✅ | The ID of the cart. |
|
|
278
|
+
* | `lineIdsToDelete` | `string[]` | ✅ | The IDs of the lines to delete. |
|
|
323
279
|
*
|
|
324
|
-
*
|
|
280
|
+
* 📤 **Returns**:
|
|
281
|
+
* A `Promise<DeleteCartLinesResponse>` containing details about the deleted lines.
|
|
325
282
|
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* ```
|
|
333
|
-
* #### output
|
|
334
|
-
* ```json
|
|
335
|
-
* {
|
|
336
|
-
* "singleWarningReportDto": []
|
|
337
|
-
* }
|
|
283
|
+
* 🛠 **Example usage**:
|
|
284
|
+
* ```ts
|
|
285
|
+
* const response = await deleteCartLines({
|
|
286
|
+
* cartId: 'cart1',
|
|
287
|
+
* lineIdsToDelete: ['line1', 'line2']
|
|
288
|
+
* });
|
|
338
289
|
* ```
|
|
290
|
+
*
|
|
291
|
+
* @param {DeleteCartLinesParameters} params - Parameters for deleting cart lines:
|
|
292
|
+
* - `cartId` - The ID of the cart.
|
|
293
|
+
* - `lineIdsToDelete` - The IDs of the lines to delete.
|
|
294
|
+
*
|
|
295
|
+
* @returns {Promise<DeleteCartLinesResponse>} - Response with details about the deleted lines.
|
|
339
296
|
*/
|
|
340
297
|
async function deleteCartLines(params) {
|
|
341
298
|
const { cartId, lineIdsToDelete } = params;
|
|
342
|
-
|
|
299
|
+
// Ensure required parameters are present
|
|
300
|
+
(0, parameters_validation_1.required)({ cartId, lineIdsToDelete });
|
|
343
301
|
const body = lineIdsToDelete.map((lineId) => ({ offerPriceId: lineId }));
|
|
344
302
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
345
303
|
method: "DELETE",
|
|
@@ -349,64 +307,49 @@ async function deleteCartLines(params) {
|
|
|
349
307
|
return data;
|
|
350
308
|
}
|
|
351
309
|
/**
|
|
352
|
-
*
|
|
353
|
-
* Fetches the lines of a shopping cart based on the provided parameters.
|
|
310
|
+
* 📋 Fetches the lines of a shopping cart.
|
|
354
311
|
*
|
|
355
312
|
* This function retrieves detailed information about the items (lines) in a shopping cart.
|
|
356
313
|
* It supports filtering by supplier, product variant, or offer price and handles pagination.
|
|
357
314
|
*
|
|
358
|
-
*
|
|
359
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
360
|
-
*
|
|
361
|
-
* The ID of the cart.
|
|
362
|
-
* #### currency - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
363
|
-
*
|
|
364
|
-
* The currency in which prices should be returned (e.g., "USD").
|
|
365
|
-
* #### pageable - `object` | <strong style={{ color: 'red' }}>required</strong>
|
|
366
|
-
*
|
|
367
|
-
* Pagination details, such as page number and size.
|
|
368
|
-
* #### supplierId - `string[]`
|
|
315
|
+
* 🛠 **Endpoint**: `GET /v2/shop/carts/{cartId}/lines [cART551]`
|
|
369
316
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
317
|
+
* | Parameter | Type | Required | Description |
|
|
318
|
+
* |---------------------|------------|------------|------------------------------------------|
|
|
319
|
+
* | `cartId` | `string` | ✅ | The ID of the cart. |
|
|
320
|
+
* | `currency` | `string` | ✅ | The currency in which prices are shown. |
|
|
321
|
+
* | `pageable` | `object` | ✅ | Pagination details (page number, size). |
|
|
322
|
+
* | `supplierId` | `string[]` | ❌ | Filter by specific supplier IDs. |
|
|
323
|
+
* | `productVariantId` | `string[]` | ❌ | Filter by specific product variants. |
|
|
324
|
+
* | `offerPriceId` | `string[]` | ❌ | Filter by specific offer price IDs. |
|
|
372
325
|
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
326
|
+
* 📤 **Returns**:
|
|
327
|
+
* A `Promise<GetCartLinesResponse>` containing the lines of the cart.
|
|
375
328
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* @returns {Promise<GetCartLinesResponse>} - A promise resolving to the response containing cart lines information.
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* #### input
|
|
382
|
-
* ```typescript
|
|
329
|
+
* 🛠 **Example usage**:
|
|
330
|
+
* ```ts
|
|
383
331
|
* const cartLines = await getCartLines({
|
|
384
332
|
* cartId: 'cart1',
|
|
385
333
|
* currency: 'USD',
|
|
386
334
|
* pageable: { page: 1, size: 10 },
|
|
387
|
-
* supplierId: ['supplier1']
|
|
388
|
-
* productVariantId: ['variant1'],
|
|
389
|
-
* offerPriceId: ['offer1']
|
|
335
|
+
* supplierId: ['supplier1']
|
|
390
336
|
* });
|
|
391
337
|
* ```
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
* "totalItems": 1,
|
|
403
|
-
* "totalPages": 1
|
|
404
|
-
* }
|
|
405
|
-
* ```
|
|
338
|
+
*
|
|
339
|
+
* @param {GetCartLinesParameters} params - Parameters for fetching cart lines:
|
|
340
|
+
* - `cartId` - The ID of the cart.
|
|
341
|
+
* - `currency` - The currency for prices.
|
|
342
|
+
* - `pageable` - Pagination details.
|
|
343
|
+
* - `supplierId` (optional) - Supplier IDs for filtering.
|
|
344
|
+
* - `productVariantId` (optional) - Product variant IDs for filtering.
|
|
345
|
+
* - `offerPriceId` (optional) - Offer price IDs for filtering.
|
|
346
|
+
*
|
|
347
|
+
* @returns {Promise<GetCartLinesResponse>} - Response containing cart lines information.
|
|
406
348
|
*/
|
|
407
349
|
async function getCartLines(params) {
|
|
408
350
|
const { cartId, currency, pageable, supplierId, productVariantId, offerPriceId, } = params;
|
|
409
|
-
|
|
351
|
+
// Ensure required parameters are present
|
|
352
|
+
(0, parameters_validation_1.required)({ cartId, currency, pageable });
|
|
410
353
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
411
354
|
method: "GET",
|
|
412
355
|
path: `/v2/shop/carts/${cartId}/lines`,
|
|
@@ -421,40 +364,39 @@ async function getCartLines(params) {
|
|
|
421
364
|
return data;
|
|
422
365
|
}
|
|
423
366
|
/**
|
|
424
|
-
*
|
|
425
|
-
* Updates the lines of a cart.
|
|
367
|
+
* ✏️ Updates the lines of a cart.
|
|
426
368
|
*
|
|
427
|
-
* This function sends a request to update
|
|
369
|
+
* This function sends a request to update specific lines of a shopping cart.
|
|
428
370
|
*
|
|
429
|
-
*
|
|
430
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
371
|
+
* 🛠 **Endpoint**: `PUT /v2/shop/carts/{cartId}/lines [cART150]`
|
|
431
372
|
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
373
|
+
* | Parameter | Type | Required | Description |
|
|
374
|
+
* |-------------------|------------|------------|----------------------------------------|
|
|
375
|
+
* | `cartId` | `string` | ✅ | The ID of the cart. |
|
|
376
|
+
* | `linesToUpdate` | `object[]` | ✅ | Details of the lines to update. |
|
|
434
377
|
*
|
|
435
|
-
*
|
|
378
|
+
* 📤 **Returns**:
|
|
379
|
+
* A `Promise<UpdateCartLinesResponse>` containing the updated lines' information.
|
|
436
380
|
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* #### input
|
|
441
|
-
* ```typescript
|
|
381
|
+
* 🛠 **Example usage**:
|
|
382
|
+
* ```ts
|
|
442
383
|
* const response = await updateCartLines({
|
|
443
384
|
* cartId: 'cart1',
|
|
444
385
|
* linesToUpdate: [
|
|
445
386
|
* { offerPriceId: 'line1', quantity: 3, updateAction: 'update' }
|
|
446
|
-
* ]
|
|
387
|
+
* ]
|
|
447
388
|
* });
|
|
448
389
|
* ```
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
390
|
+
*
|
|
391
|
+
* @param {UpdateCartLinesParameters} params - Parameters for updating cart lines:
|
|
392
|
+
* - `cartId` - The ID of the cart.
|
|
393
|
+
* - `linesToUpdate` - Details of the lines to update.
|
|
394
|
+
*
|
|
395
|
+
* @returns {Promise<UpdateCartLinesResponse>} - Response with details about the updated lines.
|
|
455
396
|
*/
|
|
456
397
|
async function updateCartLines(params) {
|
|
457
398
|
const { cartId, linesToUpdate } = params;
|
|
399
|
+
// Ensure required parameters are present
|
|
458
400
|
(0, parameters_validation_1.required)({ cartId, linesToUpdate });
|
|
459
401
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
460
402
|
method: "PUT",
|
|
@@ -464,40 +406,39 @@ async function updateCartLines(params) {
|
|
|
464
406
|
return data;
|
|
465
407
|
}
|
|
466
408
|
/**
|
|
467
|
-
*
|
|
468
|
-
* Updates the lines of a cart by variant.
|
|
469
|
-
*
|
|
470
|
-
* This function sends a request to update the lines of a cart based on the product variant.
|
|
409
|
+
* ✏️ Updates the lines of a cart by variant.
|
|
471
410
|
*
|
|
472
|
-
*
|
|
473
|
-
* #### cartId - `string` | <strong style={{ color: 'red' }}>required</strong>
|
|
411
|
+
* This function sends a request to update cart lines based on product variants.
|
|
474
412
|
*
|
|
475
|
-
*
|
|
476
|
-
* #### linesToUpdate - `object[]` | <strong style={{ color: 'red' }}>required</strong>
|
|
413
|
+
* 🛠 **Endpoint**: `PUT /v2/shop/carts/{cartId}/lines-by-variant [cART151]`
|
|
477
414
|
*
|
|
478
|
-
*
|
|
415
|
+
* | Parameter | Type | Required | Description |
|
|
416
|
+
* |-------------------|------------|------------|----------------------------------------|
|
|
417
|
+
* | `cartId` | `string` | ✅ | The ID of the cart. |
|
|
418
|
+
* | `linesToUpdate` | `object[]` | ✅ | Details of the lines to update. |
|
|
479
419
|
*
|
|
480
|
-
*
|
|
420
|
+
* 📤 **Returns**:
|
|
421
|
+
* A `Promise<UpdateCartLinesByVariantResponse>` containing the updated lines' information.
|
|
481
422
|
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
* ```typescript
|
|
423
|
+
* 🛠 **Example usage**:
|
|
424
|
+
* ```ts
|
|
485
425
|
* const response = await updateCartLinesByVariant({
|
|
486
426
|
* cartId: 'cart1',
|
|
487
427
|
* linesToUpdate: [
|
|
488
428
|
* { offerPriceId: 'variant1', quantity: 2, updateAction: 'update' }
|
|
489
|
-
* ]
|
|
429
|
+
* ]
|
|
490
430
|
* });
|
|
491
431
|
* ```
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
432
|
+
*
|
|
433
|
+
* @param {UpdateCartLinesByVariantParameters} params - Parameters for updating cart lines by variant:
|
|
434
|
+
* - `cartId` - The ID of the cart.
|
|
435
|
+
* - `linesToUpdate` - Details of the lines to update.
|
|
436
|
+
*
|
|
437
|
+
* @returns {Promise<UpdateCartLinesByVariantResponse>} - Response with details about the updated lines by variant.
|
|
498
438
|
*/
|
|
499
439
|
async function updateCartLinesByVariant(params) {
|
|
500
440
|
const { cartId, linesToUpdate } = params;
|
|
441
|
+
// Ensure required parameters are present
|
|
501
442
|
(0, parameters_validation_1.required)({ cartId, linesToUpdate });
|
|
502
443
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
503
444
|
method: "PUT",
|