@smess/networking 1.0.26 → 1.0.29
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
|
|
2
2
|
import { SmessService } from "./smess.service";
|
|
3
|
+
import { PaginationLinks } from "./store.product.service";
|
|
3
4
|
import { BehaviorSubject, Observable } from "rxjs";
|
|
4
|
-
export type CustomerTarget = "register" | "get-profile" | "update-profile" | "cart-collection" | "customer-product-collection" | "customer-product-create" | "customer-product-remove" | "customer-product-update-
|
|
5
|
+
export type CustomerTarget = "register" | "get-profile" | "update-profile" | "cart-collection" | "customer-product-collection" | "customer-product-create" | "customer-product-remove" | "customer-product-update-category";
|
|
5
6
|
export interface CustomerRegisterRequest {
|
|
6
7
|
client_id?: string;
|
|
7
8
|
email: string;
|
|
@@ -29,20 +30,147 @@ export interface CustomerCartCollectionQuery {
|
|
|
29
30
|
sort_by?: string;
|
|
30
31
|
sort_order?: "asc" | "desc";
|
|
31
32
|
}
|
|
33
|
+
export interface CustomerCartCollectionData {
|
|
34
|
+
links: PaginationLinks;
|
|
35
|
+
items: CustomerCartSummary[];
|
|
36
|
+
count: number;
|
|
37
|
+
total: number;
|
|
38
|
+
page: number;
|
|
39
|
+
totalPage: number;
|
|
40
|
+
perPage: number;
|
|
41
|
+
metadata: unknown[];
|
|
42
|
+
}
|
|
43
|
+
export type CustomerCartCollectionResponse = HttpResponse & {
|
|
44
|
+
data: CustomerCartCollectionData;
|
|
45
|
+
};
|
|
46
|
+
export interface CustomerCartSummary {
|
|
47
|
+
cartId: string;
|
|
48
|
+
reference: string;
|
|
49
|
+
dateCreated: string;
|
|
50
|
+
dateModified: string;
|
|
51
|
+
discountTotal: number;
|
|
52
|
+
discountTax: number;
|
|
53
|
+
shippingTotal: number;
|
|
54
|
+
shippingTax: number;
|
|
55
|
+
cartTax: number;
|
|
56
|
+
total: number;
|
|
57
|
+
totalTax: number;
|
|
58
|
+
customerId: string | null;
|
|
59
|
+
billingInformation: CustomerCartContactInformation | null;
|
|
60
|
+
shippingInformation: CustomerCartContactInformation | null;
|
|
61
|
+
status: string | null;
|
|
62
|
+
paymentMethod: string | null;
|
|
63
|
+
deliveryType: string | null;
|
|
64
|
+
transactionId: string | null;
|
|
65
|
+
customerIpAddress: string | null;
|
|
66
|
+
customerUserAgent: string | null;
|
|
67
|
+
customerNote: string | null;
|
|
68
|
+
cartHash: string | null;
|
|
69
|
+
cartItems: CustomerCartItem[];
|
|
70
|
+
paymentUrl: string | null;
|
|
71
|
+
store: Record<string, unknown> | null;
|
|
72
|
+
}
|
|
73
|
+
export interface CustomerCartContactInformation {
|
|
74
|
+
email?: string | null;
|
|
75
|
+
phoneNumber?: string | null;
|
|
76
|
+
street?: string | null;
|
|
77
|
+
city?: string | null;
|
|
78
|
+
postalCode?: string | null;
|
|
79
|
+
state?: string | null;
|
|
80
|
+
country?: string | null;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
export interface CustomerCartItem {
|
|
84
|
+
id: string;
|
|
85
|
+
productId: string;
|
|
86
|
+
productName: string;
|
|
87
|
+
quantity: number;
|
|
88
|
+
unit: string | null;
|
|
89
|
+
unitPrice: number;
|
|
90
|
+
subtotal: number;
|
|
91
|
+
total: number;
|
|
92
|
+
picture: string | null;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
32
95
|
export interface CustomerProductCollectionQuery {
|
|
33
96
|
page?: number;
|
|
34
97
|
per_page?: number;
|
|
35
98
|
}
|
|
99
|
+
export interface CustomerProductCollectionData {
|
|
100
|
+
links: PaginationLinks;
|
|
101
|
+
items: CustomerProductItem[];
|
|
102
|
+
count: number;
|
|
103
|
+
total: number;
|
|
104
|
+
page: number;
|
|
105
|
+
totalPage: number;
|
|
106
|
+
perPage: number;
|
|
107
|
+
metadata: unknown[];
|
|
108
|
+
}
|
|
109
|
+
export type CustomerProductCollectionResponse = HttpResponse & {
|
|
110
|
+
data: CustomerProductCollectionData;
|
|
111
|
+
};
|
|
112
|
+
export type CustomerProductCreateResponse = HttpResponse & {
|
|
113
|
+
data: CustomerProductItem;
|
|
114
|
+
};
|
|
115
|
+
export type CustomerProductUpdateCategoryResponse = HttpResponse & {
|
|
116
|
+
data: boolean;
|
|
117
|
+
};
|
|
118
|
+
export type CustomerProductRemoveResponse = HttpResponse & {
|
|
119
|
+
data: {
|
|
120
|
+
message: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
export interface CustomerProductItem {
|
|
124
|
+
customerId: string;
|
|
125
|
+
productId: string;
|
|
126
|
+
category: string | null;
|
|
127
|
+
notes: string | null;
|
|
128
|
+
createdAt: string;
|
|
129
|
+
updatedAt: string;
|
|
130
|
+
product: CustomerProductProduct | null;
|
|
131
|
+
}
|
|
132
|
+
export interface CustomerProductProduct {
|
|
133
|
+
id: string;
|
|
134
|
+
barcode: string | null;
|
|
135
|
+
expiryDate: string | null;
|
|
136
|
+
name: string;
|
|
137
|
+
category: string | null;
|
|
138
|
+
subCategory: string | null;
|
|
139
|
+
vatInPercent: number | null;
|
|
140
|
+
unit: string | null;
|
|
141
|
+
volume: number | null;
|
|
142
|
+
quantity: number | null;
|
|
143
|
+
unitWeight: number | null;
|
|
144
|
+
articleWeight: number | null;
|
|
145
|
+
tareWeight: number | null;
|
|
146
|
+
supplier: string | null;
|
|
147
|
+
supplierCode: string | null;
|
|
148
|
+
supplierItemName: string | null;
|
|
149
|
+
picture: string | null;
|
|
150
|
+
slug: string | null;
|
|
151
|
+
internalCode: string | null;
|
|
152
|
+
htmlDescription: string | null;
|
|
153
|
+
inventory: boolean;
|
|
154
|
+
quantityInStock: number | null;
|
|
155
|
+
minimumStockQuantity: number | null;
|
|
156
|
+
pricePurchase: number | null;
|
|
157
|
+
priceToSell: number | null;
|
|
158
|
+
discountInPercent: number | null;
|
|
159
|
+
priceAfterDiscount: number | null;
|
|
160
|
+
priceByWeight: boolean | null;
|
|
161
|
+
}
|
|
36
162
|
export interface CustomerProductCreateRequest {
|
|
37
163
|
product_id: string;
|
|
38
164
|
notes?: string;
|
|
165
|
+
category?: string | null;
|
|
39
166
|
}
|
|
40
167
|
export interface CustomerProductRemoveRequest {
|
|
41
168
|
product_id: string;
|
|
42
169
|
}
|
|
43
|
-
export interface
|
|
44
|
-
product_id: string;
|
|
45
|
-
|
|
170
|
+
export interface CustomerProductUpdateCategoryRequest {
|
|
171
|
+
product_id: string | null;
|
|
172
|
+
old_category: string;
|
|
173
|
+
category: string;
|
|
46
174
|
}
|
|
47
175
|
export declare class CustomerProvider implements ProviderType {
|
|
48
176
|
private readonly config;
|
|
@@ -67,5 +195,5 @@ export declare class CustomerService {
|
|
|
67
195
|
getCustomerProductCollection(query?: CustomerProductCollectionQuery): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
68
196
|
createCustomerProduct(payload: CustomerProductCreateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
69
197
|
removeCustomerProduct(payload: CustomerProductRemoveRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
70
|
-
|
|
198
|
+
updateCustomerProductCategory(payload: CustomerProductUpdateCategoryRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
71
199
|
}
|
|
@@ -23,11 +23,11 @@ export class CustomerProvider {
|
|
|
23
23
|
case "customer-product-collection":
|
|
24
24
|
return "/store/customer-product/collection";
|
|
25
25
|
case "customer-product-create":
|
|
26
|
-
return "/store/customer-product";
|
|
26
|
+
return "/store/customer-product/add";
|
|
27
27
|
case "customer-product-remove":
|
|
28
28
|
return "/store/customer-product/remove";
|
|
29
|
-
case "customer-product-update-
|
|
30
|
-
return "/store/customer-product/
|
|
29
|
+
case "customer-product-update-category":
|
|
30
|
+
return "/store/customer-product/category";
|
|
31
31
|
default:
|
|
32
32
|
return "/authentication/customer";
|
|
33
33
|
}
|
|
@@ -44,7 +44,7 @@ export class CustomerProvider {
|
|
|
44
44
|
return "POST";
|
|
45
45
|
case "customer-product-remove":
|
|
46
46
|
return "DELETE";
|
|
47
|
-
case "customer-product-update-
|
|
47
|
+
case "customer-product-update-category":
|
|
48
48
|
return "PATCH";
|
|
49
49
|
case "update-profile":
|
|
50
50
|
return "PUT";
|
|
@@ -108,7 +108,7 @@ export class CustomerService {
|
|
|
108
108
|
removeCustomerProduct(payload) {
|
|
109
109
|
return this.provider("customer-product-remove").request(payload);
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
return this.provider("customer-product-update-
|
|
111
|
+
updateCustomerProductCategory(payload) {
|
|
112
|
+
return this.provider("customer-product-update-category").request(payload);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -98,8 +98,67 @@ describe("CustomerService", () => {
|
|
|
98
98
|
expect(result?.alertModel).toBeInstanceOf(AlertModel);
|
|
99
99
|
});
|
|
100
100
|
it("getCartCollection success", async () => {
|
|
101
|
+
const cartItem = {
|
|
102
|
+
id: "45bfb315-bc60-11f0-90ea-0242ac120004",
|
|
103
|
+
productId: "352235aa-a6bc-11f0-a3ef-0242ac120004",
|
|
104
|
+
productName: "GARAM MASALA 100G",
|
|
105
|
+
quantity: 2,
|
|
106
|
+
unit: "piece",
|
|
107
|
+
unitPrice: 1.55,
|
|
108
|
+
subtotal: 3.1,
|
|
109
|
+
total: 3.1,
|
|
110
|
+
picture: "https://s3.smeservices.cloud/grandparismarche-fr/2025-04/3276650136216.png",
|
|
111
|
+
};
|
|
112
|
+
const cartSummary = {
|
|
113
|
+
cartId: "45acc017-bc60-11f0-90ea-0242ac120004",
|
|
114
|
+
reference: "ORD-A121C9-220935",
|
|
115
|
+
dateCreated: "2025-11-08 05:03:32",
|
|
116
|
+
dateModified: "2025-11-08 16:08:55",
|
|
117
|
+
discountTotal: 0,
|
|
118
|
+
discountTax: 0,
|
|
119
|
+
shippingTotal: 0,
|
|
120
|
+
shippingTax: 0,
|
|
121
|
+
cartTax: 0,
|
|
122
|
+
total: 13.95,
|
|
123
|
+
totalTax: 0,
|
|
124
|
+
customerId: "244cac49-d014-11ef-8404-0242ac120003",
|
|
125
|
+
billingInformation: null,
|
|
126
|
+
shippingInformation: {
|
|
127
|
+
email: "john.doe@example.com",
|
|
128
|
+
phoneNumber: "+1-555-123-4567",
|
|
129
|
+
street: "123 Main Street",
|
|
130
|
+
city: "san_francisco",
|
|
131
|
+
postalCode: "94105",
|
|
132
|
+
state: "ca",
|
|
133
|
+
country: "us",
|
|
134
|
+
},
|
|
135
|
+
status: "confirmed",
|
|
136
|
+
paymentMethod: "bank_transfer",
|
|
137
|
+
deliveryType: "pickup",
|
|
138
|
+
transactionId: null,
|
|
139
|
+
customerIpAddress: "172.18.0.1",
|
|
140
|
+
customerUserAgent: "IntelliJ HTTP Client/PhpStorm 2024.3.6",
|
|
141
|
+
customerNote: null,
|
|
142
|
+
cartHash: "a121c980b381419d8341556b1f90445c05cbfa4605d6257330df605d20de2c87",
|
|
143
|
+
cartItems: [cartItem],
|
|
144
|
+
paymentUrl: null,
|
|
145
|
+
store: null,
|
|
146
|
+
};
|
|
147
|
+
const data = {
|
|
148
|
+
links: {
|
|
149
|
+
first: "/api/v1/store/cart/collection?per_page=24&page=1",
|
|
150
|
+
last: "/api/v1/store/cart/collection?per_page=24&page=1",
|
|
151
|
+
},
|
|
152
|
+
items: [cartSummary],
|
|
153
|
+
count: 1,
|
|
154
|
+
total: 1,
|
|
155
|
+
page: 1,
|
|
156
|
+
totalPage: 1,
|
|
157
|
+
perPage: 24,
|
|
158
|
+
metadata: [],
|
|
159
|
+
};
|
|
101
160
|
const response = {
|
|
102
|
-
data
|
|
161
|
+
data,
|
|
103
162
|
};
|
|
104
163
|
const requestMock = jest
|
|
105
164
|
.fn()
|
|
@@ -134,8 +193,60 @@ describe("CustomerService", () => {
|
|
|
134
193
|
expect(result?.alertModel).toBeInstanceOf(AlertModel);
|
|
135
194
|
});
|
|
136
195
|
it("getCustomerProductCollection success", async () => {
|
|
196
|
+
const product = {
|
|
197
|
+
id: "504e061d-a6bc-11f0-a3ef-0242ac120004",
|
|
198
|
+
barcode: "8935063610908",
|
|
199
|
+
expiryDate: null,
|
|
200
|
+
name: "AUBERGINE MARINE PIMENTEE NGOC LIEN 400G",
|
|
201
|
+
category: "CONSERVE",
|
|
202
|
+
subCategory: null,
|
|
203
|
+
vatInPercent: 5.5,
|
|
204
|
+
unit: "piece",
|
|
205
|
+
volume: null,
|
|
206
|
+
quantity: 1,
|
|
207
|
+
unitWeight: null,
|
|
208
|
+
articleWeight: null,
|
|
209
|
+
tareWeight: null,
|
|
210
|
+
supplier: "TCHEQUE",
|
|
211
|
+
supplierCode: null,
|
|
212
|
+
supplierItemName: null,
|
|
213
|
+
picture: "https://s3.smeservices.cloud/grandparismarche-fr/2025-04/8935063610908.png",
|
|
214
|
+
slug: "aubergine-marine-pimentee-ngoc-lien-400g-8935063610908",
|
|
215
|
+
internalCode: "5215",
|
|
216
|
+
htmlDescription: null,
|
|
217
|
+
inventory: true,
|
|
218
|
+
quantityInStock: 9,
|
|
219
|
+
minimumStockQuantity: 0,
|
|
220
|
+
pricePurchase: 3.25,
|
|
221
|
+
priceToSell: 3.25,
|
|
222
|
+
discountInPercent: 0,
|
|
223
|
+
priceAfterDiscount: 0,
|
|
224
|
+
priceByWeight: false,
|
|
225
|
+
};
|
|
226
|
+
const item = {
|
|
227
|
+
customerId: "c0e25a90-bc54-11f0-90ea-0242ac120004",
|
|
228
|
+
productId: "504e061d-a6bc-11f0-a3ef-0242ac120004",
|
|
229
|
+
category: "New Cate",
|
|
230
|
+
notes: "Customer note for this favorite product",
|
|
231
|
+
createdAt: "2025-11-08 03:45:51",
|
|
232
|
+
updatedAt: "2025-11-08 03:45:51",
|
|
233
|
+
product,
|
|
234
|
+
};
|
|
235
|
+
const productCollectionData = {
|
|
236
|
+
links: {
|
|
237
|
+
first: "/api/v1/store/customer-product/collection?per_page=24&page=1",
|
|
238
|
+
last: "/api/v1/store/customer-product/collection?per_page=24&page=1",
|
|
239
|
+
},
|
|
240
|
+
items: [item],
|
|
241
|
+
count: 1,
|
|
242
|
+
total: 1,
|
|
243
|
+
page: 1,
|
|
244
|
+
totalPage: 1,
|
|
245
|
+
perPage: 24,
|
|
246
|
+
metadata: [],
|
|
247
|
+
};
|
|
137
248
|
const response = {
|
|
138
|
-
data:
|
|
249
|
+
data: productCollectionData,
|
|
139
250
|
};
|
|
140
251
|
const requestMock = jest
|
|
141
252
|
.fn()
|
|
@@ -169,8 +280,46 @@ describe("CustomerService", () => {
|
|
|
169
280
|
expect(result?.alertModel).toBeInstanceOf(AlertModel);
|
|
170
281
|
});
|
|
171
282
|
it("createCustomerProduct success", async () => {
|
|
283
|
+
const product = {
|
|
284
|
+
id: "504e061d-a6bc-11f0-a3ef-0242ac120004",
|
|
285
|
+
barcode: "8935063610908",
|
|
286
|
+
expiryDate: null,
|
|
287
|
+
name: "AUBERGINE MARINE PIMENTEE NGOC LIEN 400G",
|
|
288
|
+
category: "CONSERVE",
|
|
289
|
+
subCategory: null,
|
|
290
|
+
vatInPercent: 5.5,
|
|
291
|
+
unit: "piece",
|
|
292
|
+
volume: null,
|
|
293
|
+
quantity: 1,
|
|
294
|
+
unitWeight: null,
|
|
295
|
+
articleWeight: null,
|
|
296
|
+
tareWeight: null,
|
|
297
|
+
supplier: "TCHEQUE",
|
|
298
|
+
supplierCode: null,
|
|
299
|
+
supplierItemName: null,
|
|
300
|
+
picture: "https://s3.smeservices.cloud/grandparismarche-fr/2025-04/8935063610908.png",
|
|
301
|
+
slug: "aubergine-marine-pimentee-ngoc-lien-400g-8935063610908",
|
|
302
|
+
internalCode: "5215",
|
|
303
|
+
htmlDescription: null,
|
|
304
|
+
inventory: true,
|
|
305
|
+
quantityInStock: 9,
|
|
306
|
+
minimumStockQuantity: 0,
|
|
307
|
+
pricePurchase: 3.25,
|
|
308
|
+
priceToSell: 3.25,
|
|
309
|
+
discountInPercent: 0,
|
|
310
|
+
priceAfterDiscount: 0,
|
|
311
|
+
priceByWeight: false,
|
|
312
|
+
};
|
|
172
313
|
const response = {
|
|
173
|
-
data: {
|
|
314
|
+
data: {
|
|
315
|
+
customerId: "c0e25a90-bc54-11f0-90ea-0242ac120004",
|
|
316
|
+
productId: "504e061d-a6bc-11f0-a3ef-0242ac120004",
|
|
317
|
+
category: "New Cate",
|
|
318
|
+
notes: "Customer note for this favorite product",
|
|
319
|
+
createdAt: "2025-11-08 03:45:51",
|
|
320
|
+
updatedAt: "2025-11-09 16:34:39",
|
|
321
|
+
product,
|
|
322
|
+
},
|
|
174
323
|
};
|
|
175
324
|
const requestMock = jest
|
|
176
325
|
.fn()
|
|
@@ -181,6 +330,7 @@ describe("CustomerService", () => {
|
|
|
181
330
|
const payload = {
|
|
182
331
|
product_id: "product-123",
|
|
183
332
|
notes: "Customer note for this favorite product",
|
|
333
|
+
category: "New Cate",
|
|
184
334
|
};
|
|
185
335
|
const result = await service.createCustomerProduct(payload).toPromise();
|
|
186
336
|
expect(requestMock).toHaveBeenCalledWith(payload);
|
|
@@ -204,7 +354,11 @@ describe("CustomerService", () => {
|
|
|
204
354
|
expect(result?.alertModel).toBeInstanceOf(AlertModel);
|
|
205
355
|
});
|
|
206
356
|
it("removeCustomerProduct success", async () => {
|
|
207
|
-
const response = {
|
|
357
|
+
const response = {
|
|
358
|
+
data: {
|
|
359
|
+
message: "Favorite removed successfully",
|
|
360
|
+
},
|
|
361
|
+
};
|
|
208
362
|
const requestMock = jest
|
|
209
363
|
.fn()
|
|
210
364
|
.mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
|
|
@@ -234,8 +388,8 @@ describe("CustomerService", () => {
|
|
|
234
388
|
expect(result?.hasFailed).toBe(true);
|
|
235
389
|
expect(result?.alertModel).toBeInstanceOf(AlertModel);
|
|
236
390
|
});
|
|
237
|
-
it("
|
|
238
|
-
const response = { data:
|
|
391
|
+
it("updateCustomerProductCategory success", async () => {
|
|
392
|
+
const response = { data: true };
|
|
239
393
|
const requestMock = jest
|
|
240
394
|
.fn()
|
|
241
395
|
.mockReturnValue(of(NetworkingUIEventWrapped.succeeded(response)));
|
|
@@ -244,16 +398,17 @@ describe("CustomerService", () => {
|
|
|
244
398
|
});
|
|
245
399
|
const payload = {
|
|
246
400
|
product_id: "product-123",
|
|
247
|
-
|
|
401
|
+
old_category: "Standard",
|
|
402
|
+
category: "Preferred",
|
|
248
403
|
};
|
|
249
404
|
const result = await service
|
|
250
|
-
.
|
|
405
|
+
.updateCustomerProductCategory(payload)
|
|
251
406
|
.toPromise();
|
|
252
407
|
expect(requestMock).toHaveBeenCalledWith(payload);
|
|
253
408
|
expect(result?.hasSuccess).toBe(true);
|
|
254
409
|
expect(result?.response).toEqual(response);
|
|
255
410
|
});
|
|
256
|
-
it("
|
|
411
|
+
it("updateCustomerProductCategory error", async () => {
|
|
257
412
|
const requestMock = jest
|
|
258
413
|
.fn()
|
|
259
414
|
.mockReturnValue(of(NetworkingUIEventWrapped.failed(AlertModel.default())));
|
|
@@ -262,10 +417,11 @@ describe("CustomerService", () => {
|
|
|
262
417
|
});
|
|
263
418
|
const payload = {
|
|
264
419
|
product_id: "product-123",
|
|
265
|
-
|
|
420
|
+
old_category: "Standard",
|
|
421
|
+
category: "Preferred",
|
|
266
422
|
};
|
|
267
423
|
const result = await service
|
|
268
|
-
.
|
|
424
|
+
.updateCustomerProductCategory(payload)
|
|
269
425
|
.toPromise();
|
|
270
426
|
expect(requestMock).toHaveBeenCalledWith(payload);
|
|
271
427
|
expect(result?.hasFailed).toBe(true);
|