@chift/chift-nodejs 1.0.5 → 1.0.6
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/.eslintcache +1 -1
- package/CHANGELOG.md +4 -0
- package/dist/src/modules/api.d.ts +855 -420
- package/dist/src/modules/consumer.d.ts +56 -28
- package/dist/src/modules/consumers.d.ts +285 -140
- package/dist/src/modules/internalApi.js +10 -5
- package/dist/src/modules/pos.d.ts +4 -0
- package/dist/src/modules/pos.js +14 -0
- package/dist/src/modules/sync.d.ts +229 -113
- package/dist/src/modules/syncs.d.ts +570 -280
- package/dist/test/modules/pos.test.js +13 -0
- package/jest.config.ts +1 -1
- package/package.json +1 -1
- package/src/modules/pos.ts +26 -0
- package/src/modules/sync.ts +1 -1
- package/src/modules/syncs.ts +2 -2
- package/src/types/public-api/schema.d.ts +426 -80
- package/test/modules/consumer.test.ts +1 -1
- package/test/modules/pos.test.ts +15 -0
|
@@ -45,11 +45,14 @@ const client = new chift.API({
|
|
|
45
45
|
// Split testing between two APIs to support all endpoints
|
|
46
46
|
const cashpadConsumerId = process.env.CHIFT_CASHPAD_CONSUMER_ID;
|
|
47
47
|
const lightspeedConsumerId = process.env.CHIFT_LIGHTSPEED_CONSUMER_ID;
|
|
48
|
+
const zeltyConsumerId = process.env.CHIFT_ZELTY_CONSUMER_ID;
|
|
48
49
|
let cashpadConsumer;
|
|
49
50
|
let lightspeedConsumer;
|
|
51
|
+
let zeltyConsumer;
|
|
50
52
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
53
|
cashpadConsumer = yield client.Consumers.getConsumerById(cashpadConsumerId);
|
|
52
54
|
lightspeedConsumer = yield client.Consumers.getConsumerById(lightspeedConsumerId);
|
|
55
|
+
zeltyConsumer = yield client.Consumers.getConsumerById(zeltyConsumerId);
|
|
53
56
|
}));
|
|
54
57
|
(0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
58
|
const locations = yield lightspeedConsumer.pos.getLocations();
|
|
@@ -162,3 +165,13 @@ globals_1.test.skip('updateOrder', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
162
165
|
(0, globals_1.expect)(order).toBeTruthy();
|
|
163
166
|
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
164
167
|
}));
|
|
168
|
+
(0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
+
const products = yield zeltyConsumer.pos.getProducts();
|
|
170
|
+
(0, globals_1.expect)(products).toBeInstanceOf(Array);
|
|
171
|
+
(0, globals_1.expect)(products.length).toBeGreaterThan(0);
|
|
172
|
+
}));
|
|
173
|
+
(0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
+
const productCategories = yield zeltyConsumer.pos.getProductCategories();
|
|
175
|
+
(0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
|
|
176
|
+
(0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
|
|
177
|
+
}));
|
package/jest.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chift/chift-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "The Chift NodeJS library provides convenient access to the Chift API from applications written in the NodeJS language (Javascript/Typescript).",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
package/src/modules/pos.ts
CHANGED
|
@@ -11,6 +11,16 @@ type getPaymentMethodsParams = Omit<
|
|
|
11
11
|
'page' | 'size'
|
|
12
12
|
>;
|
|
13
13
|
|
|
14
|
+
type getProductCategoriesParams = Omit<
|
|
15
|
+
operations['pos_get_product_categories']['parameters']['query'],
|
|
16
|
+
'page' | 'size'
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
type getProductsParams = Omit<
|
|
20
|
+
operations['pos_get_products']['parameters']['query'],
|
|
21
|
+
'page' | 'size'
|
|
22
|
+
>;
|
|
23
|
+
|
|
14
24
|
type getCustomersParams = Omit<
|
|
15
25
|
operations['pos_get_customers']['parameters']['query'],
|
|
16
26
|
'page' | 'size'
|
|
@@ -71,6 +81,22 @@ const posFactory = {
|
|
|
71
81
|
url: `/consumers/{consumer_id}/pos/payment-methods`,
|
|
72
82
|
};
|
|
73
83
|
},
|
|
84
|
+
getProductCategories(
|
|
85
|
+
params: getProductCategoriesParams
|
|
86
|
+
): RequestData<components['schemas']['ProductCategoryItem'][]> {
|
|
87
|
+
return {
|
|
88
|
+
params,
|
|
89
|
+
method: 'get',
|
|
90
|
+
url: `/consumers/{consumer_id}/pos/product-categories`,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
getProducts(params: getProductsParams): RequestData<components['schemas']['POSProductItem'][]> {
|
|
94
|
+
return {
|
|
95
|
+
params,
|
|
96
|
+
method: 'get',
|
|
97
|
+
url: `/consumers/{consumer_id}/pos/products`,
|
|
98
|
+
};
|
|
99
|
+
},
|
|
74
100
|
getSales(
|
|
75
101
|
params: operations['pos_get_sales']['parameters']['query']
|
|
76
102
|
): RequestData<components['schemas']['SalesItem']> {
|
package/src/modules/sync.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ContextType } from '../types/sync';
|
|
|
4
4
|
import { Consumer } from './consumer';
|
|
5
5
|
import { Flow } from './flow';
|
|
6
6
|
|
|
7
|
-
const Sync = (internalApi: InternalAPI, body: components['schemas']['
|
|
7
|
+
const Sync = (internalApi: InternalAPI, body: components['schemas']['ReadSyncItem']) => {
|
|
8
8
|
const _internalApi: InternalAPI = internalApi;
|
|
9
9
|
const data = body;
|
|
10
10
|
const name = data.name;
|
package/src/modules/syncs.ts
CHANGED
|
@@ -6,14 +6,14 @@ const Syncs = (internalApi: InternalAPI) => {
|
|
|
6
6
|
const _internalApi: InternalAPI = internalApi;
|
|
7
7
|
|
|
8
8
|
const getSyncs = async () => {
|
|
9
|
-
const { data }: { data: components['schemas']['
|
|
9
|
+
const { data }: { data: components['schemas']['ReadSyncItem'][] } = await _internalApi.get(
|
|
10
10
|
'/syncs'
|
|
11
11
|
);
|
|
12
12
|
return data.map((sync) => Sync(_internalApi, sync));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const getSyncById = async (syncid: string) => {
|
|
16
|
-
const { data }: { data: components['schemas']['
|
|
16
|
+
const { data }: { data: components['schemas']['ReadSyncItem'] } = await _internalApi.get(
|
|
17
17
|
`/syncs/${syncid}`
|
|
18
18
|
);
|
|
19
19
|
return Sync(_internalApi, data);
|