@smess/networking 1.0.16 → 1.0.18
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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/services/store.cart.service.d.ts +139 -0
- package/dist/services/store.cart.service.js +166 -0
- package/dist/services/store.cart.service.test.d.ts +1 -0
- package/dist/services/store.cart.service.test.js +335 -0
- package/dist/services/store.product.service.d.ts +161 -0
- package/dist/services/store.product.service.js +164 -0
- package/dist/services/store.product.service.test.d.ts +1 -0
- package/dist/services/store.product.service.test.js +388 -0
- package/dist/services/store.service.d.ts +9 -0
- package/dist/services/store.service.js +14 -1
- package/package.json +1 -1
|
@@ -0,0 +1,161 @@
|
|
|
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" | "store-list" | "store-information" | "product-collection" | "product-collection-by-store" | "product-update-batch" | "customer-update-batch" | "cart-update-batch" | "order-item-update-batch";
|
|
5
|
+
export interface StoreProductCollectionRequest {
|
|
6
|
+
page?: number;
|
|
7
|
+
per_page?: number;
|
|
8
|
+
search?: string;
|
|
9
|
+
sort_by?: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
min_price?: number;
|
|
12
|
+
max_price?: number;
|
|
13
|
+
only_discounted?: boolean;
|
|
14
|
+
unit?: string;
|
|
15
|
+
supplier?: string;
|
|
16
|
+
has_offer?: boolean;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface BatchUpdateRequest {
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface PaginationLinks {
|
|
23
|
+
first: string;
|
|
24
|
+
last: string;
|
|
25
|
+
next?: string;
|
|
26
|
+
prev?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface StoreProduct {
|
|
29
|
+
id: string;
|
|
30
|
+
barcode: string;
|
|
31
|
+
expiryDate: string | null;
|
|
32
|
+
name: string;
|
|
33
|
+
category: string;
|
|
34
|
+
subCategory: string | null;
|
|
35
|
+
vatInPercent: number;
|
|
36
|
+
unit: string;
|
|
37
|
+
volume: number | null;
|
|
38
|
+
quantity: number;
|
|
39
|
+
unitWeight: number | null;
|
|
40
|
+
articleWeight: number | null;
|
|
41
|
+
tareWeight: number | null;
|
|
42
|
+
supplier: string | null;
|
|
43
|
+
supplierCode: string | null;
|
|
44
|
+
supplierItemName: string | null;
|
|
45
|
+
picture: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
internalCode: string;
|
|
48
|
+
htmlDescription: string | null;
|
|
49
|
+
inventory: boolean;
|
|
50
|
+
quantityInStock: number;
|
|
51
|
+
minimumStockQuantity: number;
|
|
52
|
+
pricePurchase: number;
|
|
53
|
+
priceToSell: number;
|
|
54
|
+
discountInPercent: number;
|
|
55
|
+
priceAfterDiscount: number;
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface StoreProductCollectionResponse {
|
|
59
|
+
links: PaginationLinks;
|
|
60
|
+
items: StoreProduct[];
|
|
61
|
+
count: number;
|
|
62
|
+
total: number;
|
|
63
|
+
page: number;
|
|
64
|
+
totalPage: number;
|
|
65
|
+
perPage: number;
|
|
66
|
+
metadata: unknown[];
|
|
67
|
+
}
|
|
68
|
+
export interface ProductCategory {
|
|
69
|
+
name: string;
|
|
70
|
+
numberOfProducts: number;
|
|
71
|
+
image: string | null;
|
|
72
|
+
}
|
|
73
|
+
export declare class StoreProductProvider implements ProviderType {
|
|
74
|
+
private readonly config;
|
|
75
|
+
private readonly target;
|
|
76
|
+
constructor(config: NetworkingConfig, target: StoreProductTarget);
|
|
77
|
+
get baseURL(): string;
|
|
78
|
+
get path(): string;
|
|
79
|
+
get method(): string;
|
|
80
|
+
get headers(): Record<string, string>;
|
|
81
|
+
getPath(...queryParams: unknown[]): string;
|
|
82
|
+
}
|
|
83
|
+
export interface StoreProductServiceType {
|
|
84
|
+
getFeaturedProductList(): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
|
|
85
|
+
getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
|
|
86
|
+
getProductCategoryList(): Observable<NetworkingUIEventWrapped<ProductCategory[]>>;
|
|
87
|
+
getProductById(productId: string): Observable<NetworkingUIEventWrapped<StoreProduct>>;
|
|
88
|
+
getStoreList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
89
|
+
getStoreInformation(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
90
|
+
getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
|
|
91
|
+
getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
|
|
92
|
+
updateProductBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
93
|
+
updateCustomerBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
94
|
+
updateCartBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
95
|
+
updateOrderItemBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
96
|
+
}
|
|
97
|
+
export declare class StoreProductService implements StoreProductServiceType {
|
|
98
|
+
private readonly config;
|
|
99
|
+
constructor(config: NetworkingConfig);
|
|
100
|
+
provider(target: StoreProductTarget): SmessService<StoreProductProvider>;
|
|
101
|
+
/**
|
|
102
|
+
* Get featured product list
|
|
103
|
+
* GET /api/v1/store/featured-product-list
|
|
104
|
+
*/
|
|
105
|
+
getFeaturedProductList(): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
|
|
106
|
+
/**
|
|
107
|
+
* Get featured product list by store
|
|
108
|
+
* GET /api/v1/store/{id}/featured-product-list
|
|
109
|
+
*/
|
|
110
|
+
getFeaturedProductListByStore(storeId: string): Observable<NetworkingUIEventWrapped<StoreProduct[]>>;
|
|
111
|
+
/**
|
|
112
|
+
* Get product category list
|
|
113
|
+
* GET /api/v1/store/product-category/list
|
|
114
|
+
*/
|
|
115
|
+
getProductCategoryList(): Observable<NetworkingUIEventWrapped<ProductCategory[]>>;
|
|
116
|
+
/**
|
|
117
|
+
* Get product by ID
|
|
118
|
+
* GET /api/v1/store/product/{id}
|
|
119
|
+
*/
|
|
120
|
+
getProductById(productId: string): Observable<NetworkingUIEventWrapped<StoreProduct>>;
|
|
121
|
+
/**
|
|
122
|
+
* Get store list
|
|
123
|
+
* GET /api/v1/store/list
|
|
124
|
+
*/
|
|
125
|
+
getStoreList(): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
126
|
+
/**
|
|
127
|
+
* Get store information
|
|
128
|
+
* GET /api/v1/store/{id}/information
|
|
129
|
+
*/
|
|
130
|
+
getStoreInformation(storeId: string): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
131
|
+
/**
|
|
132
|
+
* Get product collection
|
|
133
|
+
* GET /api/v1/store/product-collection
|
|
134
|
+
*/
|
|
135
|
+
getProductCollection(payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
|
|
136
|
+
/**
|
|
137
|
+
* Get product collection by store
|
|
138
|
+
* GET /api/v1/store/{id}/product-collection
|
|
139
|
+
*/
|
|
140
|
+
getProductCollectionByStore(storeId: string, payload?: StoreProductCollectionRequest): Observable<NetworkingUIEventWrapped<StoreProductCollectionResponse>>;
|
|
141
|
+
/**
|
|
142
|
+
* Update product batch
|
|
143
|
+
* POST /api/v1/store/{id}/product
|
|
144
|
+
*/
|
|
145
|
+
updateProductBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
146
|
+
/**
|
|
147
|
+
* Update customer batch
|
|
148
|
+
* POST /api/v1/store/{id}/customer/batch
|
|
149
|
+
*/
|
|
150
|
+
updateCustomerBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
151
|
+
/**
|
|
152
|
+
* Update cart batch
|
|
153
|
+
* POST /api/v1/store/{id}/order/batch
|
|
154
|
+
*/
|
|
155
|
+
updateCartBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
156
|
+
/**
|
|
157
|
+
* Update order item batch
|
|
158
|
+
* POST /api/v1/store/{id}/order-item
|
|
159
|
+
*/
|
|
160
|
+
updateOrderItemBatch(storeId: string, payload: BatchUpdateRequest): Observable<NetworkingUIEventWrapped<HttpResponse>>;
|
|
161
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
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 "store-list":
|
|
23
|
+
return "/store/list";
|
|
24
|
+
case "store-information":
|
|
25
|
+
return "/store/${id}/information";
|
|
26
|
+
case "product-collection":
|
|
27
|
+
return "/store/product-collection";
|
|
28
|
+
case "product-collection-by-store":
|
|
29
|
+
return "/store/${id}/product-collection";
|
|
30
|
+
case "product-update-batch":
|
|
31
|
+
return "/store/${id}/product";
|
|
32
|
+
case "customer-update-batch":
|
|
33
|
+
return "/store/${id}/customer/batch";
|
|
34
|
+
case "cart-update-batch":
|
|
35
|
+
return "/store/${id}/order/batch";
|
|
36
|
+
case "order-item-update-batch":
|
|
37
|
+
return "/store/${id}/order-item";
|
|
38
|
+
default:
|
|
39
|
+
return "/store";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get method() {
|
|
43
|
+
switch (this.target) {
|
|
44
|
+
case "product-update-batch":
|
|
45
|
+
case "customer-update-batch":
|
|
46
|
+
case "cart-update-batch":
|
|
47
|
+
case "order-item-update-batch":
|
|
48
|
+
return "POST";
|
|
49
|
+
default:
|
|
50
|
+
return "GET";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
get headers() {
|
|
54
|
+
let headers = SmessService.getHeaders(Accept.V1, null);
|
|
55
|
+
if (this.config.clientId) {
|
|
56
|
+
headers[SMESSHeader.ClientId] = this.config.clientId;
|
|
57
|
+
}
|
|
58
|
+
if (this.config.apiKey) {
|
|
59
|
+
headers[SMESSHeader.ApiKey] = this.config.apiKey;
|
|
60
|
+
}
|
|
61
|
+
return SmessService.filterHeaders(headers);
|
|
62
|
+
}
|
|
63
|
+
getPath(...queryParams) {
|
|
64
|
+
let definedPath = this.path;
|
|
65
|
+
const params = definedPath.match(/\$\{(.+?)\}/g);
|
|
66
|
+
params?.forEach((value, index) => {
|
|
67
|
+
definedPath = definedPath.replace(value, String(queryParams[index]));
|
|
68
|
+
});
|
|
69
|
+
return definedPath;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class StoreProductService {
|
|
73
|
+
constructor(config) {
|
|
74
|
+
this.config = config;
|
|
75
|
+
}
|
|
76
|
+
provider(target) {
|
|
77
|
+
const targetWrapper = new StoreProductProvider(this.config, target);
|
|
78
|
+
return new SmessService(targetWrapper);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get featured product list
|
|
82
|
+
* GET /api/v1/store/featured-product-list
|
|
83
|
+
*/
|
|
84
|
+
getFeaturedProductList() {
|
|
85
|
+
return this.provider("featured-product-list").request();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get featured product list by store
|
|
89
|
+
* GET /api/v1/store/{id}/featured-product-list
|
|
90
|
+
*/
|
|
91
|
+
getFeaturedProductListByStore(storeId) {
|
|
92
|
+
return this.provider("featured-product-list-by-store").request(undefined, undefined, storeId);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get product category list
|
|
96
|
+
* GET /api/v1/store/product-category/list
|
|
97
|
+
*/
|
|
98
|
+
getProductCategoryList() {
|
|
99
|
+
return this.provider("product-category-list").request();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get product by ID
|
|
103
|
+
* GET /api/v1/store/product/{id}
|
|
104
|
+
*/
|
|
105
|
+
getProductById(productId) {
|
|
106
|
+
return this.provider("product-get-by-id").request(undefined, undefined, productId);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get store list
|
|
110
|
+
* GET /api/v1/store/list
|
|
111
|
+
*/
|
|
112
|
+
getStoreList() {
|
|
113
|
+
return this.provider("store-list").request();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get store information
|
|
117
|
+
* GET /api/v1/store/{id}/information
|
|
118
|
+
*/
|
|
119
|
+
getStoreInformation(storeId) {
|
|
120
|
+
return this.provider("store-information").request(undefined, undefined, storeId);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get product collection
|
|
124
|
+
* GET /api/v1/store/product-collection
|
|
125
|
+
*/
|
|
126
|
+
getProductCollection(payload) {
|
|
127
|
+
return this.provider("product-collection").request(null, undefined, undefined, payload);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get product collection by store
|
|
131
|
+
* GET /api/v1/store/{id}/product-collection
|
|
132
|
+
*/
|
|
133
|
+
getProductCollectionByStore(storeId, payload) {
|
|
134
|
+
return this.provider("product-collection-by-store").request(null, undefined, storeId, payload);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Update product batch
|
|
138
|
+
* POST /api/v1/store/{id}/product
|
|
139
|
+
*/
|
|
140
|
+
updateProductBatch(storeId, payload) {
|
|
141
|
+
return this.provider("product-update-batch").request(payload, undefined, storeId);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Update customer batch
|
|
145
|
+
* POST /api/v1/store/{id}/customer/batch
|
|
146
|
+
*/
|
|
147
|
+
updateCustomerBatch(storeId, payload) {
|
|
148
|
+
return this.provider("customer-update-batch").request(payload, undefined, storeId);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Update cart batch
|
|
152
|
+
* POST /api/v1/store/{id}/order/batch
|
|
153
|
+
*/
|
|
154
|
+
updateCartBatch(storeId, payload) {
|
|
155
|
+
return this.provider("cart-update-batch").request(payload, undefined, storeId);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Update order item batch
|
|
159
|
+
* POST /api/v1/store/{id}/order-item
|
|
160
|
+
*/
|
|
161
|
+
updateOrderItemBatch(storeId, payload) {
|
|
162
|
+
return this.provider("order-item-update-batch").request(payload, undefined, storeId);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|