@djust-b2b/djust-front-sdk 2.1.0 → 2.2.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 +25 -23
- package/lib/index.js +2 -2
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/interfaces/index.js +0 -1
- package/lib/interfaces/models/attribute.d.ts +12 -2
- package/lib/interfaces/models/custom-field.d.ts +4 -0
- package/lib/interfaces/models/customer-account.d.ts +1 -0
- package/lib/interfaces/models/offer.d.ts +9 -0
- package/lib/interfaces/models/payment.d.ts +1 -0
- package/lib/services/attributes/definitions.d.ts +27 -0
- package/lib/services/attributes/index.d.ts +32 -0
- package/lib/services/attributes/index.js +49 -0
- package/lib/services/auth/__mocks__/auth.mocks.d.ts +248 -0
- package/lib/services/auth/__mocks__/auth.mocks.js +220 -0
- package/lib/services/auth/definitions.d.ts +39 -0
- package/lib/services/auth/definitions.requests.d.ts +4 -0
- package/lib/services/auth/index.d.ts +58 -3
- package/lib/services/auth/index.js +72 -2
- package/lib/services/cart/index.js +1 -0
- package/lib/services/custom-field/definitions.d.ts +6 -0
- package/lib/services/custom-field/index.d.ts +40 -2
- package/lib/services/custom-field/index.js +50 -3
- package/lib/services/customer-account/definitions.d.ts +15 -2
- package/lib/services/customer-account/index.d.ts +47 -5
- package/lib/services/customer-account/index.js +68 -5
- package/lib/services/customer-user/definitions.d.ts +2 -0
- package/lib/services/customer-user/index.d.ts +1 -1
- package/lib/services/customer-user/index.js +4 -1
- package/lib/services/incident/definitions.d.ts +15 -0
- package/lib/services/incident/index.d.ts +81 -2
- package/lib/services/incident/index.js +116 -1
- package/lib/services/logistic-order/definitions.d.ts +15 -4
- package/lib/services/logistic-order/index.d.ts +19 -10
- package/lib/services/logistic-order/index.js +40 -17
- package/lib/services/navigation-category/definitions.d.ts +7 -0
- package/lib/services/navigation-category/index.d.ts +33 -1
- package/lib/services/navigation-category/index.js +40 -0
- package/lib/services/offer-inventories/index.js +3 -3
- package/lib/services/offer-prices/__mocks__/offer-prices.mocks.d.ts +108 -0
- package/lib/services/offer-prices/__mocks__/offer-prices.mocks.js +200 -0
- package/lib/services/offer-prices/definitions.d.ts +23 -0
- package/lib/services/offer-prices/index.d.ts +35 -0
- package/lib/services/offer-prices/index.js +52 -0
- package/lib/services/payment/index.js +1 -1
- package/lib/services/product/definitions.d.ts +5 -0
- package/lib/services/product/index.d.ts +6 -29
- package/lib/services/product/index.js +8 -42
- package/lib/services/product-variant/definitions.d.ts +27 -0
- package/lib/services/product-variant/index.d.ts +30 -1
- package/lib/services/product-variant/index.js +40 -0
- package/lib/services/supplier/__mocks__/supplier-mocks.d.ts +48 -0
- package/lib/services/supplier/__mocks__/supplier-mocks.js +167 -0
- package/lib/services/supplier/definitions.d.ts +3 -3
- package/lib/services/supplier/index.js +0 -2
- package/package.json +4 -3
- package/lib/interfaces/models/buying-list.d.ts +0 -16
- package/lib/services/buying-list/definitions.d.ts +0 -43
- package/lib/services/buying-list/index.d.ts +0 -33
- package/lib/services/buying-list/index.js +0 -104
- /package/lib/services/{buying-list → attributes}/definitions.js +0 -0
- /package/lib/{interfaces/models/buying-list.js → services/offer-prices/definitions.js} +0 -0
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "2.2.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/
|
|
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": "
|
|
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,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,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
|
-
}
|
|
File without changes
|
|
File without changes
|