@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.
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ /**
3
+ * Mocks centralisés pour les tests du module offer-prices
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mockHttpErrors = exports.mockErrors = exports.mockResponses = exports.mockOrder = exports.mockPageableObject = exports.mockParameters = exports.mockOfferPrices = exports.mockPriceRanges = exports.mockProductPrices = void 0;
7
+ // Mock data pour les prix de produits
8
+ exports.mockProductPrices = {
9
+ standard: {
10
+ itemPrice: 10.5,
11
+ unitPrice: 2.1,
12
+ itemPriceTTC: 12.6,
13
+ unitPriceTTC: 2.52,
14
+ },
15
+ discounted: {
16
+ itemPrice: 8.4,
17
+ unitPrice: 1.68,
18
+ itemPriceTTC: 10.08,
19
+ unitPriceTTC: 2.02,
20
+ },
21
+ };
22
+ // Mock data pour les gammes de prix
23
+ exports.mockPriceRanges = {
24
+ single: [
25
+ {
26
+ quantity: 1,
27
+ price: exports.mockProductPrices.standard,
28
+ discountPrice: exports.mockProductPrices.standard,
29
+ },
30
+ ],
31
+ multiple: [
32
+ {
33
+ quantity: 1,
34
+ price: exports.mockProductPrices.standard,
35
+ discountPrice: exports.mockProductPrices.standard,
36
+ },
37
+ {
38
+ quantity: 10,
39
+ price: exports.mockProductPrices.standard,
40
+ discountPrice: exports.mockProductPrices.discounted,
41
+ },
42
+ {
43
+ quantity: 50,
44
+ price: exports.mockProductPrices.standard,
45
+ discountPrice: {
46
+ itemPrice: 7.35,
47
+ unitPrice: 1.47,
48
+ itemPriceTTC: 8.82,
49
+ unitPriceTTC: 1.76,
50
+ },
51
+ },
52
+ ],
53
+ };
54
+ // Mock data pour les prix d'offres
55
+ exports.mockOfferPrices = [
56
+ {
57
+ id: "offer_price_1",
58
+ externalId: "ext_offer_price_1",
59
+ type: "PUBLIC",
60
+ itemPerPack: 5,
61
+ customerAccountExternalId: "",
62
+ customerTagExternalId: "",
63
+ priceRanges: exports.mockPriceRanges.single,
64
+ },
65
+ {
66
+ id: "offer_price_2",
67
+ externalId: "ext_offer_price_2",
68
+ type: "GROUP",
69
+ itemPerPack: 10,
70
+ customerAccountExternalId: "",
71
+ customerTagExternalId: "tag_123",
72
+ priceRanges: exports.mockPriceRanges.multiple,
73
+ },
74
+ {
75
+ id: "offer_price_3",
76
+ externalId: "ext_offer_price_3",
77
+ type: "ACCOUNT",
78
+ itemPerPack: 1,
79
+ customerAccountExternalId: "account_456",
80
+ customerTagExternalId: "",
81
+ priceRanges: exports.mockPriceRanges.single,
82
+ },
83
+ ];
84
+ // Mock data pour les paramètres de test
85
+ exports.mockParameters = {
86
+ getPaginatedOfferPrices: {
87
+ valid: {
88
+ offerInventoryExternalId: "inventory_123",
89
+ },
90
+ withPagination: {
91
+ offerInventoryExternalId: "inventory_123",
92
+ page: 0,
93
+ size: 20,
94
+ },
95
+ withSorting: {
96
+ offerInventoryExternalId: "inventory_123",
97
+ page: 1,
98
+ size: 10,
99
+ sort: "createdAt,desc",
100
+ },
101
+ missingRequired: {
102
+ page: 0,
103
+ size: 20,
104
+ },
105
+ },
106
+ };
107
+ // Mock data pour les objets de pagination
108
+ exports.mockPageableObject = {
109
+ offset: 0,
110
+ pageNumber: 0,
111
+ pageSize: 20,
112
+ paged: true,
113
+ sort: [],
114
+ unpaged: false,
115
+ };
116
+ exports.mockOrder = {
117
+ ascending: false,
118
+ descending: true,
119
+ direction: "DESC",
120
+ ignoreCase: false,
121
+ nullHandling: "NATIVE",
122
+ property: "createdAt",
123
+ };
124
+ // Mock Headers pour les tests
125
+ function createMockHeaders() {
126
+ const headers = new Headers();
127
+ headers.append("Content-Type", "application/json");
128
+ headers.append("dj-client", "test-client");
129
+ headers.append("dj-api-key", "test-api-key");
130
+ return headers;
131
+ }
132
+ // Mock data pour les réponses d'API
133
+ exports.mockResponses = {
134
+ getPaginatedOfferPrices: {
135
+ success: {
136
+ data: {
137
+ content: exports.mockOfferPrices,
138
+ empty: false,
139
+ first: true,
140
+ last: false,
141
+ number: 0,
142
+ numberOfElements: 3,
143
+ pageable: exports.mockPageableObject,
144
+ size: 20,
145
+ sort: [exports.mockOrder],
146
+ totalElements: 15,
147
+ },
148
+ headers: createMockHeaders(),
149
+ status: 200,
150
+ },
151
+ empty: {
152
+ data: {
153
+ content: [],
154
+ empty: true,
155
+ first: true,
156
+ last: true,
157
+ number: 0,
158
+ numberOfElements: 0,
159
+ pageable: exports.mockPageableObject,
160
+ size: 20,
161
+ sort: [],
162
+ totalElements: 0,
163
+ },
164
+ headers: createMockHeaders(),
165
+ status: 200,
166
+ },
167
+ singleItem: {
168
+ data: {
169
+ content: [exports.mockOfferPrices[0]],
170
+ empty: false,
171
+ first: true,
172
+ last: true,
173
+ number: 0,
174
+ numberOfElements: 1,
175
+ pageable: exports.mockPageableObject,
176
+ size: 20,
177
+ sort: [],
178
+ totalElements: 1,
179
+ },
180
+ headers: createMockHeaders(),
181
+ status: 200,
182
+ },
183
+ },
184
+ };
185
+ // Mock data pour les erreurs
186
+ exports.mockErrors = {
187
+ networkError: new Error("Network error"),
188
+ unauthorized: new Error("Unauthorized"),
189
+ badRequest: new Error("Bad request"),
190
+ notFound: new Error("Not found"),
191
+ serverError: new Error("Internal server error"),
192
+ missingParameter: new Error("Missing required parameter: offerInventoryExternalId"),
193
+ };
194
+ // Mock data pour les cas d'erreur HTTP
195
+ exports.mockHttpErrors = {
196
+ 400: { status: 400, message: "Bad Request" },
197
+ 401: { status: 401, message: "Unauthorized" },
198
+ 404: { status: 404, message: "Not Found" },
199
+ 500: { status: 500, message: "Internal Server Error" },
200
+ };
@@ -155,7 +155,7 @@ async function getPaymentMethods({ reference, countryCode, referenceType, locale
155
155
  (0, parameters_validation_1.required)({ reference });
156
156
  const { data } = await (0, fetch_instance_1.enhancedFetch)({
157
157
  method: "GET",
158
- path: `/v1/shop/payments/methods`,
158
+ path: `/v1/shop/payments/payments-methods`,
159
159
  params: {
160
160
  reference,
161
161
  countryCode,
@@ -0,0 +1,48 @@
1
+ import { SupplierDto, SupplierEvaluationDto, SupplierIdType } from "../../../interfaces/models/supplier";
2
+ import { PageableParameters } from "../../../interfaces/models/common";
3
+ export declare const mockSuppliers: SupplierDto[];
4
+ export declare const mockSupplierEvaluations: SupplierEvaluationDto[];
5
+ export declare const mockPageable: PageableParameters;
6
+ export declare const mockPageableWithSort: PageableParameters;
7
+ export declare const mockGetSuppliersParams: {
8
+ pageable: PageableParameters;
9
+ supplierStatus: string;
10
+ supplierIds: string[];
11
+ idType: SupplierIdType;
12
+ };
13
+ export declare const mockGetSupplierParams: {
14
+ supplierId: string;
15
+ idType: SupplierIdType;
16
+ };
17
+ export declare const mockGetSupplierEvaluationsParams: {
18
+ supplierId: string;
19
+ idType: SupplierIdType;
20
+ pageable: PageableParameters;
21
+ };
22
+ export declare const mockErrorResponse: {
23
+ message: string;
24
+ status: number;
25
+ };
26
+ export declare const mockNotFoundError: {
27
+ message: string;
28
+ status: number;
29
+ };
30
+ export declare const mockValidationError: {
31
+ message: string;
32
+ status: number;
33
+ };
34
+ export declare const mockEnhancedFetchSuccess: {
35
+ data: SupplierDto[];
36
+ headers: Headers;
37
+ status: number;
38
+ };
39
+ export declare const mockEnhancedFetchSupplierSuccess: {
40
+ data: SupplierDto;
41
+ headers: Headers;
42
+ status: number;
43
+ };
44
+ export declare const mockEnhancedFetchEvaluationsSuccess: {
45
+ data: SupplierEvaluationDto[];
46
+ headers: Headers;
47
+ status: number;
48
+ };
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockEnhancedFetchEvaluationsSuccess = exports.mockEnhancedFetchSupplierSuccess = exports.mockEnhancedFetchSuccess = exports.mockValidationError = exports.mockNotFoundError = exports.mockErrorResponse = exports.mockGetSupplierEvaluationsParams = exports.mockGetSupplierParams = exports.mockGetSuppliersParams = exports.mockPageableWithSort = exports.mockPageable = exports.mockSupplierEvaluations = exports.mockSuppliers = void 0;
4
+ // Mock data for suppliers
5
+ exports.mockSuppliers = [
6
+ {
7
+ id: "supplier-1",
8
+ externalId: "ext-supplier-1",
9
+ name: "Supplier One",
10
+ description: "First test supplier",
11
+ supplierStatus: "ACTIVE",
12
+ supplierRating: "4.5",
13
+ evaluationCount: 10,
14
+ totalOffers: 50,
15
+ totalOrders: 100,
16
+ totalSales: 50000,
17
+ returnPolicy: "30 days return policy",
18
+ logo: "https://example.com/logo1.png",
19
+ banner: "https://example.com/banner1.png",
20
+ additionalImageLink: ["https://example.com/image1.png"],
21
+ isDefault: true,
22
+ externalSource: "MIRAKL",
23
+ customFieldValues: [],
24
+ paymentDueDate: {
25
+ paymentDueDateDelay: 30,
26
+ paymentDueDateMode: "SIMPLE",
27
+ },
28
+ createdAt: "2023-01-01T00:00:00Z",
29
+ updatedAt: "2023-01-01T00:00:00Z",
30
+ },
31
+ {
32
+ id: "supplier-2",
33
+ externalId: "ext-supplier-2",
34
+ name: "Supplier Two",
35
+ description: "Second test supplier",
36
+ supplierStatus: "INACTIVE",
37
+ supplierRating: "3.8",
38
+ evaluationCount: 5,
39
+ totalOffers: 25,
40
+ totalOrders: 50,
41
+ totalSales: 25000,
42
+ returnPolicy: "14 days return policy",
43
+ logo: "https://example.com/logo2.png",
44
+ banner: "https://example.com/banner2.png",
45
+ additionalImageLink: ["https://example.com/image2.png"],
46
+ isDefault: false,
47
+ externalSource: "CLIENT",
48
+ customFieldValues: [],
49
+ paymentDueDate: {
50
+ paymentDueDateDelay: 15,
51
+ paymentDueDateMode: "SIMPLE",
52
+ },
53
+ createdAt: "2023-01-02T00:00:00Z",
54
+ updatedAt: "2023-01-02T00:00:00Z",
55
+ },
56
+ {
57
+ id: "supplier-3",
58
+ externalId: "ext-supplier-3",
59
+ name: "Supplier Three",
60
+ description: "Third test supplier",
61
+ supplierStatus: "SUSPENDED",
62
+ supplierRating: "2.1",
63
+ evaluationCount: 2,
64
+ totalOffers: 10,
65
+ totalOrders: 20,
66
+ totalSales: 10000,
67
+ returnPolicy: "No returns",
68
+ logo: "https://example.com/logo3.png",
69
+ banner: "https://example.com/banner3.png",
70
+ additionalImageLink: ["https://example.com/image3.png"],
71
+ isDefault: false,
72
+ externalSource: "EXTERN",
73
+ customFieldValues: [],
74
+ paymentDueDate: {
75
+ paymentDueDateDelay: 7,
76
+ paymentDueDateMode: "END_OF_MONTH",
77
+ },
78
+ createdAt: "2023-01-03T00:00:00Z",
79
+ updatedAt: "2023-01-03T00:00:00Z",
80
+ },
81
+ ];
82
+ // Mock data for supplier evaluations
83
+ exports.mockSupplierEvaluations = [
84
+ {
85
+ comment: "Excellent service and fast delivery",
86
+ creationDate: "2023-01-15T10:00:00Z",
87
+ customerId: "customer-1",
88
+ firstname: "John",
89
+ lastname: "Doe",
90
+ grade: 5,
91
+ lastUpdatedDate: "2023-01-15T10:00:00Z",
92
+ },
93
+ {
94
+ comment: "Good quality products",
95
+ creationDate: "2023-01-14T15:30:00Z",
96
+ customerId: "customer-2",
97
+ firstname: "Jane",
98
+ lastname: "Smith",
99
+ grade: 4,
100
+ lastUpdatedDate: "2023-01-14T15:30:00Z",
101
+ },
102
+ {
103
+ comment: "Average experience",
104
+ creationDate: "2023-01-13T09:15:00Z",
105
+ customerId: "customer-3",
106
+ firstname: "Bob",
107
+ lastname: "Johnson",
108
+ grade: 3,
109
+ lastUpdatedDate: "2023-01-13T09:15:00Z",
110
+ },
111
+ ];
112
+ // Mock pagination data
113
+ exports.mockPageable = {
114
+ page: 0,
115
+ size: 10,
116
+ sort: ["createdAt,desc"],
117
+ };
118
+ exports.mockPageableWithSort = {
119
+ page: 1,
120
+ size: 5,
121
+ sort: ["name,asc"],
122
+ };
123
+ // Mock request parameters
124
+ exports.mockGetSuppliersParams = {
125
+ pageable: exports.mockPageable,
126
+ supplierStatus: "ACTIVE",
127
+ supplierIds: ["supplier-1", "supplier-2"],
128
+ idType: "DJUST_ID",
129
+ };
130
+ exports.mockGetSupplierParams = {
131
+ supplierId: "supplier-1",
132
+ idType: "DJUST_ID",
133
+ };
134
+ exports.mockGetSupplierEvaluationsParams = {
135
+ supplierId: "supplier-1",
136
+ idType: "DJUST_ID",
137
+ pageable: exports.mockPageable,
138
+ };
139
+ // Mock error responses
140
+ exports.mockErrorResponse = {
141
+ message: "Internal server error",
142
+ status: 500,
143
+ };
144
+ exports.mockNotFoundError = {
145
+ message: "Supplier not found",
146
+ status: 404,
147
+ };
148
+ exports.mockValidationError = {
149
+ message: "Validation failed",
150
+ status: 400,
151
+ };
152
+ // Mock enhancedFetch responses
153
+ exports.mockEnhancedFetchSuccess = {
154
+ data: exports.mockSuppliers,
155
+ headers: new Headers(),
156
+ status: 200,
157
+ };
158
+ exports.mockEnhancedFetchSupplierSuccess = {
159
+ data: exports.mockSuppliers[0],
160
+ headers: new Headers(),
161
+ status: 200,
162
+ };
163
+ exports.mockEnhancedFetchEvaluationsSuccess = {
164
+ data: exports.mockSupplierEvaluations,
165
+ headers: new Headers(),
166
+ status: 200,
167
+ };
@@ -4,10 +4,10 @@ import { PageableParameters } from "../../interfaces/models/common";
4
4
  * Request parameters type definitions
5
5
  */
6
6
  export interface GetSuppliersParameters {
7
- supplierIds: string[];
8
- idType: SupplierIdType;
9
7
  pageable: PageableParameters;
10
- supplierStatus: string[];
8
+ supplierStatus?: string;
9
+ supplierIds?: string[];
10
+ idType?: SupplierIdType;
11
11
  }
12
12
  export interface GetSupplierParameters {
13
13
  supplierId: string;
@@ -47,7 +47,6 @@ async function getSuppliers({ pageable, supplierStatus, supplierIds, idType, })
47
47
  method: "GET",
48
48
  path: `/v1/shop/suppliers`,
49
49
  params: {
50
- pageable,
51
50
  page: pageable.page,
52
51
  size: pageable.size,
53
52
  sort: pageable.sort,
@@ -137,7 +136,6 @@ async function getSupplierEvaluations({ supplierId, idType, pageable, }) {
137
136
  path: `/v1/shop/suppliers/${supplierId}/evaluations`,
138
137
  params: {
139
138
  idType,
140
- pageable,
141
139
  page: pageable.page,
142
140
  size: pageable.size,
143
141
  sort: pageable.sort,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.3.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",
@@ -27,7 +27,8 @@
27
27
  "@semantic-release/npm": "^11.0.2",
28
28
  "@types/jest": "^29.0.1",
29
29
  "@types/node": "^18.7.16",
30
- "@vitest/ui": "latest",
30
+ "@vitest/coverage-v8": "3.0.9",
31
+ "@vitest/ui": "3.0.9",
31
32
  "cz-conventional-changelog": "^3.3.0",
32
33
  "dotenv": "^16.0.2",
33
34
  "esbuild": "^0.20.1",
@@ -43,7 +44,7 @@
43
44
  "typedoc": "0.27.3",
44
45
  "typedoc-plugin-markdown": "4.3.1",
45
46
  "typescript": "^5.6.3",
46
- "vitest": "latest"
47
+ "vitest": "3.0.9"
47
48
  },
48
49
  "files": [
49
50
  "lib/**/**.js",
@@ -1,16 +0,0 @@
1
- import { OfferInventory, OfferPriceResponse } from "./offer";
2
- import { SupplierResponse } from "./supplier";
3
- export interface BuyingList {
4
- buyingListItems: BuyingListItem[];
5
- createdAt?: string;
6
- customerUserId: string;
7
- id: string;
8
- name: string;
9
- }
10
- export interface BuyingListItem {
11
- id: string;
12
- offerPrice: OfferPriceResponse;
13
- offerInventory: OfferInventory;
14
- quantity: number;
15
- supplier: SupplierResponse;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,43 +0,0 @@
1
- import { BuyingList, BuyingListItem } from "../../interfaces/models/buying-list";
2
- /**
3
- * Request parameters type definitions
4
- */
5
- export interface GetBuyingListParameters {
6
- buyingListId: string;
7
- locale?: string;
8
- }
9
- export interface CreateBuyingListParameters {
10
- name: string;
11
- }
12
- export interface UpdateBuyingListParameters {
13
- buyingListId: string;
14
- name?: string;
15
- }
16
- export interface UpdateBuyingListItemsParameters {
17
- buyingListId: string;
18
- products: BuyingListItem[];
19
- }
20
- export interface DeleteBuyingListParameters {
21
- buyingListId: string;
22
- }
23
- export interface DeleteBuyingListItemsParameters {
24
- buyingListId: string;
25
- itemIds: string[];
26
- }
27
- export interface UpdateBuyingListOwnerParameters {
28
- buyingListId: string;
29
- newOwnerEmail: string;
30
- }
31
- /**
32
- * Response type definitions
33
- */
34
- export interface GetBuyingListResponse extends BuyingList {
35
- }
36
- export interface GetBuyingListsResponse extends Array<BuyingList> {
37
- }
38
- export interface CreateBuyingListResponse extends BuyingList {
39
- }
40
- export interface UpdateBuyingListResponse extends BuyingList {
41
- }
42
- export interface UpdateBuyingListItemsResponse extends BuyingList {
43
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,33 +0,0 @@
1
- import { CreateBuyingListParameters, CreateBuyingListResponse, DeleteBuyingListItemsParameters, DeleteBuyingListParameters, GetBuyingListParameters, GetBuyingListResponse, GetBuyingListsResponse, UpdateBuyingListItemsParameters, UpdateBuyingListItemsResponse, UpdateBuyingListOwnerParameters, UpdateBuyingListParameters, UpdateBuyingListResponse } from "./definitions";
2
- /**
3
- * Get buying list by id
4
- */
5
- export declare function getBuyingList({ buyingListId, locale, }: GetBuyingListParameters): Promise<GetBuyingListResponse>;
6
- /**
7
- * Get buying lists
8
- */
9
- export declare function getBuyingLists(): Promise<GetBuyingListsResponse>;
10
- /**
11
- * Create a buying list
12
- */
13
- export declare function createBuyingList({ name, }: CreateBuyingListParameters): Promise<CreateBuyingListResponse>;
14
- /**
15
- * Update a buying list
16
- */
17
- export declare function updateBuyingList({ buyingListId, name, }: UpdateBuyingListParameters): Promise<UpdateBuyingListResponse>;
18
- /**
19
- * Add products to a buying list
20
- */
21
- export declare function updateBuyingListItems({ buyingListId, products, }: UpdateBuyingListItemsParameters): Promise<UpdateBuyingListItemsResponse>;
22
- /**
23
- * Delete a buying list
24
- */
25
- export declare function deleteBuyingList({ buyingListId, }: DeleteBuyingListParameters): Promise<void>;
26
- /**
27
- * Delete products from a buying list
28
- */
29
- export declare function deleteBuyingListItems({ buyingListId, itemIds, }: DeleteBuyingListItemsParameters): Promise<void>;
30
- /**
31
- * Update buying list's owner
32
- */
33
- export declare function updateBuyingListOwner({ buyingListId, newOwnerEmail, }: UpdateBuyingListOwnerParameters): Promise<void>;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBuyingList = getBuyingList;
4
- exports.getBuyingLists = getBuyingLists;
5
- exports.createBuyingList = createBuyingList;
6
- exports.updateBuyingList = updateBuyingList;
7
- exports.updateBuyingListItems = updateBuyingListItems;
8
- exports.deleteBuyingList = deleteBuyingList;
9
- exports.deleteBuyingListItems = deleteBuyingListItems;
10
- exports.updateBuyingListOwner = updateBuyingListOwner;
11
- const parameters_validation_1 = require("../../helpers/parameters-validation");
12
- const fetch_instance_1 = require("../../settings/fetch-instance");
13
- /**
14
- * Get buying list by id
15
- */
16
- async function getBuyingList({ buyingListId, locale, }) {
17
- (0, parameters_validation_1.required)({ buyingListId });
18
- const { data } = await (0, fetch_instance_1.enhancedFetch)({
19
- method: "GET",
20
- path: `/v1/shop/buying-lists/${buyingListId}`,
21
- params: { locale },
22
- });
23
- return data;
24
- }
25
- /**
26
- * Get buying lists
27
- */
28
- async function getBuyingLists() {
29
- const { data } = await (0, fetch_instance_1.enhancedFetch)({
30
- method: "GET",
31
- path: `/v1/shop/buying-lists`,
32
- });
33
- return data;
34
- }
35
- /**
36
- * Create a buying list
37
- */
38
- async function createBuyingList({ name, }) {
39
- (0, parameters_validation_1.required)({ name });
40
- const { data } = await (0, fetch_instance_1.enhancedFetch)({
41
- method: "POST",
42
- path: `/v1/shop/buying-lists`,
43
- body: JSON.stringify({ name: name }),
44
- });
45
- return data;
46
- }
47
- /**
48
- * Update a buying list
49
- */
50
- async function updateBuyingList({ buyingListId, name, }) {
51
- (0, parameters_validation_1.required)({ buyingListId, name });
52
- const { data } = await (0, fetch_instance_1.enhancedFetch)({
53
- method: "PUT",
54
- path: `/v1/shop/buying-lists/${buyingListId}`,
55
- body: JSON.stringify({ name }),
56
- });
57
- return data;
58
- }
59
- /**
60
- * Add products to a buying list
61
- */
62
- async function updateBuyingListItems({ buyingListId, products, }) {
63
- (0, parameters_validation_1.required)({ buyingListId, products });
64
- const { data } = await (0, fetch_instance_1.enhancedFetch)({
65
- method: "PUT",
66
- path: `/v1/shop/buying-lists/${buyingListId}/items`,
67
- body: JSON.stringify(products),
68
- });
69
- return data;
70
- }
71
- /**
72
- * Delete a buying list
73
- */
74
- async function deleteBuyingList({ buyingListId, }) {
75
- (0, parameters_validation_1.required)({ buyingListId });
76
- (0, fetch_instance_1.enhancedFetch)({
77
- method: "DELETE",
78
- path: `/v1/shop/buying-lists/${buyingListId}`,
79
- });
80
- }
81
- /**
82
- * Delete products from a buying list
83
- */
84
- async function deleteBuyingListItems({ buyingListId, itemIds, }) {
85
- (0, parameters_validation_1.required)({ buyingListId, itemIds });
86
- await (0, fetch_instance_1.enhancedFetch)({
87
- method: "DELETE",
88
- path: `/v1/shop/buying-lists/${buyingListId}/items`,
89
- params: {
90
- itemIds: itemIds,
91
- },
92
- });
93
- }
94
- /**
95
- * Update buying list's owner
96
- */
97
- async function updateBuyingListOwner({ buyingListId, newOwnerEmail, }) {
98
- (0, parameters_validation_1.required)({ buyingListId, newOwnerEmail });
99
- await (0, fetch_instance_1.enhancedFetch)({
100
- method: "PUT",
101
- path: `/v1/shop/buying-lists/${buyingListId}/change-owner`,
102
- body: JSON.stringify({ newOwnerEmail }),
103
- });
104
- }