@djust-b2b/djust-front-sdk 1.23.0 → 1.25.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 +3 -0
- package/lib/interfaces/models/customer-account.d.ts +1 -0
- package/lib/services/customer-account/definitions.d.ts +2 -0
- package/lib/services/customer-account/index.d.ts +1 -0
- package/lib/services/customer-account/index.js +4 -1
- package/lib/services/customer-user/definitions.d.ts +20 -0
- package/lib/services/customer-user/index.d.ts +132 -3
- package/lib/services/customer-user/index.js +171 -2
- package/package.json +1 -1
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;
|
|
@@ -53,6 +53,8 @@ export interface GetCustomerAccountOrdersParameters {
|
|
|
53
53
|
}
|
|
54
54
|
export interface GetCustomerAccountUsersParameters {
|
|
55
55
|
pageable: PageableParameters;
|
|
56
|
+
forAllAccounts?: boolean;
|
|
57
|
+
query?: string;
|
|
56
58
|
}
|
|
57
59
|
export interface CreateCustomerAccountOrganisationParameters {
|
|
58
60
|
externalId: string;
|
|
@@ -334,6 +334,7 @@ export declare function getCustomerAccountOrders(params: GetCustomerAccountOrder
|
|
|
334
334
|
* | **Parameter** | **Type** | **Required** | **Description** |
|
|
335
335
|
* |-------------------|------------|--------------|-------------------------------------------------------------|
|
|
336
336
|
* | `pageable` | `object` | ✅ | Object containing pagination details: `page`, `size`, etc. |
|
|
337
|
+
* | `forAllAccounts` | `boolean` | ❌ | Specifies if we want to retrieve users of all my users' accounts |
|
|
337
338
|
* | `locale` | `string` | ❌ | The locale in which data should be retrieved. |
|
|
338
339
|
*
|
|
339
340
|
* ### **Returns**:
|
|
@@ -474,6 +474,7 @@ async function getCustomerAccountOrders(params) {
|
|
|
474
474
|
* | **Parameter** | **Type** | **Required** | **Description** |
|
|
475
475
|
* |-------------------|------------|--------------|-------------------------------------------------------------|
|
|
476
476
|
* | `pageable` | `object` | ✅ | Object containing pagination details: `page`, `size`, etc. |
|
|
477
|
+
* | `forAllAccounts` | `boolean` | ❌ | Specifies if we want to retrieve users of all my users' accounts |
|
|
477
478
|
* | `locale` | `string` | ❌ | The locale in which data should be retrieved. |
|
|
478
479
|
*
|
|
479
480
|
* ### **Returns**:
|
|
@@ -488,7 +489,7 @@ async function getCustomerAccountOrders(params) {
|
|
|
488
489
|
* ```
|
|
489
490
|
*/
|
|
490
491
|
async function getCustomerAccountUsers(params) {
|
|
491
|
-
var _a, _b, _c;
|
|
492
|
+
var _a, _b, _c, _d;
|
|
492
493
|
(0, parameters_validation_1.required)({ pageable: params.pageable });
|
|
493
494
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
494
495
|
method: "GET",
|
|
@@ -497,6 +498,8 @@ async function getCustomerAccountUsers(params) {
|
|
|
497
498
|
page: (_a = params.pageable) === null || _a === void 0 ? void 0 : _a.page,
|
|
498
499
|
size: (_b = params.pageable) === null || _b === void 0 ? void 0 : _b.size,
|
|
499
500
|
sort: (_c = params.pageable) === null || _c === void 0 ? void 0 : _c.sort,
|
|
501
|
+
forAllAccounts: (_d = params.forAllAccounts) !== null && _d !== void 0 ? _d : false,
|
|
502
|
+
query: params.query || "",
|
|
500
503
|
},
|
|
501
504
|
});
|
|
502
505
|
return data;
|
|
@@ -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
|
|
92
|
+
* Updates your customer user.
|
|
93
93
|
*
|
|
94
|
-
* This function sends a request to update the details of
|
|
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
|
|
134
|
+
* Updates your customer user.
|
|
132
135
|
*
|
|
133
|
-
* This function sends a request to update the details of
|
|
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
|
+
}
|