@smess/networking 1.0.23 → 1.0.25

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.
Files changed (85) hide show
  1. package/dist/scripts/dev-test.d.ts +1 -0
  2. package/dist/scripts/dev-test.js +803 -0
  3. package/dist/scripts/real-test.d.ts +1 -0
  4. package/dist/scripts/real-test.js +341 -0
  5. package/dist/src/core/axios.d.ts +51 -0
  6. package/dist/src/core/axios.js +65 -0
  7. package/dist/src/core/axios.observable.d.ts +11 -0
  8. package/dist/src/core/axios.observable.js +58 -0
  9. package/dist/src/core/base.provider.advanced.test.d.ts +1 -0
  10. package/dist/src/core/base.provider.advanced.test.js +29 -0
  11. package/dist/src/core/base.provider.d.ts +15 -0
  12. package/dist/src/core/base.provider.js +13 -0
  13. package/dist/src/core/base.provider.test.d.ts +1 -0
  14. package/dist/src/core/base.provider.test.js +36 -0
  15. package/dist/src/core/base.service.wrapper.advanced.test.d.ts +1 -0
  16. package/dist/src/core/base.service.wrapper.advanced.test.js +39 -0
  17. package/dist/src/core/base.service.wrapper.d.ts +7 -0
  18. package/dist/src/core/base.service.wrapper.js +11 -0
  19. package/dist/src/core/base.service.wrapper.test.d.ts +1 -0
  20. package/dist/src/core/base.service.wrapper.test.js +25 -0
  21. package/dist/src/core/rx.http.service.d.ts +51 -0
  22. package/dist/src/core/rx.http.service.js +65 -0
  23. package/dist/src/index.d.ts +19 -0
  24. package/dist/src/index.js +23 -0
  25. package/dist/src/services/auth.service.d.ts +65 -0
  26. package/dist/src/services/auth.service.js +197 -0
  27. package/dist/src/services/auth.service.test.d.ts +1 -0
  28. package/dist/src/services/auth.service.test.js +334 -0
  29. package/dist/src/services/cache.service.d.ts +31 -0
  30. package/dist/src/services/cache.service.js +77 -0
  31. package/dist/src/services/cache.service.test.d.ts +1 -0
  32. package/dist/src/services/cache.service.test.js +88 -0
  33. package/dist/src/services/customer.service.d.ts +71 -0
  34. package/dist/src/services/customer.service.js +114 -0
  35. package/dist/src/services/customer.service.test.d.ts +1 -0
  36. package/dist/src/services/customer.service.test.js +274 -0
  37. package/dist/src/services/employee.service.d.ts +73 -0
  38. package/dist/src/services/employee.service.js +74 -0
  39. package/dist/src/services/employee.service.test.d.ts +1 -0
  40. package/dist/src/services/employee.service.test.js +127 -0
  41. package/dist/src/services/logger.service.d.ts +31 -0
  42. package/dist/src/services/logger.service.js +93 -0
  43. package/dist/src/services/logger.service.test.d.ts +1 -0
  44. package/dist/src/services/logger.service.test.js +31 -0
  45. package/dist/src/services/order.service.d.ts +73 -0
  46. package/dist/src/services/order.service.js +97 -0
  47. package/dist/src/services/order.service.test.d.ts +1 -0
  48. package/dist/src/services/order.service.test.js +163 -0
  49. package/dist/src/services/product.service.d.ts +21 -0
  50. package/dist/src/services/product.service.js +42 -0
  51. package/dist/src/services/product.service.test.d.ts +1 -0
  52. package/dist/src/services/product.service.test.js +61 -0
  53. package/dist/src/services/smess.service.d.ts +36 -0
  54. package/dist/src/services/smess.service.js +128 -0
  55. package/dist/src/services/smess.service.test.d.ts +1 -0
  56. package/dist/src/services/smess.service.test.js +103 -0
  57. package/dist/src/services/store.cart.service.d.ts +158 -0
  58. package/dist/src/services/store.cart.service.js +177 -0
  59. package/dist/src/services/store.cart.service.test.d.ts +1 -0
  60. package/dist/src/services/store.cart.service.test.js +394 -0
  61. package/dist/src/services/store.product.service.d.ts +123 -0
  62. package/dist/src/services/store.product.service.js +102 -0
  63. package/dist/src/services/store.product.service.test.d.ts +1 -0
  64. package/dist/src/services/store.product.service.test.js +319 -0
  65. package/dist/src/services/store.service.d.ts +79 -0
  66. package/dist/src/services/store.service.js +235 -0
  67. package/dist/src/services/store.service.test.d.ts +1 -0
  68. package/dist/src/services/store.service.test.js +274 -0
  69. package/dist/src/services/user.service.d.ts +16 -0
  70. package/dist/src/services/user.service.js +37 -0
  71. package/dist/src/services/user.service.test.d.ts +1 -0
  72. package/dist/src/services/user.service.test.js +52 -0
  73. package/dist/src/services/utils/withAuthReset.d.ts +3 -0
  74. package/dist/src/services/utils/withAuthReset.js +8 -0
  75. package/dist/src/types/types.d.ts +93 -0
  76. package/dist/src/types/types.js +82 -0
  77. package/dist/src/types/types.test.d.ts +1 -0
  78. package/dist/src/types/types.test.js +25 -0
  79. package/dist/src/utils/cache-import.d.ts +3 -0
  80. package/dist/src/utils/cache-import.js +2 -0
  81. package/dist/src/utils/networking-import.d.ts +4 -0
  82. package/dist/src/utils/networking-import.js +3 -0
  83. package/dist/src/utils/rxjs-import.d.ts +5 -0
  84. package/dist/src/utils/rxjs-import.js +5 -0
  85. package/package.json +1 -1
@@ -0,0 +1,394 @@
1
+ import { StoreCartService, StoreCartProvider, } from "./store.cart.service";
2
+ import { NetworkingUIEventWrapped, AlertModel, } from "../types/types";
3
+ import { BehaviorSubject, of } from "rxjs";
4
+ describe("StoreCartService", () => {
5
+ const config = {
6
+ baseUrl: "https://api.example.com",
7
+ isProd: false,
8
+ clientId: "test-client-id",
9
+ apiKey: "test-api-key",
10
+ };
11
+ let service;
12
+ beforeEach(() => {
13
+ service = new StoreCartService(config);
14
+ });
15
+ it("should initialize with null cartHash and storeId", () => {
16
+ expect(service.currentCartHash).toBe(null);
17
+ expect(service.cartHash$.value).toBe(null);
18
+ expect(service.currentStoreId).toBe(null);
19
+ expect(service.storeId$.value).toBe(null);
20
+ });
21
+ it("should initialize with provided storeId BehaviorSubject", () => {
22
+ const storeId = "store-123";
23
+ const $storeId = new BehaviorSubject(storeId);
24
+ const serviceWithStore = new StoreCartService(config, $storeId);
25
+ expect(serviceWithStore.currentStoreId).toBe(storeId);
26
+ expect(serviceWithStore.storeId$.value).toBe(storeId);
27
+ });
28
+ it("should update storeId dynamically", () => {
29
+ expect(service.currentStoreId).toBe(null);
30
+ service.setStoreId("store-456");
31
+ expect(service.currentStoreId).toBe("store-456");
32
+ expect(service.storeId$.value).toBe("store-456");
33
+ });
34
+ describe("getCart", () => {
35
+ it("should get cart successfully and update cartHash", async () => {
36
+ const cart = {
37
+ dateCreated: "2025-10-14 12:56:31",
38
+ dateModified: "2025-10-14 12:56:31",
39
+ discountTotal: 0,
40
+ discountTax: 0,
41
+ shippingTotal: 0,
42
+ shippingTax: 0,
43
+ cartTax: 0,
44
+ total: 20.0,
45
+ totalTax: 0,
46
+ customerId: "cust-123",
47
+ billingInformation: null,
48
+ shippingInformation: null,
49
+ paymentMethod: "cash",
50
+ deliveryType: "pickup",
51
+ transactionId: null,
52
+ customerIpAddress: "172.18.0.1",
53
+ customerUserAgent: "Test Agent",
54
+ customerNote: null,
55
+ cartHash: "test-hash-123",
56
+ cartItems: [
57
+ {
58
+ id: "item-1",
59
+ productId: "prod-1",
60
+ name: "Test Product",
61
+ quantity: 2,
62
+ price: 10.0,
63
+ total: 20.0,
64
+ },
65
+ ],
66
+ paymentUrl: null,
67
+ store: null,
68
+ };
69
+ jest.spyOn(service, "provider").mockReturnValue({
70
+ request: () => of(NetworkingUIEventWrapped.succeeded(cart)),
71
+ });
72
+ const result = await service.getCart().toPromise();
73
+ expect(result?.hasSuccess).toBe(true);
74
+ expect(result?.response).toEqual(cart);
75
+ expect(service.currentCartHash).toBe("test-hash-123");
76
+ });
77
+ it("should handle getCart error", async () => {
78
+ jest.spyOn(service, "provider").mockReturnValue({
79
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
80
+ });
81
+ const result = await service.getCart().toPromise();
82
+ expect(result?.hasFailed).toBe(true);
83
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
84
+ });
85
+ });
86
+ describe("updateCart", () => {
87
+ it("should update cart successfully", async () => {
88
+ const payload = {
89
+ status: "submitted",
90
+ customer_note: "Customer Note Example",
91
+ customer_id: "f1df6e9a-0160-11f0-82c2-6cac1a7e2953",
92
+ payment_method: "bank_transfer",
93
+ delivery_type: "delivery",
94
+ billing_information: {
95
+ email: "billing@example.com",
96
+ phone_number: "+1-555-111-2222",
97
+ street: "456 Market Street",
98
+ city: "san_francisco",
99
+ postal_code: "94103",
100
+ state: "ca",
101
+ country: "us",
102
+ },
103
+ shipping_information: {
104
+ email: "john.doe@example.com",
105
+ phone_number: "+1-555-123-4567",
106
+ street: "123 Main Street",
107
+ city: "san_francisco",
108
+ postal_code: "94105",
109
+ state: "ca",
110
+ country: "us",
111
+ },
112
+ };
113
+ const cart = {
114
+ dateCreated: "2025-10-14 12:56:31",
115
+ dateModified: "2025-10-14 12:56:31",
116
+ discountTotal: 0,
117
+ discountTax: 0,
118
+ shippingTotal: 0,
119
+ shippingTax: 0,
120
+ cartTax: 0,
121
+ total: 0,
122
+ totalTax: 0,
123
+ customerId: null,
124
+ billingInformation: null,
125
+ shippingInformation: null,
126
+ paymentMethod: "cash",
127
+ deliveryType: "pickup",
128
+ transactionId: null,
129
+ customerIpAddress: "172.18.0.1",
130
+ customerUserAgent: "Test Agent",
131
+ customerNote: "Please deliver in the evening",
132
+ cartHash: "test-hash",
133
+ cartItems: [],
134
+ paymentUrl: null,
135
+ store: null,
136
+ };
137
+ jest.spyOn(service, "provider").mockReturnValue({
138
+ request: () => of(NetworkingUIEventWrapped.succeeded(cart)),
139
+ });
140
+ const result = await service.updateCart(payload).toPromise();
141
+ expect(result?.hasSuccess).toBe(true);
142
+ expect(result?.response).toEqual(cart);
143
+ });
144
+ it("should handle updateCart error", async () => {
145
+ const payload = {
146
+ status: "invalid_status",
147
+ };
148
+ jest.spyOn(service, "provider").mockReturnValue({
149
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
150
+ });
151
+ const result = await service.updateCart(payload).toPromise();
152
+ expect(result?.hasFailed).toBe(true);
153
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
154
+ });
155
+ });
156
+ describe("addItem", () => {
157
+ it("should add item to cart successfully", async () => {
158
+ const payload = {
159
+ product_id: "prod-123",
160
+ quantity: 3,
161
+ };
162
+ const cart = {
163
+ dateCreated: "2025-10-14 12:56:31",
164
+ dateModified: "2025-10-14 12:56:31",
165
+ discountTotal: 0,
166
+ discountTax: 0,
167
+ shippingTotal: 0,
168
+ shippingTax: 0,
169
+ cartTax: 0,
170
+ total: 45.0,
171
+ totalTax: 0,
172
+ customerId: null,
173
+ billingInformation: null,
174
+ shippingInformation: null,
175
+ paymentMethod: "cash",
176
+ deliveryType: "pickup",
177
+ transactionId: null,
178
+ customerIpAddress: "172.18.0.1",
179
+ customerUserAgent: "Test Agent",
180
+ customerNote: null,
181
+ cartHash: "test-hash",
182
+ cartItems: [
183
+ {
184
+ id: "item-1",
185
+ productId: "prod-123",
186
+ quantity: 3,
187
+ price: 15.0,
188
+ total: 45.0,
189
+ },
190
+ ],
191
+ paymentUrl: null,
192
+ store: null,
193
+ };
194
+ jest.spyOn(service, "provider").mockReturnValue({
195
+ request: () => of(NetworkingUIEventWrapped.succeeded(cart)),
196
+ });
197
+ const result = await service.addItem(payload).toPromise();
198
+ expect(result?.hasSuccess).toBe(true);
199
+ expect(result?.response).toEqual(cart);
200
+ });
201
+ it("should handle addItem error", async () => {
202
+ const payload = {
203
+ product_id: "prod-999",
204
+ quantity: 1,
205
+ };
206
+ jest.spyOn(service, "provider").mockReturnValue({
207
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
208
+ });
209
+ const result = await service.addItem(payload).toPromise();
210
+ expect(result?.hasFailed).toBe(true);
211
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
212
+ });
213
+ });
214
+ describe("batchItems", () => {
215
+ it("should batch create/update items successfully and update cartHash", async () => {
216
+ const payload = {
217
+ create: [
218
+ { product_id: "prod-111", quantity: 2 },
219
+ { product_id: "prod-222", quantity: 1 },
220
+ ],
221
+ update: [
222
+ { product_id: "prod-333", quantity: 5 },
223
+ ],
224
+ };
225
+ const cart = {
226
+ dateCreated: "2025-10-14 12:56:31",
227
+ dateModified: "2025-10-14 12:56:31",
228
+ discountTotal: 0,
229
+ discountTax: 0,
230
+ shippingTotal: 0,
231
+ shippingTax: 0,
232
+ cartTax: 0,
233
+ total: 100.0,
234
+ totalTax: 0,
235
+ customerId: null,
236
+ billingInformation: null,
237
+ shippingInformation: null,
238
+ paymentMethod: "cash",
239
+ deliveryType: "pickup",
240
+ transactionId: null,
241
+ customerIpAddress: "172.18.0.1",
242
+ customerUserAgent: "Test Agent",
243
+ customerNote: null,
244
+ cartHash: "hash-batch-123",
245
+ cartItems: [
246
+ { id: "item-1", productId: "prod-111", quantity: 2, price: 10, total: 20 },
247
+ { id: "item-2", productId: "prod-222", quantity: 1, price: 30, total: 30 },
248
+ { id: "item-3", productId: "prod-333", quantity: 5, price: 10, total: 50 },
249
+ ],
250
+ paymentUrl: null,
251
+ store: null,
252
+ };
253
+ jest.spyOn(service, "provider").mockReturnValue({
254
+ request: () => of(NetworkingUIEventWrapped.succeeded(cart)),
255
+ });
256
+ const result = await service.batchItems(payload).toPromise();
257
+ expect(result?.hasSuccess).toBe(true);
258
+ expect(result?.response).toEqual(cart);
259
+ expect(service.currentCartHash).toBe("hash-batch-123");
260
+ });
261
+ it("should handle batchItems error", async () => {
262
+ const payload = {
263
+ create: [{ product_id: "invalid", quantity: 0 }],
264
+ };
265
+ jest.spyOn(service, "provider").mockReturnValue({
266
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
267
+ });
268
+ const result = await service.batchItems(payload).toPromise();
269
+ expect(result?.hasFailed).toBe(true);
270
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
271
+ });
272
+ });
273
+ describe("updateItemQuantity", () => {
274
+ it("should update item quantity successfully", async () => {
275
+ const itemId = "item-123";
276
+ const payload = {
277
+ quantity: 5,
278
+ };
279
+ const cart = {
280
+ dateCreated: "2025-10-14 12:56:31",
281
+ dateModified: "2025-10-14 12:56:31",
282
+ discountTotal: 0,
283
+ discountTax: 0,
284
+ shippingTotal: 0,
285
+ shippingTax: 0,
286
+ cartTax: 0,
287
+ total: 75.0,
288
+ totalTax: 0,
289
+ customerId: null,
290
+ billingInformation: null,
291
+ shippingInformation: null,
292
+ paymentMethod: "cash",
293
+ deliveryType: "pickup",
294
+ transactionId: null,
295
+ customerIpAddress: "172.18.0.1",
296
+ customerUserAgent: "Test Agent",
297
+ customerNote: null,
298
+ cartHash: "test-hash",
299
+ cartItems: [
300
+ {
301
+ id: itemId,
302
+ productId: "prod-123",
303
+ quantity: 5,
304
+ price: 15.0,
305
+ total: 75.0,
306
+ },
307
+ ],
308
+ paymentUrl: null,
309
+ store: null,
310
+ };
311
+ jest.spyOn(service, "provider").mockReturnValue({
312
+ request: () => of(NetworkingUIEventWrapped.succeeded(cart)),
313
+ });
314
+ const result = await service.updateItemQuantity(itemId, payload).toPromise();
315
+ expect(result?.hasSuccess).toBe(true);
316
+ expect(result?.response).toEqual(cart);
317
+ });
318
+ it("should handle updateItemQuantity error", async () => {
319
+ const itemId = "item-999";
320
+ const payload = {
321
+ quantity: 5,
322
+ };
323
+ jest.spyOn(service, "provider").mockReturnValue({
324
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
325
+ });
326
+ const result = await service.updateItemQuantity(itemId, payload).toPromise();
327
+ expect(result?.hasFailed).toBe(true);
328
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
329
+ });
330
+ });
331
+ describe("deleteItem", () => {
332
+ it("should delete item from cart successfully", async () => {
333
+ const itemId = "item-123";
334
+ jest.spyOn(service, "provider").mockReturnValue({
335
+ request: () => of(NetworkingUIEventWrapped.succeeded(undefined)),
336
+ });
337
+ const result = await service.deleteItem(itemId).toPromise();
338
+ expect(result?.hasSuccess).toBe(true);
339
+ });
340
+ it("should handle deleteItem error", async () => {
341
+ const itemId = "item-999";
342
+ jest.spyOn(service, "provider").mockReturnValue({
343
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
344
+ });
345
+ const result = await service.deleteItem(itemId).toPromise();
346
+ expect(result?.hasFailed).toBe(true);
347
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
348
+ });
349
+ });
350
+ describe("deleteAllItems", () => {
351
+ it("should delete all items from cart successfully", async () => {
352
+ jest.spyOn(service, "provider").mockReturnValue({
353
+ request: () => of(NetworkingUIEventWrapped.succeeded(undefined)),
354
+ });
355
+ const result = await service.deleteAllItems().toPromise();
356
+ expect(result?.hasSuccess).toBe(true);
357
+ });
358
+ it("should handle deleteAllItems error", async () => {
359
+ jest.spyOn(service, "provider").mockReturnValue({
360
+ request: () => of(NetworkingUIEventWrapped.failed(AlertModel.default())),
361
+ });
362
+ const result = await service.deleteAllItems().toPromise();
363
+ expect(result?.hasFailed).toBe(true);
364
+ expect(result?.alertModel).toBeInstanceOf(AlertModel);
365
+ });
366
+ });
367
+ describe("headers", () => {
368
+ it("should include X-Store-Id header when storeId is set", () => {
369
+ const storeId = "store-123";
370
+ const cartHash = "cart-hash-456";
371
+ const $cartHashSubject = new BehaviorSubject(cartHash);
372
+ const $storeIdSubject = new BehaviorSubject(storeId);
373
+ const provider = new StoreCartProvider(config, "cart-get", $cartHashSubject, $storeIdSubject);
374
+ const headers = provider.headers;
375
+ expect(headers["X-Store-Id"]).toBe(storeId);
376
+ expect(headers["X-Nonce-Token"]).toBe(cartHash);
377
+ });
378
+ it("should not include X-Store-Id header when storeId is null", () => {
379
+ const $cartHashSubject = new BehaviorSubject(null);
380
+ const $storeIdSubject = new BehaviorSubject(null);
381
+ const provider = new StoreCartProvider(config, "cart-get", $cartHashSubject, $storeIdSubject);
382
+ const headers = provider.headers;
383
+ expect(headers["X-Store-Id"]).toBeUndefined();
384
+ });
385
+ it("should include X-Nonce-Token header when cartHash is set", () => {
386
+ const cartHash = "cart-hash-789";
387
+ const $cartHashSubject = new BehaviorSubject(cartHash);
388
+ const $storeIdSubject = new BehaviorSubject(null);
389
+ const provider = new StoreCartProvider(config, "cart-get", $cartHashSubject, $storeIdSubject);
390
+ const headers = provider.headers;
391
+ expect(headers["X-Nonce-Token"]).toBe(cartHash);
392
+ });
393
+ });
394
+ });
@@ -0,0 +1,123 @@
1
+ import { ProviderType, NetworkingConfig, NetworkingUIEventWrapped, HttpResponse } from "../types/types";
2
+ import { SmessService } from "./smess.service";
3
+ import { Observable } from "rxjs";
4
+ export type StoreProductTarget = "featured-product-list" | "featured-product-list-by-store" | "product-category-list" | "product-get-by-id" | "product-collection" | "product-collection-by-store";
5
+ export interface StoreProductCollectionRequest {
6
+ page?: number;
7
+ per_page?: number;
8
+ search?: string;
9
+ sort_by?: string;
10
+ category?: string;
11
+ group?: string;
12
+ min_price?: number;
13
+ max_price?: number;
14
+ only_discounted?: boolean;
15
+ unit?: string;
16
+ supplier?: string;
17
+ has_offer?: boolean;
18
+ [key: string]: unknown;
19
+ }
20
+ export interface PaginationLinks {
21
+ first: string;
22
+ last: string;
23
+ next?: string;
24
+ prev?: string;
25
+ }
26
+ export interface StoreProduct {
27
+ id: string;
28
+ barcode: string;
29
+ expiryDate: string | null;
30
+ name: string;
31
+ category: string;
32
+ subCategory: string | null;
33
+ vatInPercent: number;
34
+ unit: string;
35
+ volume: number | null;
36
+ quantity: number;
37
+ unitWeight: number | null;
38
+ articleWeight: number | null;
39
+ tareWeight: number | null;
40
+ supplier: string | null;
41
+ supplierCode: string | null;
42
+ supplierItemName: string | null;
43
+ picture: string;
44
+ slug: string;
45
+ internalCode: string;
46
+ htmlDescription: string | null;
47
+ inventory: boolean;
48
+ quantityInStock: number;
49
+ minimumStockQuantity: number;
50
+ pricePurchase: number;
51
+ priceToSell: number;
52
+ discountInPercent: number;
53
+ priceAfterDiscount: number;
54
+ [key: string]: unknown;
55
+ }
56
+ export interface StoreProductCollectionResponse {
57
+ links: PaginationLinks;
58
+ items: StoreProduct[];
59
+ count: number;
60
+ total: number;
61
+ page: number;
62
+ totalPage: number;
63
+ perPage: number;
64
+ metadata: unknown[];
65
+ }
66
+ export interface ProductCategory {
67
+ name: string;
68
+ numberOfProducts: number;
69
+ image: string | null;
70
+ }
71
+ export declare class StoreProductProvider implements ProviderType {
72
+ private readonly config;
73
+ private readonly target;
74
+ constructor(config: NetworkingConfig, target: StoreProductTarget);
75
+ get baseURL(): string;
76
+ get path(): string;
77
+ get method(): string;
78
+ get headers(): Record<string, string>;
79
+ getPath(...queryParams: unknown[]): string;
80
+ }
81
+ export interface StoreProductServiceType {
82
+ getFeaturedProductList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
83
+ getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
84
+ getProductCategoryList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
85
+ getProductById(productId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
86
+ getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
87
+ getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
88
+ }
89
+ export declare class StoreProductService implements StoreProductServiceType {
90
+ private readonly config;
91
+ constructor(config: NetworkingConfig);
92
+ provider(target: StoreProductTarget): SmessService<StoreProductProvider>;
93
+ /**
94
+ * Get featured product list
95
+ * GET /api/v1/store/featured-product-list
96
+ */
97
+ getFeaturedProductList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
98
+ /**
99
+ * Get featured product list by store
100
+ * GET /api/v1/store/{id}/featured-product-list
101
+ */
102
+ getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
103
+ /**
104
+ * Get product category list
105
+ * GET /api/v1/store/product-category/list
106
+ */
107
+ getProductCategoryList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
108
+ /**
109
+ * Get product by ID
110
+ * GET /api/v1/store/product/{id}
111
+ */
112
+ getProductById(productId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
113
+ /**
114
+ * Get product collection
115
+ * GET /api/v1/store/product-collection
116
+ */
117
+ getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
118
+ /**
119
+ * Get product collection by store
120
+ * GET /api/v1/store/{id}/product-collection
121
+ */
122
+ getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
123
+ }
@@ -0,0 +1,102 @@
1
+ import { Accept, SMESSHeader, SmessService } from "./smess.service";
2
+ export class StoreProductProvider {
3
+ constructor(config, target) {
4
+ this.config = config;
5
+ this.target = target;
6
+ }
7
+ get baseURL() {
8
+ return this.config.version
9
+ ? `${this.config.baseUrl}/${this.config.version}`
10
+ : this.config.baseUrl;
11
+ }
12
+ get path() {
13
+ switch (this.target) {
14
+ case "featured-product-list":
15
+ return "/store/featured-product-list";
16
+ case "featured-product-list-by-store":
17
+ return "/store/${id}/featured-product-list";
18
+ case "product-category-list":
19
+ return "/store/product-category/list";
20
+ case "product-get-by-id":
21
+ return "/store/product/${id}";
22
+ case "product-collection":
23
+ return "/store/product-collection";
24
+ case "product-collection-by-store":
25
+ return "/store/${id}/product-collection";
26
+ default:
27
+ return "/store";
28
+ }
29
+ }
30
+ get method() {
31
+ return "GET";
32
+ }
33
+ get headers() {
34
+ let headers = SmessService.getHeaders(Accept.V1, null);
35
+ if (this.config.clientId) {
36
+ headers[SMESSHeader.ClientId] = this.config.clientId;
37
+ }
38
+ if (this.config.apiKey) {
39
+ headers[SMESSHeader.ApiKey] = this.config.apiKey;
40
+ }
41
+ return SmessService.filterHeaders(headers);
42
+ }
43
+ getPath(...queryParams) {
44
+ let definedPath = this.path;
45
+ const params = definedPath.match(/\$\{(.+?)\}/g);
46
+ params?.forEach((value, index) => {
47
+ definedPath = definedPath.replace(value, String(queryParams[index]));
48
+ });
49
+ return definedPath;
50
+ }
51
+ }
52
+ export class StoreProductService {
53
+ constructor(config) {
54
+ this.config = config;
55
+ }
56
+ provider(target) {
57
+ const targetWrapper = new StoreProductProvider(this.config, target);
58
+ return new SmessService(targetWrapper);
59
+ }
60
+ /**
61
+ * Get featured product list
62
+ * GET /api/v1/store/featured-product-list
63
+ */
64
+ getFeaturedProductList() {
65
+ return this.provider("featured-product-list").request();
66
+ }
67
+ /**
68
+ * Get featured product list by store
69
+ * GET /api/v1/store/{id}/featured-product-list
70
+ */
71
+ getFeaturedProductListByStore(storeId) {
72
+ return this.provider("featured-product-list-by-store").request(undefined, undefined, storeId);
73
+ }
74
+ /**
75
+ * Get product category list
76
+ * GET /api/v1/store/product-category/list
77
+ */
78
+ getProductCategoryList() {
79
+ return this.provider("product-category-list").request();
80
+ }
81
+ /**
82
+ * Get product by ID
83
+ * GET /api/v1/store/product/{id}
84
+ */
85
+ getProductById(productId) {
86
+ return this.provider("product-get-by-id").request(undefined, undefined, productId);
87
+ }
88
+ /**
89
+ * Get product collection
90
+ * GET /api/v1/store/product-collection
91
+ */
92
+ getProductCollection(payload) {
93
+ return this.provider("product-collection").request(payload, undefined, undefined);
94
+ }
95
+ /**
96
+ * Get product collection by store
97
+ * GET /api/v1/store/{id}/product-collection
98
+ */
99
+ getProductCollectionByStore(storeId, payload) {
100
+ return this.provider("product-collection-by-store").request(payload, undefined, storeId);
101
+ }
102
+ }
@@ -0,0 +1 @@
1
+ export {};