@djust-b2b/djust-front-sdk 1.23.0 → 1.24.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
@@ -101,6 +101,9 @@ export declare const DjustSDK: {
101
101
  getCustomerUserAddresses({ shipping, billing, account, organisationIds, }: import("./interfaces").GetCustomerUserAddressesParameters): Promise<void>;
102
102
  getCustomerUserOrganisations(): Promise<import("./interfaces").GetCustomerUserOrganisationsResponse>;
103
103
  sendCustomerUserActivationRequest({ redirectUrl, token, }: import("./interfaces").SendCustomerUserActivationRequestParameters): Promise<void>;
104
+ updateSpecificCustomerUser({ userToUpdateId, civility, firstName, lastName, phone, groups, customFieldValues, }: import("./interfaces").UpdateSpecificCustomerUserParameters): Promise<void>;
105
+ removeAccountsFromCustomerUser({ userToUpdateId, idType, accountIds, }: import("./interfaces").RemoveAccountsFromCustomerUserParameters): Promise<void>;
106
+ addCustomerUserToAccounts({ userToUpdateId, idType, accountIds, }: import("./interfaces").AddCustomerUserToAccountsParameters): Promise<void>;
104
107
  getCustomerAccount(config?: import("./interfaces/models/common").DjustConfig): Promise<import("./interfaces").GetCustomerAccountResponse>;
105
108
  getCustomerAccountV2(pageable: import("./interfaces/models/common").PageableParameters): Promise<import("./interfaces").GetCustomerAccountResponseV2>;
106
109
  createCustomerAccount({ createAddressRequests, createCustomerUserRequest, createObjectCustomerAccountRequest, customFieldValues, customerTagList, fromFO, legalUser, ...config }: import("./interfaces").CreateCustomerAccountParameters & import("./interfaces/models/common").DjustConfig): Promise<import("./interfaces").CreateCustomerAccountResponse>;
@@ -4,6 +4,7 @@ import { Country } from "./common";
4
4
  import { CustomerUserWithoutAccountDto } from "./customer-user";
5
5
  import { PaymentType } from "./payment";
6
6
  export type CustomerAccountStatus = "ACTIVE" | "INACTIVE" | "WAITING_APPROBATION" | "APPROBATION_REFUSED";
7
+ export type AccountIdType = "DJUST_ID" | "EXTERNAL_ID";
7
8
  interface CustomerTagNameableDto {
8
9
  id: string;
9
10
  name: string;
@@ -2,6 +2,7 @@ import { CustomFieldValueRequest } from "../../interfaces/models/custom-field";
2
2
  import { CivilityType, UserInfoDto, UserStatus } from "../../interfaces/models/customer-user";
3
3
  import { CustomerOrganisationDto } from "../../interfaces/models/customer-organisation";
4
4
  import { AddressDto } from "../../interfaces/models/address";
5
+ import { AccountIdType } from "../../interfaces/models/customer-account";
5
6
  /**
6
7
  * Requests parameters type definitions
7
8
  */
@@ -40,6 +41,25 @@ export interface SendCustomerUserActivationRequestParameters {
40
41
  redirectUrl?: string;
41
42
  token: string;
42
43
  }
44
+ export interface UpdateSpecificCustomerUserParameters {
45
+ userToUpdateId: string;
46
+ civility: CivilityType;
47
+ customFieldValues?: CustomFieldValueRequest[];
48
+ firstName: string;
49
+ lastName: string;
50
+ phone?: string;
51
+ groups?: string[];
52
+ }
53
+ export interface RemoveAccountsFromCustomerUserParameters {
54
+ userToUpdateId: string;
55
+ idType?: AccountIdType;
56
+ accountIds: string[];
57
+ }
58
+ export interface AddCustomerUserToAccountsParameters {
59
+ userToUpdateId: string;
60
+ idType?: AccountIdType;
61
+ accountIds: string[];
62
+ }
43
63
  /**
44
64
  * Responses type definitions
45
65
  */
@@ -1,4 +1,4 @@
1
- import { ActivateCustomerUserParameters, CreateCustomerUserParameters, CreateCustomerUserResponse, GetAuthenticatedUserResponse, GetCustomerUserAddressesParameters, GetCustomerUserOrganisationsResponse, SendCustomerUserActivationRequestParameters, UpdateCustomerUserParameters, UpdateCustomerUserResponse } from "./definitions";
1
+ import { ActivateCustomerUserParameters, AddCustomerUserToAccountsParameters, CreateCustomerUserParameters, CreateCustomerUserResponse, GetAuthenticatedUserResponse, GetCustomerUserAddressesParameters, GetCustomerUserOrganisationsResponse, RemoveAccountsFromCustomerUserParameters, SendCustomerUserActivationRequestParameters, UpdateCustomerUserParameters, UpdateCustomerUserResponse, UpdateSpecificCustomerUserParameters } from "./definitions";
2
2
  /**
3
3
  * 🚚 **Retrieve Authenticated User**
4
4
  *
@@ -89,9 +89,9 @@ export declare function createCustomerUser(params: CreateCustomerUserParameters)
89
89
  * 🚚 **Update Customer User**
90
90
  *
91
91
  * **APICODE(USER-201)**
92
- * Updates a customer user.
92
+ * Updates your customer user.
93
93
  *
94
- * This function sends a request to update the details of an existing customer user.
94
+ * This function sends a request to update the details of the current customer user.
95
95
  *
96
96
  * 🛠 **Endpoint**: `PUT /v1/shop/customer-users`
97
97
  *
@@ -262,3 +262,132 @@ export declare function getCustomerUserOrganisations(): Promise<GetCustomerUserO
262
262
  * ```
263
263
  */
264
264
  export declare function sendCustomerUserActivationRequest({ redirectUrl, token, }: SendCustomerUserActivationRequestParameters): Promise<void>;
265
+ /**
266
+ * 🚚 **Update Specific Customer User**
267
+ *
268
+ * **APICODE(USER-202)**
269
+ * Updates a specific customer user.
270
+ *
271
+ * This function updates the details of a specific user, identified by
272
+ * the `userToUpdateId`. This parameter is mandatory and validated
273
+ * before the request is executed.
274
+ *
275
+ * 🛠 **Endpoint**: `PUT /v1/shop/customer-users/{userToUpdateId}`
276
+ *
277
+ * | Parameter | Type | Required | Description |
278
+ * |--------------------|--------|----------|--------------------------------------------------|
279
+ * | `userToUpdateId` | string | ✅ | The ID of the user you want to update. |
280
+ * | `firstName` | string | ✅ | The first name of the user. |
281
+ * | `lastName` | string | ✅ | The last name of the user. |
282
+ * | `civility` | string | ❌ | The civility of the user (e.g., Mr., Ms.). |
283
+ * | `phone` | string | ❌ | The phone number of the user. |
284
+ * | `customFieldValues`| object | ❌ | Custom fields for additional user information. |
285
+ * | `groups` | string[] | ❌ | The groups to which the user belongs. |
286
+
287
+ *
288
+ * 📤 **Returns**:
289
+ * A `Promise` resolving when the request is sent.
290
+ *
291
+ * 🛠 **Example usage**:
292
+ * ```ts
293
+ * const updatedUser = await updateCustomerUser({
294
+ * "userToUpdateId": "user1"
295
+ "civility": "MR",
296
+ "customFieldValues": [
297
+ {
298
+ "customFieldId": "string",
299
+ "customFieldValue": "string"
300
+ }
301
+ ],
302
+ "firstName": "string",
303
+ "groups": [
304
+ "string"
305
+ ],
306
+ "lastName": "string",
307
+ "phone": "+1 6884-2243 27"
308
+ });
309
+ * ```
310
+ * #### Output
311
+ * ```json
312
+ * {
313
+ * "detail": "User updated successfully"
314
+ * }
315
+ * ```
316
+ */
317
+ export declare function updateSpecificCustomerUser({ userToUpdateId, civility, firstName, lastName, phone, groups, customFieldValues, }: UpdateSpecificCustomerUserParameters): Promise<void>;
318
+ /**
319
+ * 🚚 **Remove Accounts from User**
320
+ *
321
+ * **APICODE(USER-350)**
322
+ * Removes accounts from a specific customer user.
323
+ *
324
+ * This function removes accounts of a specific user, identified by
325
+ * the `userToUpdateId`. The parameters `userToUpdateId` and `accountIds` are mandatory and validated
326
+ * before the request is executed.
327
+ *
328
+ * 🛠 **Endpoint**: `DELETE /v1/shop/customer-users/{userToUpdateId}/customer-accounts`
329
+ *
330
+ * | Parameter | Type | Required | Description |
331
+ * |--------------------|--------|----------|--------------------------------------------------|
332
+ * | `userToUpdateId` | string | ✅ | The ID of the user you want to update. |
333
+ * | `idType` | `AccountIdType`| ❌ | The type of account ID (e.g., `DJUST_ID`, `EXTERNAL_ID`). |
334
+ * | `accountIds` | string[] | ✅ | The first name of the user. |
335
+
336
+ *
337
+ * 📤 **Returns**:
338
+ * A `Promise` resolving when the request is sent.
339
+ *
340
+ * 🛠 **Example usage**:
341
+ * ```ts
342
+ * const updatedUser = await updateCustomerUser({
343
+ * "userToUpdateId": "user1",
344
+ * "idType": "EXTERNAL_ID",
345
+ "accountIds": ["account1", "account2", ...],
346
+ });
347
+ * ```
348
+ * #### Output
349
+ * ```json
350
+ * {
351
+ * "detail": "User successfully removed from accounts"
352
+ * }
353
+ * ```
354
+ */
355
+ export declare function removeAccountsFromCustomerUser({ userToUpdateId, idType, accountIds, }: RemoveAccountsFromCustomerUserParameters): Promise<void>;
356
+ /**
357
+ * 🚚 **Add User to Accounts**
358
+ *
359
+ * **APICODE(USER-250)**
360
+ * Add specific user to accounts.
361
+ *
362
+ * This function removes accounts of a specific user, identified by
363
+ * the `userToUpdateId`. The parameters `userToUpdateId` and `accountIds` are mandatory and validated
364
+ * before the request is executed.
365
+ *
366
+ * 🛠 **Endpoint**: `PATCH /v1/shop/customer-users/{userToUpdateId}/customer-accounts`
367
+ *
368
+ * | Parameter | Type | Required | Description |
369
+ * |--------------------|--------|----------|--------------------------------------------------|
370
+ * | `userToUpdateId` | string | ✅ | The ID of the user you want to update. |
371
+ * | `idType` | `AccountIdType`| ❌ | The type of account ID (e.g., `DJUST_ID`, `EXTERNAL_ID`). |
372
+ * | `accountIds` | string[] | ✅ | The first name of the user. |
373
+
374
+ *
375
+ * 📤 **Returns**:
376
+ * A `Promise` resolving when the request is sent.
377
+ *
378
+ * 🛠 **Example usage**:
379
+ * ```ts
380
+ * const updatedUser = await updateCustomerUser({
381
+ * "userToUpdateId": "user1",
382
+ * "idType": "EXTERNAL_ID",
383
+ "accountIds": ["account1", "account2", ...],
384
+ });
385
+ * ```
386
+ * #### Output
387
+ * ```json
388
+ * {
389
+ * "detail": "User successfully added to accounts"
390
+ * }
391
+ * ```
392
+ */
393
+ export declare function addCustomerUserToAccounts({ userToUpdateId, idType, accountIds, }: AddCustomerUserToAccountsParameters): Promise<void>;
@@ -7,6 +7,9 @@ exports.activateCustomerUser = activateCustomerUser;
7
7
  exports.getCustomerUserAddresses = getCustomerUserAddresses;
8
8
  exports.getCustomerUserOrganisations = getCustomerUserOrganisations;
9
9
  exports.sendCustomerUserActivationRequest = sendCustomerUserActivationRequest;
10
+ exports.updateSpecificCustomerUser = updateSpecificCustomerUser;
11
+ exports.removeAccountsFromCustomerUser = removeAccountsFromCustomerUser;
12
+ exports.addCustomerUserToAccounts = addCustomerUserToAccounts;
10
13
  const parameters_validation_1 = require("../../helpers/parameters-validation");
11
14
  const fetch_instance_1 = require("../../settings/fetch-instance");
12
15
  /**
@@ -128,9 +131,9 @@ async function createCustomerUser(params) {
128
131
  * 🚚 **Update Customer User**
129
132
  *
130
133
  * **APICODE(USER-201)**
131
- * Updates a customer user.
134
+ * Updates your customer user.
132
135
  *
133
- * This function sends a request to update the details of an existing customer user.
136
+ * This function sends a request to update the details of the current customer user.
134
137
  *
135
138
  * 🛠 **Endpoint**: `PUT /v1/shop/customer-users`
136
139
  *
@@ -353,3 +356,169 @@ async function sendCustomerUserActivationRequest({ redirectUrl, token, }) {
353
356
  }),
354
357
  });
355
358
  }
359
+ /**
360
+ * 🚚 **Update Specific Customer User**
361
+ *
362
+ * **APICODE(USER-202)**
363
+ * Updates a specific customer user.
364
+ *
365
+ * This function updates the details of a specific user, identified by
366
+ * the `userToUpdateId`. This parameter is mandatory and validated
367
+ * before the request is executed.
368
+ *
369
+ * 🛠 **Endpoint**: `PUT /v1/shop/customer-users/{userToUpdateId}`
370
+ *
371
+ * | Parameter | Type | Required | Description |
372
+ * |--------------------|--------|----------|--------------------------------------------------|
373
+ * | `userToUpdateId` | string | ✅ | The ID of the user you want to update. |
374
+ * | `firstName` | string | ✅ | The first name of the user. |
375
+ * | `lastName` | string | ✅ | The last name of the user. |
376
+ * | `civility` | string | ❌ | The civility of the user (e.g., Mr., Ms.). |
377
+ * | `phone` | string | ❌ | The phone number of the user. |
378
+ * | `customFieldValues`| object | ❌ | Custom fields for additional user information. |
379
+ * | `groups` | string[] | ❌ | The groups to which the user belongs. |
380
+
381
+ *
382
+ * 📤 **Returns**:
383
+ * A `Promise` resolving when the request is sent.
384
+ *
385
+ * 🛠 **Example usage**:
386
+ * ```ts
387
+ * const updatedUser = await updateCustomerUser({
388
+ * "userToUpdateId": "user1"
389
+ "civility": "MR",
390
+ "customFieldValues": [
391
+ {
392
+ "customFieldId": "string",
393
+ "customFieldValue": "string"
394
+ }
395
+ ],
396
+ "firstName": "string",
397
+ "groups": [
398
+ "string"
399
+ ],
400
+ "lastName": "string",
401
+ "phone": "+1 6884-2243 27"
402
+ });
403
+ * ```
404
+ * #### Output
405
+ * ```json
406
+ * {
407
+ * "detail": "User updated successfully"
408
+ * }
409
+ * ```
410
+ */
411
+ async function updateSpecificCustomerUser({ userToUpdateId, civility, firstName, lastName, phone, groups, customFieldValues, }) {
412
+ (0, parameters_validation_1.required)({ userToUpdateId, civility, firstName, lastName });
413
+ const { data } = await (0, fetch_instance_1.enhancedFetch)({
414
+ method: "PUT",
415
+ path: `/v1/shop/customer-users/${userToUpdateId}`,
416
+ body: JSON.stringify({
417
+ civility,
418
+ firstName,
419
+ lastName,
420
+ phone,
421
+ groups,
422
+ customFieldValues,
423
+ }),
424
+ });
425
+ return data;
426
+ }
427
+ /**
428
+ * 🚚 **Remove Accounts from User**
429
+ *
430
+ * **APICODE(USER-350)**
431
+ * Removes accounts from a specific customer user.
432
+ *
433
+ * This function removes accounts of a specific user, identified by
434
+ * the `userToUpdateId`. The parameters `userToUpdateId` and `accountIds` are mandatory and validated
435
+ * before the request is executed.
436
+ *
437
+ * 🛠 **Endpoint**: `DELETE /v1/shop/customer-users/{userToUpdateId}/customer-accounts`
438
+ *
439
+ * | Parameter | Type | Required | Description |
440
+ * |--------------------|--------|----------|--------------------------------------------------|
441
+ * | `userToUpdateId` | string | ✅ | The ID of the user you want to update. |
442
+ * | `idType` | `AccountIdType`| ❌ | The type of account ID (e.g., `DJUST_ID`, `EXTERNAL_ID`). |
443
+ * | `accountIds` | string[] | ✅ | The first name of the user. |
444
+
445
+ *
446
+ * 📤 **Returns**:
447
+ * A `Promise` resolving when the request is sent.
448
+ *
449
+ * 🛠 **Example usage**:
450
+ * ```ts
451
+ * const updatedUser = await updateCustomerUser({
452
+ * "userToUpdateId": "user1",
453
+ * "idType": "EXTERNAL_ID",
454
+ "accountIds": ["account1", "account2", ...],
455
+ });
456
+ * ```
457
+ * #### Output
458
+ * ```json
459
+ * {
460
+ * "detail": "User successfully removed from accounts"
461
+ * }
462
+ * ```
463
+ */
464
+ async function removeAccountsFromCustomerUser({ userToUpdateId, idType, accountIds, }) {
465
+ (0, parameters_validation_1.required)({ userToUpdateId, accountIds });
466
+ const { data } = await (0, fetch_instance_1.enhancedFetch)({
467
+ method: "DELETE",
468
+ path: `/v1/shop/customer-users/${userToUpdateId}/customer-accounts`,
469
+ body: JSON.stringify(accountIds),
470
+ params: {
471
+ idType,
472
+ },
473
+ });
474
+ return data;
475
+ }
476
+ /**
477
+ * 🚚 **Add User to Accounts**
478
+ *
479
+ * **APICODE(USER-250)**
480
+ * Add specific user to accounts.
481
+ *
482
+ * This function removes accounts of a specific user, identified by
483
+ * the `userToUpdateId`. The parameters `userToUpdateId` and `accountIds` are mandatory and validated
484
+ * before the request is executed.
485
+ *
486
+ * 🛠 **Endpoint**: `PATCH /v1/shop/customer-users/{userToUpdateId}/customer-accounts`
487
+ *
488
+ * | Parameter | Type | Required | Description |
489
+ * |--------------------|--------|----------|--------------------------------------------------|
490
+ * | `userToUpdateId` | string | ✅ | The ID of the user you want to update. |
491
+ * | `idType` | `AccountIdType`| ❌ | The type of account ID (e.g., `DJUST_ID`, `EXTERNAL_ID`). |
492
+ * | `accountIds` | string[] | ✅ | The first name of the user. |
493
+
494
+ *
495
+ * 📤 **Returns**:
496
+ * A `Promise` resolving when the request is sent.
497
+ *
498
+ * 🛠 **Example usage**:
499
+ * ```ts
500
+ * const updatedUser = await updateCustomerUser({
501
+ * "userToUpdateId": "user1",
502
+ * "idType": "EXTERNAL_ID",
503
+ "accountIds": ["account1", "account2", ...],
504
+ });
505
+ * ```
506
+ * #### Output
507
+ * ```json
508
+ * {
509
+ * "detail": "User successfully added to accounts"
510
+ * }
511
+ * ```
512
+ */
513
+ async function addCustomerUserToAccounts({ userToUpdateId, idType, accountIds, }) {
514
+ (0, parameters_validation_1.required)({ userToUpdateId, accountIds });
515
+ const { data } = await (0, fetch_instance_1.enhancedFetch)({
516
+ method: "PATCH",
517
+ path: `/v1/shop/customer-users/${userToUpdateId}/customer-accounts`,
518
+ body: JSON.stringify(accountIds),
519
+ params: {
520
+ idType,
521
+ },
522
+ });
523
+ return data;
524
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.23.0",
3
+ "version": "1.24.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",