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