@chift/chift-nodejs 0.0.1
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 -0
- package/.eslintignore +1 -0
- package/.eslintrc.json +25 -0
- package/.github/workflows/ci.yml +73 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +7 -0
- package/CHANGELOG.md +4 -0
- package/LICENSE +201 -0
- package/README.md +48 -0
- package/coverage/clover.xml +1645 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/helpers/index.html +131 -0
- package/coverage/lcov-report/src/helpers/openapi.ts.html +151 -0
- package/coverage/lcov-report/src/helpers/settings.ts.html +94 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +88 -0
- package/coverage/lcov-report/src/modules/accounting.ts.html +1156 -0
- package/coverage/lcov-report/src/modules/api.ts.html +190 -0
- package/coverage/lcov-report/src/modules/consumer.ts.html +616 -0
- package/coverage/lcov-report/src/modules/consumers.ts.html +331 -0
- package/coverage/lcov-report/src/modules/custom.ts.html +193 -0
- package/coverage/lcov-report/src/modules/datastores.ts.html +142 -0
- package/coverage/lcov-report/src/modules/ecommerce.ts.html +331 -0
- package/coverage/lcov-report/src/modules/flow.ts.html +589 -0
- package/coverage/lcov-report/src/modules/index.html +326 -0
- package/coverage/lcov-report/src/modules/integrations.ts.html +151 -0
- package/coverage/lcov-report/src/modules/internalApi.ts.html +586 -0
- package/coverage/lcov-report/src/modules/invoicing.ts.html +391 -0
- package/coverage/lcov-report/src/modules/pos.ts.html +421 -0
- package/coverage/lcov-report/src/modules/sync.ts.html +316 -0
- package/coverage/lcov-report/src/modules/syncs.ts.html +169 -0
- package/coverage/lcov-report/src/modules/webhooks.ts.html +343 -0
- package/coverage/lcov.info +1976 -0
- package/dist/src/helpers/openapi.d.ts +3 -0
- package/dist/src/helpers/openapi.js +18 -0
- package/dist/src/helpers/settings.d.ts +4 -0
- package/dist/src/helpers/settings.js +5 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/modules/accounting.d.ts +48 -0
- package/dist/src/modules/accounting.js +255 -0
- package/dist/src/modules/api.d.ts +39333 -0
- package/dist/src/modules/api.js +36 -0
- package/dist/src/modules/consumer.d.ts +2588 -0
- package/dist/src/modules/consumer.js +118 -0
- package/dist/src/modules/consumers.d.ts +13034 -0
- package/dist/src/modules/consumers.js +51 -0
- package/dist/src/modules/custom.d.ts +8 -0
- package/dist/src/modules/custom.js +36 -0
- package/dist/src/modules/datastores.d.ts +18 -0
- package/dist/src/modules/datastores.js +23 -0
- package/dist/src/modules/ecommerce.d.ts +16 -0
- package/dist/src/modules/ecommerce.js +69 -0
- package/dist/src/modules/flow.d.ts +15 -0
- package/dist/src/modules/flow.js +156 -0
- package/dist/src/modules/integrations.d.ts +14 -0
- package/dist/src/modules/integrations.js +23 -0
- package/dist/src/modules/internalApi.d.ts +22 -0
- package/dist/src/modules/internalApi.js +160 -0
- package/dist/src/modules/invoicing.d.ts +18 -0
- package/dist/src/modules/invoicing.js +90 -0
- package/dist/src/modules/pos.d.ts +20 -0
- package/dist/src/modules/pos.js +80 -0
- package/dist/src/modules/sync.d.ts +10494 -0
- package/dist/src/modules/sync.js +75 -0
- package/dist/src/modules/syncs.d.ts +26200 -0
- package/dist/src/modules/syncs.js +29 -0
- package/dist/src/modules/webhooks.d.ts +55 -0
- package/dist/src/modules/webhooks.js +53 -0
- package/dist/src/types/api.d.ts +28 -0
- package/dist/src/types/api.js +2 -0
- package/dist/src/types/consumers.d.ts +8 -0
- package/dist/src/types/consumers.js +2 -0
- package/dist/src/types/public-api/mappings.d.ts +21 -0
- package/dist/src/types/public-api/mappings.js +2 -0
- package/dist/src/types/sync.d.ts +20 -0
- package/dist/src/types/sync.js +2 -0
- package/dist/test/modules/accounting.test.d.ts +1 -0
- package/dist/test/modules/accounting.test.js +453 -0
- package/dist/test/modules/consumer.test.d.ts +1 -0
- package/dist/test/modules/consumer.test.js +89 -0
- package/dist/test/modules/consumers.test.d.ts +1 -0
- package/dist/test/modules/consumers.test.js +109 -0
- package/dist/test/modules/ecommerce.test.d.ts +1 -0
- package/dist/test/modules/ecommerce.test.js +193 -0
- package/dist/test/modules/flow.test.d.ts +1 -0
- package/dist/test/modules/flow.test.js +69 -0
- package/dist/test/modules/integrations.test.d.ts +1 -0
- package/dist/test/modules/integrations.test.js +54 -0
- package/dist/test/modules/invoicing.test.d.ts +1 -0
- package/dist/test/modules/invoicing.test.js +108 -0
- package/dist/test/modules/pos.test.d.ts +1 -0
- package/dist/test/modules/pos.test.js +164 -0
- package/dist/test/modules/sync.test.d.ts +1 -0
- package/dist/test/modules/sync.test.js +81 -0
- package/dist/test/modules/syncs.test.d.ts +1 -0
- package/dist/test/modules/syncs.test.js +53 -0
- package/dist/test/modules/webhooks.test.d.ts +1 -0
- package/dist/test/modules/webhooks.test.js +120 -0
- package/jest.config.ts +195 -0
- package/package.json +47 -0
- package/src/helpers/openapi.ts +22 -0
- package/src/helpers/settings.ts +3 -0
- package/src/index.ts +1 -0
- package/src/modules/accounting.ts +357 -0
- package/src/modules/api.ts +35 -0
- package/src/modules/consumer.ts +177 -0
- package/src/modules/consumers.ts +82 -0
- package/src/modules/custom.ts +36 -0
- package/src/modules/datastores.ts +19 -0
- package/src/modules/ecommerce.ts +82 -0
- package/src/modules/flow.ts +168 -0
- package/src/modules/integrations.ts +22 -0
- package/src/modules/internalApi.ts +162 -0
- package/src/modules/invoicing.ts +106 -0
- package/src/modules/pos.ts +112 -0
- package/src/modules/sync.ts +77 -0
- package/src/modules/syncs.ts +28 -0
- package/src/modules/webhooks.ts +86 -0
- package/src/types/api.ts +35 -0
- package/src/types/consumers.ts +9 -0
- package/src/types/public-api/mappings.ts +21 -0
- package/src/types/public-api/schema.d.ts +9436 -0
- package/src/types/sync.ts +23 -0
- package/test/data/accounting_invoice.pdf +0 -0
- package/test/modules/accounting.test.ts +483 -0
- package/test/modules/consumer.test.ts +68 -0
- package/test/modules/consumers.test.ts +83 -0
- package/test/modules/ecommerce.test.ts +177 -0
- package/test/modules/integrations.test.ts +22 -0
- package/test/modules/invoicing.test.ts +88 -0
- package/test/modules/pos.test.ts +145 -0
- package/test/modules/sync.test.ts +60 -0
- package/test/modules/syncs.test.ts +23 -0
- package/test/modules/webhooks.test.ts +92 -0
- package/test/set_envs.sh +14 -0
- package/tsconfig.json +107 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const globals_1 = require("@jest/globals");
|
|
36
|
+
const chift = __importStar(require("../../src/index"));
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const client = new chift.API({
|
|
40
|
+
baseUrl: process.env.CHIFT_BASE_URL,
|
|
41
|
+
clientId: process.env.CHIFT_CLIENT_ID,
|
|
42
|
+
clientSecret: process.env.CHIFT_CLIENT_SECRET,
|
|
43
|
+
accountId: process.env.CHIFT_ACCOUNT_ID,
|
|
44
|
+
});
|
|
45
|
+
const consumerId = process.env.CHIFT_WOOCOMMERCE_CONSUMER_ID;
|
|
46
|
+
let consumer;
|
|
47
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
49
|
+
}));
|
|
50
|
+
let customers;
|
|
51
|
+
(0, globals_1.test)('getCustomers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
customers = yield consumer.ecommerce.getCustomers();
|
|
53
|
+
(0, globals_1.expect)(customers).toBeInstanceOf(Array);
|
|
54
|
+
(0, globals_1.expect)(customers.length).toBeGreaterThan(0);
|
|
55
|
+
(0, globals_1.expect)(customers[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
56
|
+
}));
|
|
57
|
+
let products;
|
|
58
|
+
(0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
products = yield consumer.ecommerce.getProducts();
|
|
60
|
+
(0, globals_1.expect)(products).toBeInstanceOf(Array);
|
|
61
|
+
(0, globals_1.expect)(products.length).toBeGreaterThan(0);
|
|
62
|
+
(0, globals_1.expect)(products[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
63
|
+
}));
|
|
64
|
+
(0, globals_1.test)('getCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
const customer = yield consumer.ecommerce.getCustomer(customers[0].id);
|
|
66
|
+
(0, globals_1.expect)(customer).toHaveProperty('id', customers[0].id);
|
|
67
|
+
(0, globals_1.expect)(customer).toHaveProperty('first_name');
|
|
68
|
+
(0, globals_1.expect)(customer).toHaveProperty('last_name');
|
|
69
|
+
(0, globals_1.expect)(customer).toHaveProperty('phone');
|
|
70
|
+
(0, globals_1.expect)(customer).toHaveProperty('email');
|
|
71
|
+
(0, globals_1.expect)(customer).toHaveProperty('language');
|
|
72
|
+
(0, globals_1.expect)(customer).toHaveProperty('internal_notes');
|
|
73
|
+
(0, globals_1.expect)(customer).toHaveProperty('currency');
|
|
74
|
+
(0, globals_1.expect)(customer).toHaveProperty('addresses');
|
|
75
|
+
(0, globals_1.expect)(customer).toHaveProperty('created_on');
|
|
76
|
+
}));
|
|
77
|
+
(0, globals_1.test)('getProduct', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const product = yield consumer.ecommerce.getProduct(products[0].id);
|
|
79
|
+
(0, globals_1.expect)(product).toBeTruthy();
|
|
80
|
+
(0, globals_1.expect)(product).toHaveProperty('id', products[0].id);
|
|
81
|
+
(0, globals_1.expect)(product).toHaveProperty('name', globals_1.expect.any(String));
|
|
82
|
+
(0, globals_1.expect)(product).toHaveProperty('description');
|
|
83
|
+
(0, globals_1.expect)(product).toHaveProperty('description_html');
|
|
84
|
+
(0, globals_1.expect)(product).toHaveProperty('categories');
|
|
85
|
+
(0, globals_1.expect)(product).toHaveProperty('created_on');
|
|
86
|
+
(0, globals_1.expect)(product).toHaveProperty('variants');
|
|
87
|
+
(0, globals_1.expect)(product).toHaveProperty('status');
|
|
88
|
+
(0, globals_1.expect)(product).toHaveProperty('common_attributes');
|
|
89
|
+
(0, globals_1.expect)(product).toHaveProperty('variant_attributes_options');
|
|
90
|
+
(0, globals_1.expect)(product).toHaveProperty('common_images');
|
|
91
|
+
}));
|
|
92
|
+
(0, globals_1.test)('getProductVariantById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
+
if (!(products === null || products === void 0 ? void 0 : products.length)) {
|
|
94
|
+
throw new Error('No product to test');
|
|
95
|
+
}
|
|
96
|
+
if (!products[0].variants) {
|
|
97
|
+
throw new Error('No product variant to test');
|
|
98
|
+
}
|
|
99
|
+
const variant = yield consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
|
|
100
|
+
(0, globals_1.expect)(variant).toBeTruthy();
|
|
101
|
+
(0, globals_1.expect)(variant).toHaveProperty('id', globals_1.expect.any(String));
|
|
102
|
+
}));
|
|
103
|
+
let locations;
|
|
104
|
+
(0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
locations = yield consumer.ecommerce.getLocations();
|
|
106
|
+
(0, globals_1.expect)(locations).toBeInstanceOf(Array);
|
|
107
|
+
(0, globals_1.expect)(locations.length).toBeGreaterThan(0);
|
|
108
|
+
(0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
109
|
+
(0, globals_1.expect)(locations[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
110
|
+
}));
|
|
111
|
+
(0, globals_1.test)('updateAvailableQuantity', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
if (!(products === null || products === void 0 ? void 0 : products.length)) {
|
|
113
|
+
throw new Error('No product to test');
|
|
114
|
+
}
|
|
115
|
+
if (!products[0].variants) {
|
|
116
|
+
throw new Error('No product variant to test');
|
|
117
|
+
}
|
|
118
|
+
const product = yield consumer.ecommerce.updateAvailableQuantity(products[0].variants[0].id, {
|
|
119
|
+
location_id: locations[0].id,
|
|
120
|
+
available_quantity: 1,
|
|
121
|
+
});
|
|
122
|
+
(0, globals_1.expect)(product).toBeTruthy();
|
|
123
|
+
(0, globals_1.expect)(product).toHaveProperty('available_quantity', globals_1.expect.any(Number));
|
|
124
|
+
}));
|
|
125
|
+
/*
|
|
126
|
+
test('createOrder', async () => {
|
|
127
|
+
const order = await consumer.ecommerce.createOrder({
|
|
128
|
+
customer: {
|
|
129
|
+
email: 'test@test.com',
|
|
130
|
+
},
|
|
131
|
+
billing_address: {
|
|
132
|
+
first_name: 'Test',
|
|
133
|
+
last_name: 'Test',
|
|
134
|
+
street: 'Test',
|
|
135
|
+
number: '1',
|
|
136
|
+
city: 'Test',
|
|
137
|
+
country: 'BE',
|
|
138
|
+
},
|
|
139
|
+
shipping_address: {
|
|
140
|
+
first_name: 'Test',
|
|
141
|
+
last_name: 'Test',
|
|
142
|
+
street: 'Test',
|
|
143
|
+
number: '1',
|
|
144
|
+
city: 'Test',
|
|
145
|
+
country: 'BE',
|
|
146
|
+
},
|
|
147
|
+
currency: 'EUR',
|
|
148
|
+
lines: [
|
|
149
|
+
{
|
|
150
|
+
variant_id: '1',
|
|
151
|
+
quantity: 1,
|
|
152
|
+
tax_rate: 21.0,
|
|
153
|
+
unit_price: 10.0,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
payment_method: 'bank-transfer',
|
|
157
|
+
});
|
|
158
|
+
expect(order).toBeTruthy();
|
|
159
|
+
expect(order).toHaveProperty('id', expect.any(String));
|
|
160
|
+
});
|
|
161
|
+
*/
|
|
162
|
+
let orders;
|
|
163
|
+
(0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
orders = yield consumer.ecommerce.getOrders({
|
|
165
|
+
date_from: '2021-10-01',
|
|
166
|
+
date_to: '2021-12-31',
|
|
167
|
+
});
|
|
168
|
+
(0, globals_1.expect)(orders).toBeInstanceOf(Array);
|
|
169
|
+
}));
|
|
170
|
+
(0, globals_1.test)('getOrder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
const order = yield consumer.ecommerce.getOrder(orders[0].id);
|
|
172
|
+
(0, globals_1.expect)(order).toBeTruthy();
|
|
173
|
+
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
174
|
+
(0, globals_1.expect)(order).toHaveProperty('order_number');
|
|
175
|
+
(0, globals_1.expect)(order).toHaveProperty('billing_address');
|
|
176
|
+
(0, globals_1.expect)(order).toHaveProperty('shipping_address');
|
|
177
|
+
(0, globals_1.expect)(order).toHaveProperty('created_on');
|
|
178
|
+
(0, globals_1.expect)(order).toHaveProperty('confirmed_on');
|
|
179
|
+
(0, globals_1.expect)(order).toHaveProperty('cancelled_on');
|
|
180
|
+
(0, globals_1.expect)(order).toHaveProperty('status', globals_1.expect.any(String));
|
|
181
|
+
(0, globals_1.expect)(order).toHaveProperty('discount_amount', globals_1.expect.any(Number));
|
|
182
|
+
(0, globals_1.expect)(order).toHaveProperty('untaxed_amount_without_fees', globals_1.expect.any(Number));
|
|
183
|
+
(0, globals_1.expect)(order).toHaveProperty('tax_amount_without_fees', globals_1.expect.any(Number));
|
|
184
|
+
(0, globals_1.expect)(order).toHaveProperty('total_without_fees', globals_1.expect.any(Number));
|
|
185
|
+
(0, globals_1.expect)(order).toHaveProperty('untaxed_amount', globals_1.expect.any(Number));
|
|
186
|
+
(0, globals_1.expect)(order).toHaveProperty('tax_amount', globals_1.expect.any(Number));
|
|
187
|
+
(0, globals_1.expect)(order).toHaveProperty('total', globals_1.expect.any(Number));
|
|
188
|
+
(0, globals_1.expect)(order).toHaveProperty('refunded_amount', globals_1.expect.any(Number));
|
|
189
|
+
(0, globals_1.expect)(order).toHaveProperty('currency');
|
|
190
|
+
(0, globals_1.expect)(order).toHaveProperty('note');
|
|
191
|
+
(0, globals_1.expect)(order).toHaveProperty('lines', globals_1.expect.any(Array));
|
|
192
|
+
(0, globals_1.expect)(order).toHaveProperty('other_fees');
|
|
193
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const globals_1 = require("@jest/globals");
|
|
36
|
+
const chift = __importStar(require("../../src/index"));
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const client = new chift.API({
|
|
40
|
+
baseUrl: process.env.CHIFT_BASE_URL,
|
|
41
|
+
clientId: process.env.CHIFT_CLIENT_ID,
|
|
42
|
+
clientSecret: process.env.CHIFT_CLIENT_SECRET,
|
|
43
|
+
accountId: process.env.CHIFT_ACCOUNT_ID,
|
|
44
|
+
});
|
|
45
|
+
let flow;
|
|
46
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const syncId = process.env.CHIFT_TEST_SYNC_ID;
|
|
48
|
+
const sync = yield client.Syncs.getSyncById(syncId);
|
|
49
|
+
flow = yield sync.createFlow({
|
|
50
|
+
name: 'Je suis un flux de test',
|
|
51
|
+
description: 'Flux de test',
|
|
52
|
+
execution: {
|
|
53
|
+
type: 'code',
|
|
54
|
+
},
|
|
55
|
+
trigger: {
|
|
56
|
+
type: 'event',
|
|
57
|
+
},
|
|
58
|
+
config: {},
|
|
59
|
+
}, (consumer, flowContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
console.log(`Mon flow_id : ${flowContext.flow_id}`);
|
|
61
|
+
console.log(`Bonjour, ceci est un test, on exécute le flux pour consumer: ${consumer}`);
|
|
62
|
+
}));
|
|
63
|
+
}));
|
|
64
|
+
(0, globals_1.test)('executeLocal', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
flow.execute({ context: { logs: true, local: true } });
|
|
66
|
+
}));
|
|
67
|
+
(0, globals_1.test)('execute', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
flow.execute({ context: { logs: true, local: false } });
|
|
69
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const globals_1 = require("@jest/globals");
|
|
36
|
+
const chift = __importStar(require("../../src/index"));
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const client = new chift.API({
|
|
40
|
+
baseUrl: process.env.CHIFT_BASE_URL,
|
|
41
|
+
clientId: process.env.CHIFT_CLIENT_ID,
|
|
42
|
+
clientSecret: process.env.CHIFT_CLIENT_SECRET,
|
|
43
|
+
accountId: process.env.CHIFT_ACCOUNT_ID,
|
|
44
|
+
});
|
|
45
|
+
(0, globals_1.test)('getIntegrations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const integrations = yield client.Integrations.getIntegrations();
|
|
47
|
+
(0, globals_1.expect)(integrations).toBeInstanceOf(Array);
|
|
48
|
+
(0, globals_1.expect)(integrations.length).toBeGreaterThan(0);
|
|
49
|
+
(0, globals_1.expect)(integrations[0]).toHaveProperty('integrationid', globals_1.expect.any(Number));
|
|
50
|
+
(0, globals_1.expect)(integrations[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
51
|
+
(0, globals_1.expect)(integrations[0]).toHaveProperty('status', globals_1.expect.stringMatching(/^(active|inactive)$/));
|
|
52
|
+
(0, globals_1.expect)(integrations[0]).toHaveProperty('api', globals_1.expect.any(String));
|
|
53
|
+
(0, globals_1.expect)(integrations[0]).toHaveProperty('credentials', globals_1.expect.any(Array));
|
|
54
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const globals_1 = require("@jest/globals");
|
|
36
|
+
const chift = __importStar(require("../../src/index"));
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const client = new chift.API({
|
|
40
|
+
baseUrl: process.env.CHIFT_BASE_URL,
|
|
41
|
+
clientId: process.env.CHIFT_CLIENT_ID,
|
|
42
|
+
clientSecret: process.env.CHIFT_CLIENT_SECRET,
|
|
43
|
+
accountId: process.env.CHIFT_ACCOUNT_ID,
|
|
44
|
+
});
|
|
45
|
+
const consumerId = process.env.CHIFT_AXONAUT_CONSUMER_ID;
|
|
46
|
+
let consumer;
|
|
47
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
49
|
+
}));
|
|
50
|
+
let invoices;
|
|
51
|
+
(0, globals_1.test)('getInvoices', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
invoices = yield consumer.invoicing.getInvoices({
|
|
53
|
+
invoice_type: 'customer_invoice',
|
|
54
|
+
date_from: '2023-01-01',
|
|
55
|
+
date_to: '2023-01-31',
|
|
56
|
+
});
|
|
57
|
+
(0, globals_1.expect)(invoices).toBeInstanceOf(Array);
|
|
58
|
+
(0, globals_1.expect)(invoices.length).toBeGreaterThan(0);
|
|
59
|
+
(0, globals_1.expect)(invoices[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
60
|
+
}));
|
|
61
|
+
(0, globals_1.test)('getInvoiceById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const invoice = yield consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
|
|
63
|
+
(0, globals_1.expect)(invoice).toHaveProperty('id', globals_1.expect.any(String));
|
|
64
|
+
}));
|
|
65
|
+
let products;
|
|
66
|
+
(0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
products = yield consumer.invoicing.getProducts();
|
|
68
|
+
(0, globals_1.expect)(products).toBeInstanceOf(Array);
|
|
69
|
+
(0, globals_1.expect)(products.length).toBeGreaterThan(0);
|
|
70
|
+
(0, globals_1.expect)(products[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
71
|
+
}));
|
|
72
|
+
(0, globals_1.test)('getProductById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const product = yield consumer.invoicing.getProductById(products[0].id);
|
|
74
|
+
(0, globals_1.expect)(product).toHaveProperty('id', globals_1.expect.any(String));
|
|
75
|
+
}));
|
|
76
|
+
let vatCodes;
|
|
77
|
+
(0, globals_1.test)('getTaxes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
vatCodes = yield consumer.invoicing.getTaxes();
|
|
79
|
+
(0, globals_1.expect)(vatCodes).toBeInstanceOf(Array);
|
|
80
|
+
(0, globals_1.expect)(vatCodes.length).toBeGreaterThan(0);
|
|
81
|
+
(0, globals_1.expect)(vatCodes[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
82
|
+
}));
|
|
83
|
+
(0, globals_1.test)('getTaxById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const tax = yield consumer.invoicing.getTaxById(vatCodes[0].id);
|
|
85
|
+
(0, globals_1.expect)(tax).toHaveProperty('id', globals_1.expect.any(String));
|
|
86
|
+
}));
|
|
87
|
+
let opportunities;
|
|
88
|
+
(0, globals_1.test)('getOpportunities', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
opportunities = yield consumer.invoicing.getOpportunities();
|
|
90
|
+
(0, globals_1.expect)(opportunities).toBeInstanceOf(Array);
|
|
91
|
+
(0, globals_1.expect)(opportunities.length).toBeGreaterThan(0);
|
|
92
|
+
(0, globals_1.expect)(opportunities[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
93
|
+
}));
|
|
94
|
+
(0, globals_1.test)('getOpportunitiesById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const opportunity = yield consumer.invoicing.getOpportunitiesById(opportunities[0].id);
|
|
96
|
+
(0, globals_1.expect)(opportunity).toHaveProperty('id', globals_1.expect.any(String));
|
|
97
|
+
}));
|
|
98
|
+
let contacts;
|
|
99
|
+
(0, globals_1.test)('getContacts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
contacts = yield consumer.invoicing.getContacts();
|
|
101
|
+
(0, globals_1.expect)(contacts).toBeInstanceOf(Array);
|
|
102
|
+
(0, globals_1.expect)(contacts.length).toBeGreaterThan(0);
|
|
103
|
+
(0, globals_1.expect)(contacts[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
104
|
+
}));
|
|
105
|
+
(0, globals_1.test)('getContactById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
const contact = yield consumer.invoicing.getContactById(contacts[0].id);
|
|
107
|
+
(0, globals_1.expect)(contact).toHaveProperty('id', globals_1.expect.any(String));
|
|
108
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const globals_1 = require("@jest/globals");
|
|
36
|
+
const chift = __importStar(require("../../src/index"));
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
dotenv.config();
|
|
39
|
+
const client = new chift.API({
|
|
40
|
+
baseUrl: process.env.CHIFT_BASE_URL,
|
|
41
|
+
clientId: process.env.CHIFT_CLIENT_ID,
|
|
42
|
+
clientSecret: process.env.CHIFT_CLIENT_SECRET,
|
|
43
|
+
accountId: process.env.CHIFT_ACCOUNT_ID,
|
|
44
|
+
});
|
|
45
|
+
// Split testing between two APIs to support all endpoints
|
|
46
|
+
const cashpadConsumerId = process.env.CHIFT_CASHPAD_CONSUMER_ID;
|
|
47
|
+
const lightspeedConsumerId = process.env.CHIFT_LIGHTSPEED_CONSUMER_ID;
|
|
48
|
+
let cashpadConsumer;
|
|
49
|
+
let lightspeedConsumer;
|
|
50
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
cashpadConsumer = yield client.Consumers.getConsumerById(cashpadConsumerId);
|
|
52
|
+
lightspeedConsumer = yield client.Consumers.getConsumerById(lightspeedConsumerId);
|
|
53
|
+
}));
|
|
54
|
+
(0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
const locations = yield lightspeedConsumer.pos.getLocations();
|
|
56
|
+
(0, globals_1.expect)(locations).toBeInstanceOf(Array);
|
|
57
|
+
(0, globals_1.expect)(locations.length).toBeGreaterThan(0);
|
|
58
|
+
(0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
59
|
+
(0, globals_1.expect)(locations[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
60
|
+
}));
|
|
61
|
+
let orders;
|
|
62
|
+
(0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
orders = yield lightspeedConsumer.pos.getOrders({
|
|
64
|
+
date_from: '2022-08-11',
|
|
65
|
+
date_to: '2022-08-12',
|
|
66
|
+
});
|
|
67
|
+
(0, globals_1.expect)(orders).toBeInstanceOf(Array);
|
|
68
|
+
(0, globals_1.expect)(orders.length).toBeGreaterThan(0);
|
|
69
|
+
(0, globals_1.expect)(orders[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
70
|
+
}));
|
|
71
|
+
// TODO: Fix Method Not Allowed error
|
|
72
|
+
globals_1.test.skip('createCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const body = {
|
|
74
|
+
first_name: 'John',
|
|
75
|
+
last_name: 'Doe',
|
|
76
|
+
email: 'test@test.com',
|
|
77
|
+
};
|
|
78
|
+
const customer = yield cashpadConsumer.pos.createCustomer(body);
|
|
79
|
+
(0, globals_1.expect)(customer).toBeTruthy();
|
|
80
|
+
(0, globals_1.expect)(customer).toHaveProperty('id', globals_1.expect.any(String));
|
|
81
|
+
(0, globals_1.expect)(customer).toHaveProperty('name');
|
|
82
|
+
}));
|
|
83
|
+
// TODO: Fix timeout error
|
|
84
|
+
let customers = [];
|
|
85
|
+
globals_1.test.skip('getCustomers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
customers = yield cashpadConsumer.pos.getCustomers();
|
|
87
|
+
(0, globals_1.expect)(customers).toBeInstanceOf(Array);
|
|
88
|
+
(0, globals_1.expect)(customers.length).toBeGreaterThan(0);
|
|
89
|
+
(0, globals_1.expect)(customers[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
90
|
+
}));
|
|
91
|
+
// TODO: Fix The day parameter is missing error
|
|
92
|
+
globals_1.test.skip('getOrder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
+
const order = yield lightspeedConsumer.pos.getOrder(orders[0].id);
|
|
94
|
+
(0, globals_1.expect)(order).toBeTruthy();
|
|
95
|
+
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
96
|
+
(0, globals_1.expect)(order).toHaveProperty('order_number');
|
|
97
|
+
(0, globals_1.expect)(order).toHaveProperty('creation_date', globals_1.expect.any(String));
|
|
98
|
+
(0, globals_1.expect)(order).toHaveProperty('closing_date');
|
|
99
|
+
(0, globals_1.expect)(order).toHaveProperty('service_date');
|
|
100
|
+
(0, globals_1.expect)(order).toHaveProperty('total', globals_1.expect.any(Number));
|
|
101
|
+
(0, globals_1.expect)(order).toHaveProperty('tax_amount', globals_1.expect.any(Number));
|
|
102
|
+
(0, globals_1.expect)(order).toHaveProperty('total_discount');
|
|
103
|
+
(0, globals_1.expect)(order).toHaveProperty('total_refund');
|
|
104
|
+
(0, globals_1.expect)(order).toHaveProperty('total_tip', globals_1.expect.any(Number));
|
|
105
|
+
(0, globals_1.expect)(order).toHaveProperty('items', globals_1.expect.any(Array));
|
|
106
|
+
(0, globals_1.expect)(order).toHaveProperty('payments', globals_1.expect.any(Array));
|
|
107
|
+
(0, globals_1.expect)(order).toHaveProperty('currency');
|
|
108
|
+
(0, globals_1.expect)(order).toHaveProperty('country');
|
|
109
|
+
(0, globals_1.expect)(order).toHaveProperty('loyalty');
|
|
110
|
+
(0, globals_1.expect)(order).toHaveProperty('customer_id');
|
|
111
|
+
(0, globals_1.expect)(order).toHaveProperty('location_id');
|
|
112
|
+
(0, globals_1.expect)(order).toHaveProperty('taxes');
|
|
113
|
+
}));
|
|
114
|
+
// TODO: Fix getCustomers first
|
|
115
|
+
globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
+
const customer = yield cashpadConsumer.pos.getCustomer(customers[0].id);
|
|
117
|
+
(0, globals_1.expect)(customer).toBeTruthy();
|
|
118
|
+
(0, globals_1.expect)(customer).toHaveProperty('id', globals_1.expect.any(String));
|
|
119
|
+
(0, globals_1.expect)(customer).toHaveProperty('name');
|
|
120
|
+
}));
|
|
121
|
+
(0, globals_1.test)('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
const paymentMethods = yield lightspeedConsumer.pos.getPaymentMethods();
|
|
123
|
+
(0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
|
|
124
|
+
(0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
|
|
125
|
+
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
126
|
+
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
127
|
+
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('extra');
|
|
128
|
+
}));
|
|
129
|
+
(0, globals_1.test)('getSales', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
const sales = yield lightspeedConsumer.pos.getSales({
|
|
131
|
+
date_from: '2022-08-11',
|
|
132
|
+
date_to: '2022-08-12',
|
|
133
|
+
});
|
|
134
|
+
(0, globals_1.expect)(sales).toHaveProperty('total', globals_1.expect.any(Number));
|
|
135
|
+
(0, globals_1.expect)(sales).toHaveProperty('tax_amount', globals_1.expect.any(Number));
|
|
136
|
+
(0, globals_1.expect)(sales).toHaveProperty('taxes', globals_1.expect.any(Array));
|
|
137
|
+
}));
|
|
138
|
+
(0, globals_1.test)('getClosure', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
+
const closure = yield lightspeedConsumer.pos.getClosure('2022-08-11');
|
|
140
|
+
(0, globals_1.expect)(closure).toHaveProperty('date', globals_1.expect.any(String));
|
|
141
|
+
(0, globals_1.expect)(closure).toHaveProperty('status');
|
|
142
|
+
}));
|
|
143
|
+
(0, globals_1.test)('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
const payments = yield lightspeedConsumer.pos.getPayments({
|
|
145
|
+
date_from: '2022-08-11',
|
|
146
|
+
date_to: '2022-08-12',
|
|
147
|
+
});
|
|
148
|
+
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
149
|
+
(0, globals_1.expect)(payments.length).toBeGreaterThan(0);
|
|
150
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('id');
|
|
151
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('payment_method_id');
|
|
152
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('payment_method_name');
|
|
153
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('total', globals_1.expect.any(Number));
|
|
154
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('tip', globals_1.expect.any(Number));
|
|
155
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('status');
|
|
156
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('currency');
|
|
157
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('date');
|
|
158
|
+
}));
|
|
159
|
+
// TODO: Fix API Resource does not exist
|
|
160
|
+
globals_1.test.skip('updateOrder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
+
const order = yield lightspeedConsumer.pos.updateOrder(orders[0].id, {});
|
|
162
|
+
(0, globals_1.expect)(order).toBeTruthy();
|
|
163
|
+
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
164
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|