@djust-b2b/djust-front-sdk 2.1.1 β†’ 2.3.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.
@@ -48,7 +48,7 @@ export declare function getCustomerAccountV2(pageable: PageableParameters): Prom
48
48
  *
49
49
  * This function allows the creation of a new customer account with relevant details including addresses, user information, and custom fields.
50
50
  *
51
- * πŸ›  **Endpoint**: `POST /v1/shop/customer-accounts`
51
+ * πŸ›  **Endpoint**: `POST /v1/shop/customer-accounts` [ACCOUNT-100]
52
52
  *
53
53
  * | Parameter | Type | Required | Description |
54
54
  * |-----------------------------------|--------------------------------|----------|-------------|
@@ -58,82 +58,59 @@ export declare function getCustomerAccountV2(pageable: PageableParameters): Prom
58
58
  * | `customFieldValues` | `object[]` | βœ… | List of custom fields with their `customFieldId` and `customFieldValue`. |
59
59
  * | `customerTagList` | `string[]` | βœ… | List of customer tags. |
60
60
  * | `fromFO` | `boolean` | βœ… | Flag indicating if the account is created from the front-office (FO). |
61
- * | `legalUser` | `object[]` | βœ… | Information about the legal user including `birthday`, `countryOfResidence`, `email`, `firstName`, `lastName`, and `nationality`. |
62
-
61
+ * | `legalUser` | `object` | βœ… | Information about the legal user including `birthday`, `countryOfResidence`, `email`, `firstName`, `lastName`, and `nationality`. |
62
+ *
63
63
  * πŸ“€ **Returns**:
64
64
  * A `Promise<CreateCustomerAccountResponse>` containing the details of the created customer account.
65
65
  *
66
66
  * πŸ›  **Example usage**:
67
67
  * ```ts
68
68
  * const response = await createCustomerAccount({
69
- * createAddressRequests: [
70
- * {
71
- * additionalAddress: "string",
72
- * address: "string",
73
- * billing: true,
74
- * city: "string",
75
- * company: "string",
76
- * country: "string",
77
- * externalId: "string",
78
- * fullName: "string",
79
- * id: "string",
80
- * label: "string",
81
- * phone: "string",
82
- * shipping: true,
83
- * state: "string",
84
- * zipcode: "string"
85
- * }
86
- * ],
87
- * createCustomerUserRequest: {
88
- * civility: "MR",
89
- * email: "string",
90
- * customFieldValues: [
91
- * {
92
- * customFieldId: 'string',
93
- * customFieldValue: 'string'
94
- * }
95
- * ],
96
- * externalId: "string",
97
- * firstName: "string",
98
- * groups: ["group1", "group2"],
99
- * lastName: "string",
100
- * mainOrganisationsId: "orgId",
101
- * mainSubOrganisationsId: "subOrgId",
102
- * organisationsIds: ['orgId1', 'orgId2'],
103
- * password: "password123",
104
- * phone: "123456789",
105
- * subOrganisationsIds: ['subOrgId1', 'subOrgId2']
106
- * },
107
- * createObjectCustomerAccountRequest: {
108
- * accountManager: "string",
109
- * businessRegistrationNumber: "string",
110
- * companyRegistrationName: "string",
111
- * externalId: "string",
112
- * name: "string",
113
- * vatNumber: "string",
114
- * website: "string"
115
- * },
116
- * customFieldValues: [
117
- * {
118
- * customFieldId: "string",
119
- * customFieldValue: "value"
120
- * }
121
- * ],
122
- * customerTagList: ["tag1", "tag2"],
123
- * fromFO: true,
124
- * legalUser: [
125
- * {
126
- * birthday: "2024-12-11T09:46:27.656Z",
127
- * countryOfResidence: "FR",
128
- * email: "user@example.com",
129
- * firstName: "John",
130
- * id: "userId",
131
- * lastName: "Doe",
132
- * nationality: "FR"
133
- * }
134
- * ],
69
+ * createAddressRequests: [
70
+ * {
71
+ * address: "123 Main Street",
72
+ * city: "Paris",
73
+ * country: "FR",
74
+ * billing: true,
75
+ * shipping: true,
76
+ * fullName: "John Doe",
77
+ * zipcode: "75001"
78
+ * }
79
+ * ],
80
+ * createCustomerUserRequest: {
81
+ * email: "john.doe@example.com",
82
+ * firstName: "John",
83
+ * lastName: "Doe",
84
+ * password: "securePassword123",
85
+ * phone: "+33123456789"
86
+ * },
87
+ * createObjectCustomerAccountRequest: {
88
+ * name: "Acme Corporation",
89
+ * externalId: "acme-corp-001",
90
+ * vatNumber: "FR12345678901"
91
+ * },
92
+ * customFieldValues: [
93
+ * {
94
+ * customFieldId: "industry",
95
+ * customFieldValue: "technology"
96
+ * }
97
+ * ],
98
+ * customerTagList: ["premium", "enterprise"],
99
+ * fromFO: true,
100
+ * legalUser: {
101
+ * birthday: "1990-01-01T00:00:00.000Z",
102
+ * countryOfResidence: "FR",
103
+ * email: "john.doe@example.com",
104
+ * firstName: "John",
105
+ * lastName: "Doe",
106
+ * nationality: "FR"
107
+ * }
135
108
  * });
136
109
  * ```
110
+ *
111
+ * @param {CreateCustomerAccountParameters} params - The parameters for creating a customer account
112
+ * @throws {Error} If required parameters are missing
113
+ * @returns {Promise<CreateCustomerAccountResponse>} A promise resolving to the response containing the created customer account
137
114
  */
138
115
  export declare function createCustomerAccount({ createAddressRequests, createCustomerUserRequest, createObjectCustomerAccountRequest, customFieldValues, customerTagList, fromFO, legalUser, ...config }: CreateCustomerAccountParameters & DjustConfig): Promise<CreateCustomerAccountResponse>;
139
116
  /**
@@ -291,7 +268,7 @@ export declare function updateCustomerAccountAddress({ addressId, additionalAddr
291
268
  *
292
269
  * This function retrieves custom fields for a customer account.
293
270
  *
294
- * πŸ›  **Endpoint**: `GET /v1/shop/customer-accounts/custom-fields`
271
+ * πŸ›  **Endpoint**: `GET /v1/shop/customer-accounts/custom-fields` [ACCOUNT-554]
295
272
  *
296
273
  * | **Parameter** | **Type** | **Required** | **Description** |
297
274
  * |----------------------|------------|--------------|---------------------------------------------------------------------------|
@@ -88,7 +88,7 @@ async function getCustomerAccountV2(pageable) {
88
88
  *
89
89
  * This function allows the creation of a new customer account with relevant details including addresses, user information, and custom fields.
90
90
  *
91
- * πŸ›  **Endpoint**: `POST /v1/shop/customer-accounts`
91
+ * πŸ›  **Endpoint**: `POST /v1/shop/customer-accounts` [ACCOUNT-100]
92
92
  *
93
93
  * | Parameter | Type | Required | Description |
94
94
  * |-----------------------------------|--------------------------------|----------|-------------|
@@ -98,82 +98,59 @@ async function getCustomerAccountV2(pageable) {
98
98
  * | `customFieldValues` | `object[]` | βœ… | List of custom fields with their `customFieldId` and `customFieldValue`. |
99
99
  * | `customerTagList` | `string[]` | βœ… | List of customer tags. |
100
100
  * | `fromFO` | `boolean` | βœ… | Flag indicating if the account is created from the front-office (FO). |
101
- * | `legalUser` | `object[]` | βœ… | Information about the legal user including `birthday`, `countryOfResidence`, `email`, `firstName`, `lastName`, and `nationality`. |
102
-
101
+ * | `legalUser` | `object` | βœ… | Information about the legal user including `birthday`, `countryOfResidence`, `email`, `firstName`, `lastName`, and `nationality`. |
102
+ *
103
103
  * πŸ“€ **Returns**:
104
104
  * A `Promise<CreateCustomerAccountResponse>` containing the details of the created customer account.
105
105
  *
106
106
  * πŸ›  **Example usage**:
107
107
  * ```ts
108
108
  * const response = await createCustomerAccount({
109
- * createAddressRequests: [
110
- * {
111
- * additionalAddress: "string",
112
- * address: "string",
113
- * billing: true,
114
- * city: "string",
115
- * company: "string",
116
- * country: "string",
117
- * externalId: "string",
118
- * fullName: "string",
119
- * id: "string",
120
- * label: "string",
121
- * phone: "string",
122
- * shipping: true,
123
- * state: "string",
124
- * zipcode: "string"
125
- * }
126
- * ],
127
- * createCustomerUserRequest: {
128
- * civility: "MR",
129
- * email: "string",
130
- * customFieldValues: [
131
- * {
132
- * customFieldId: 'string',
133
- * customFieldValue: 'string'
134
- * }
135
- * ],
136
- * externalId: "string",
137
- * firstName: "string",
138
- * groups: ["group1", "group2"],
139
- * lastName: "string",
140
- * mainOrganisationsId: "orgId",
141
- * mainSubOrganisationsId: "subOrgId",
142
- * organisationsIds: ['orgId1', 'orgId2'],
143
- * password: "password123",
144
- * phone: "123456789",
145
- * subOrganisationsIds: ['subOrgId1', 'subOrgId2']
146
- * },
147
- * createObjectCustomerAccountRequest: {
148
- * accountManager: "string",
149
- * businessRegistrationNumber: "string",
150
- * companyRegistrationName: "string",
151
- * externalId: "string",
152
- * name: "string",
153
- * vatNumber: "string",
154
- * website: "string"
155
- * },
156
- * customFieldValues: [
157
- * {
158
- * customFieldId: "string",
159
- * customFieldValue: "value"
160
- * }
161
- * ],
162
- * customerTagList: ["tag1", "tag2"],
163
- * fromFO: true,
164
- * legalUser: [
165
- * {
166
- * birthday: "2024-12-11T09:46:27.656Z",
167
- * countryOfResidence: "FR",
168
- * email: "user@example.com",
169
- * firstName: "John",
170
- * id: "userId",
171
- * lastName: "Doe",
172
- * nationality: "FR"
173
- * }
174
- * ],
109
+ * createAddressRequests: [
110
+ * {
111
+ * address: "123 Main Street",
112
+ * city: "Paris",
113
+ * country: "FR",
114
+ * billing: true,
115
+ * shipping: true,
116
+ * fullName: "John Doe",
117
+ * zipcode: "75001"
118
+ * }
119
+ * ],
120
+ * createCustomerUserRequest: {
121
+ * email: "john.doe@example.com",
122
+ * firstName: "John",
123
+ * lastName: "Doe",
124
+ * password: "securePassword123",
125
+ * phone: "+33123456789"
126
+ * },
127
+ * createObjectCustomerAccountRequest: {
128
+ * name: "Acme Corporation",
129
+ * externalId: "acme-corp-001",
130
+ * vatNumber: "FR12345678901"
131
+ * },
132
+ * customFieldValues: [
133
+ * {
134
+ * customFieldId: "industry",
135
+ * customFieldValue: "technology"
136
+ * }
137
+ * ],
138
+ * customerTagList: ["premium", "enterprise"],
139
+ * fromFO: true,
140
+ * legalUser: {
141
+ * birthday: "1990-01-01T00:00:00.000Z",
142
+ * countryOfResidence: "FR",
143
+ * email: "john.doe@example.com",
144
+ * firstName: "John",
145
+ * lastName: "Doe",
146
+ * nationality: "FR"
147
+ * }
175
148
  * });
176
149
  * ```
150
+ *
151
+ * @param {CreateCustomerAccountParameters} params - The parameters for creating a customer account
152
+ * @throws {Error} If required parameters are missing
153
+ * @returns {Promise<CreateCustomerAccountResponse>} A promise resolving to the response containing the created customer account
177
154
  */
178
155
  async function createCustomerAccount({ createAddressRequests, createCustomerUserRequest, createObjectCustomerAccountRequest, customFieldValues, customerTagList, fromFO, legalUser, ...config }) {
179
156
  (0, parameters_validation_1.required)({
@@ -419,7 +396,7 @@ async function updateCustomerAccountAddress({ addressId, additionalAddress, addr
419
396
  *
420
397
  * This function retrieves custom fields for a customer account.
421
398
  *
422
- * πŸ›  **Endpoint**: `GET /v1/shop/customer-accounts/custom-fields`
399
+ * πŸ›  **Endpoint**: `GET /v1/shop/customer-accounts/custom-fields` [ACCOUNT-554]
423
400
  *
424
401
  * | **Parameter** | **Type** | **Required** | **Description** |
425
402
  * |----------------------|------------|--------------|---------------------------------------------------------------------------|
@@ -12,6 +12,7 @@ export interface getIncidentsParameters {
12
12
  page: number;
13
13
  size: number;
14
14
  sort: String[];
15
+ supplierIds?: String[];
15
16
  }
16
17
  export interface getIncidentParameters {
17
18
  incidentId: string;
@@ -4,7 +4,7 @@ import { getIncidentsParameters, getIncidentParameters, createOrderLogisticIncid
4
4
  *
5
5
  * This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, status, and sorting preferences.
6
6
  *
7
- * πŸ›  **Endpoint**: `GET /v1/shop/incidents [ORDER-559]`
7
+ * πŸ›  **Endpoint**: `GET /v1/shop/incidents`
8
8
  *
9
9
  * | Parameter | Type | Required | Description |
10
10
  * |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
@@ -221,3 +221,43 @@ export declare function createOrderLogisticIncidentThread({ logisticOrderId, inc
221
221
  * @returns {Promise<createIncidentResponse>} A promise that resolves to the created incident details.
222
222
  */
223
223
  export declare function createIncident({ customField, externalId, logisticOrderId, reasonCodes, idType, }: createIncidentParameters): Promise<createIncidentResponse>;
224
+ /**
225
+ * 🚚 Retrieves a list of incidents based on various filter criteria.
226
+ *
227
+ * This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, supplier IDs, status, and sorting preferences.
228
+ *
229
+ * πŸ›  **Endpoint**: `GET /v2/shop/incidents` [ORDER-559]
230
+ *
231
+ * | Parameter | Type | Required | Description |
232
+ * |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
233
+ * | `customerAccountIds` | `string[]` | ❌ | List of customer account IDs to filter incidents by. |
234
+ * | `linkedType` | `string` | βœ… | Type of entity linked to the incident (e.g., ORDER or ORDER_LINES). |
235
+ * | `ids` | `string[]` | ❌ | Specific incident IDs to retrieve. |
236
+ * | `status` | `IncidentStatus[]`| ❌ | List of statuses to filter incidents by (e.g., OPEN, ON_GOING, CLOSED). |
237
+ * | `idType` | `IncidentIdType` | ❌ | Type of ID used for filtering (e.g., DJUST_ID, EXTERNAL_ID). |
238
+ * | `page` | `number` | ❌ | Page number for paginated results (starting at 0). |
239
+ * | `size` | `number` | ❌ | Number of incidents per page. |
240
+ * | `sort` | `string[]` | ❌ | Sorting criteria in the format `field,(asc|desc)` (e.g., `status,desc`). |
241
+ * | `supplierIds` | `string[]` | ❌ | List of supplier IDs to filter incidents by. |
242
+ *
243
+ * πŸ“€ **Returns**:
244
+ * A `Promise<getIncidentsResponse>` containing a paginated list of incidents matching the filter criteria.
245
+ *
246
+ * πŸ›  **Example usage**:
247
+ * ```ts
248
+ * const incidents = await getIncidentsV2({
249
+ * customerAccountIds: ["acc123", "acc456"],
250
+ * linkedType: "ORDER",
251
+ * status: ["OPEN", "ON_GOING"],
252
+ * supplierIds: ["supplier1", "supplier2"],
253
+ * page: 0,
254
+ * size: 10,
255
+ * sort: ["createdAt,desc"],
256
+ * });
257
+ * ```
258
+ *
259
+ * @param {getIncidentsParameters} params - The parameters for filtering and retrieving incidents.
260
+ * @throws {Error} If the required `linkedType` is missing.
261
+ * @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
262
+ */
263
+ export declare function getIncidentsV2({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, supplierIds, }: getIncidentsParameters): Promise<getIncidentsResponse>;
@@ -6,6 +6,7 @@ exports.createOrderLogisticIncident = createOrderLogisticIncident;
6
6
  exports.createOrderLogisticLineIncident = createOrderLogisticLineIncident;
7
7
  exports.createOrderLogisticIncidentThread = createOrderLogisticIncidentThread;
8
8
  exports.createIncident = createIncident;
9
+ exports.getIncidentsV2 = getIncidentsV2;
9
10
  const parameters_validation_1 = require("../../helpers/parameters-validation");
10
11
  const fetch_instance_1 = require("../../settings/fetch-instance");
11
12
  /**
@@ -13,7 +14,7 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
13
14
  *
14
15
  * This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, status, and sorting preferences.
15
16
  *
16
- * πŸ›  **Endpoint**: `GET /v1/shop/incidents [ORDER-559]`
17
+ * πŸ›  **Endpoint**: `GET /v1/shop/incidents`
17
18
  *
18
19
  * | Parameter | Type | Required | Description |
19
20
  * |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
@@ -318,3 +319,61 @@ async function createIncident({ customField, externalId, logisticOrderId, reason
318
319
  });
319
320
  return data;
320
321
  }
322
+ /**
323
+ * 🚚 Retrieves a list of incidents based on various filter criteria.
324
+ *
325
+ * This function allows you to fetch incidents with detailed filtering options, such as customer account IDs, supplier IDs, status, and sorting preferences.
326
+ *
327
+ * πŸ›  **Endpoint**: `GET /v2/shop/incidents` [ORDER-559]
328
+ *
329
+ * | Parameter | Type | Required | Description |
330
+ * |-----------------------|--------------------|----------|-----------------------------------------------------------------------------|
331
+ * | `customerAccountIds` | `string[]` | ❌ | List of customer account IDs to filter incidents by. |
332
+ * | `linkedType` | `string` | βœ… | Type of entity linked to the incident (e.g., ORDER or ORDER_LINES). |
333
+ * | `ids` | `string[]` | ❌ | Specific incident IDs to retrieve. |
334
+ * | `status` | `IncidentStatus[]`| ❌ | List of statuses to filter incidents by (e.g., OPEN, ON_GOING, CLOSED). |
335
+ * | `idType` | `IncidentIdType` | ❌ | Type of ID used for filtering (e.g., DJUST_ID, EXTERNAL_ID). |
336
+ * | `page` | `number` | ❌ | Page number for paginated results (starting at 0). |
337
+ * | `size` | `number` | ❌ | Number of incidents per page. |
338
+ * | `sort` | `string[]` | ❌ | Sorting criteria in the format `field,(asc|desc)` (e.g., `status,desc`). |
339
+ * | `supplierIds` | `string[]` | ❌ | List of supplier IDs to filter incidents by. |
340
+ *
341
+ * πŸ“€ **Returns**:
342
+ * A `Promise<getIncidentsResponse>` containing a paginated list of incidents matching the filter criteria.
343
+ *
344
+ * πŸ›  **Example usage**:
345
+ * ```ts
346
+ * const incidents = await getIncidentsV2({
347
+ * customerAccountIds: ["acc123", "acc456"],
348
+ * linkedType: "ORDER",
349
+ * status: ["OPEN", "ON_GOING"],
350
+ * supplierIds: ["supplier1", "supplier2"],
351
+ * page: 0,
352
+ * size: 10,
353
+ * sort: ["createdAt,desc"],
354
+ * });
355
+ * ```
356
+ *
357
+ * @param {getIncidentsParameters} params - The parameters for filtering and retrieving incidents.
358
+ * @throws {Error} If the required `linkedType` is missing.
359
+ * @returns {Promise<getIncidentsResponse>} A promise that resolves to a response object containing the incidents.
360
+ */
361
+ async function getIncidentsV2({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, supplierIds, }) {
362
+ (0, parameters_validation_1.required)({ linkedType });
363
+ const { data } = await (0, fetch_instance_1.enhancedFetch)({
364
+ method: "GET",
365
+ path: `/v2/shop/incidents`,
366
+ params: {
367
+ customerAccountIds,
368
+ linkedType,
369
+ ids,
370
+ status,
371
+ idType,
372
+ page,
373
+ size,
374
+ sort,
375
+ supplierIds,
376
+ },
377
+ });
378
+ return data;
379
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Mocks centralisΓ©s pour les tests du module offer-prices
3
+ */
4
+ import { GetPaginatedOfferPricesParameters, GetOfferPricesResponse } from "../definitions";
5
+ import { OfferPrice } from "../../../interfaces/models/offer";
6
+ import { Order, PageableObject } from "../../../interfaces/models/common";
7
+ export declare const mockProductPrices: {
8
+ standard: {
9
+ itemPrice: number;
10
+ unitPrice: number;
11
+ itemPriceTTC: number;
12
+ unitPriceTTC: number;
13
+ };
14
+ discounted: {
15
+ itemPrice: number;
16
+ unitPrice: number;
17
+ itemPriceTTC: number;
18
+ unitPriceTTC: number;
19
+ };
20
+ };
21
+ export declare const mockPriceRanges: {
22
+ single: {
23
+ quantity: number;
24
+ price: {
25
+ itemPrice: number;
26
+ unitPrice: number;
27
+ itemPriceTTC: number;
28
+ unitPriceTTC: number;
29
+ };
30
+ discountPrice: {
31
+ itemPrice: number;
32
+ unitPrice: number;
33
+ itemPriceTTC: number;
34
+ unitPriceTTC: number;
35
+ };
36
+ }[];
37
+ multiple: {
38
+ quantity: number;
39
+ price: {
40
+ itemPrice: number;
41
+ unitPrice: number;
42
+ itemPriceTTC: number;
43
+ unitPriceTTC: number;
44
+ };
45
+ discountPrice: {
46
+ itemPrice: number;
47
+ unitPrice: number;
48
+ itemPriceTTC: number;
49
+ unitPriceTTC: number;
50
+ };
51
+ }[];
52
+ };
53
+ export declare const mockOfferPrices: OfferPrice[];
54
+ export declare const mockParameters: {
55
+ getPaginatedOfferPrices: {
56
+ valid: GetPaginatedOfferPricesParameters;
57
+ withPagination: GetPaginatedOfferPricesParameters;
58
+ withSorting: GetPaginatedOfferPricesParameters;
59
+ missingRequired: Partial<GetPaginatedOfferPricesParameters>;
60
+ };
61
+ };
62
+ export declare const mockPageableObject: PageableObject;
63
+ export declare const mockOrder: Order;
64
+ export declare const mockResponses: {
65
+ getPaginatedOfferPrices: {
66
+ success: {
67
+ data: GetOfferPricesResponse;
68
+ headers: Headers;
69
+ status: number;
70
+ };
71
+ empty: {
72
+ data: GetOfferPricesResponse;
73
+ headers: Headers;
74
+ status: number;
75
+ };
76
+ singleItem: {
77
+ data: GetOfferPricesResponse;
78
+ headers: Headers;
79
+ status: number;
80
+ };
81
+ };
82
+ };
83
+ export declare const mockErrors: {
84
+ networkError: Error;
85
+ unauthorized: Error;
86
+ badRequest: Error;
87
+ notFound: Error;
88
+ serverError: Error;
89
+ missingParameter: Error;
90
+ };
91
+ export declare const mockHttpErrors: {
92
+ 400: {
93
+ status: number;
94
+ message: string;
95
+ };
96
+ 401: {
97
+ status: number;
98
+ message: string;
99
+ };
100
+ 404: {
101
+ status: number;
102
+ message: string;
103
+ };
104
+ 500: {
105
+ status: number;
106
+ message: string;
107
+ };
108
+ };