@chift/chift-nodejs 1.0.15 → 1.0.17
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/.github/workflows/ci.yml +10 -10
- package/CHANGELOG.md +15 -2
- package/README.md +3 -3
- package/dist/src/modules/accounting.d.ts +3 -3
- package/dist/src/modules/api.d.ts +4374 -2758
- package/dist/src/modules/consumer.d.ts +829 -509
- package/dist/src/modules/consumer.js +3 -0
- package/dist/src/modules/consumers.d.ts +4395 -2787
- package/dist/src/modules/datastores.d.ts +2 -2
- package/dist/src/modules/ecommerce.d.ts +2 -2
- package/dist/src/modules/integrations.d.ts +9 -4
- package/dist/src/modules/invoicing.d.ts +3 -3
- package/dist/src/modules/payment.d.ts +14 -0
- package/dist/src/modules/payment.js +41 -0
- package/dist/src/modules/sync.d.ts +3507 -2223
- package/dist/src/modules/sync.js +1 -1
- package/dist/src/modules/webhooks.d.ts +4 -1
- package/dist/src/types/sync.d.ts +22 -5
- package/dist/test/modules/accounting.test.js +58 -50
- package/dist/test/modules/consumer.test.js +4 -4
- package/dist/test/modules/consumers.test.js +4 -4
- package/dist/test/modules/ecommerce.test.js +23 -19
- package/dist/test/modules/integrations.test.js +4 -4
- package/dist/test/modules/invoicing.test.js +16 -9
- package/dist/test/modules/payment.test.d.ts +1 -0
- package/dist/test/modules/payment.test.js +88 -0
- package/dist/test/modules/pms.test.d.ts +1 -0
- package/dist/test/modules/pms.test.js +90 -0
- package/dist/test/modules/pos.test.js +31 -34
- package/dist/test/modules/sync.test.js +31 -19
- package/dist/test/modules/syncs.test.js +4 -4
- package/dist/test/modules/webhooks.test.js +4 -4
- package/package.json +1 -1
- package/src/modules/accounting.ts +3 -3
- package/src/modules/consumer.ts +6 -1
- package/src/modules/ecommerce.ts +4 -2
- package/src/modules/invoicing.ts +7 -3
- package/src/modules/payment.ts +59 -0
- package/src/modules/sync.ts +1 -1
- package/src/types/public-api/schema.d.ts +4165 -900
- package/src/types/sync.ts +20 -5
- package/test/modules/accounting.test.ts +69 -50
- package/test/modules/consumer.test.ts +5 -5
- package/test/modules/consumers.test.ts +4 -4
- package/test/modules/ecommerce.test.ts +25 -20
- package/test/modules/integrations.test.ts +4 -4
- package/test/modules/invoicing.test.ts +20 -10
- package/test/modules/payment.test.ts +65 -0
- package/test/modules/pms.test.ts +69 -0
- package/test/modules/pos.test.ts +32 -34
- package/test/modules/sync.test.ts +33 -19
- package/test/modules/syncs.test.ts +4 -4
- package/test/modules/webhooks.test.ts +4 -4
- package/.eslintcache +0 -1
- package/coverage/clover.xml +0 -1645
- package/coverage/coverage-final.json +0 -19
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/helpers/index.html +0 -131
- package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
- package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/index.ts.html +0 -88
- package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
- package/coverage/lcov-report/src/modules/api.ts.html +0 -190
- package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
- package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
- package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
- package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
- package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
- package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
- package/coverage/lcov-report/src/modules/index.html +0 -326
- package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
- package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
- package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
- package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
- package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
- package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
- package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
- package/coverage/lcov.info +0 -1976
- package/dist/src/types/public-api/schema.d.ts +0 -11959
- package/dist/src/types/public-api/schema.js +0 -6
- package/src/types/public-api/schema.ts +0 -12029
- package/test/set_envs.sh +0 -14
package/dist/src/modules/sync.js
CHANGED
|
@@ -54,7 +54,7 @@ const Sync = (internalApi, body) => {
|
|
|
54
54
|
type: context.execution.type,
|
|
55
55
|
data: executionData,
|
|
56
56
|
},
|
|
57
|
-
|
|
57
|
+
triggers: context.triggers,
|
|
58
58
|
config: context.config,
|
|
59
59
|
});
|
|
60
60
|
const myflow = (0, flow_1.Flow)(_internalApi, createFlowData, data.syncid, data.consumers, process);
|
|
@@ -29,7 +29,10 @@ declare const Webhooks: (internalApi: InternalAPI) => {
|
|
|
29
29
|
redirect_url?: string | undefined;
|
|
30
30
|
}>;
|
|
31
31
|
unRegisterWebhook: (webhookId: string) => Promise<{
|
|
32
|
-
|
|
32
|
+
headers: {
|
|
33
|
+
[name: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
content?: undefined;
|
|
33
36
|
}>;
|
|
34
37
|
getWebhookLogsByWebhookId: (webhookId: string) => Promise<{
|
|
35
38
|
webhooklogid: string;
|
package/dist/src/types/sync.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface FlowTriggerOptions {
|
|
2
|
+
autostart?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export interface FlowTrigger {
|
|
5
|
+
id: string;
|
|
6
|
+
type: 'event' | 'timer';
|
|
7
|
+
cronschedules?: string[];
|
|
8
|
+
definitionFields?: any[];
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
label?: string;
|
|
11
|
+
options?: FlowTriggerOptions;
|
|
12
|
+
}
|
|
13
|
+
interface FlowConfig {
|
|
14
|
+
datastores?: {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}[];
|
|
18
|
+
definitionFields?: Record<string, unknown>[];
|
|
19
|
+
doorkeyFields?: Record<string, unknown>[];
|
|
4
20
|
}
|
|
5
21
|
export interface ExecutionType {
|
|
6
22
|
type: 'code' | 'module';
|
|
@@ -9,12 +25,13 @@ export interface ExecutionType {
|
|
|
9
25
|
export interface ContextType {
|
|
10
26
|
name: string;
|
|
11
27
|
description?: string;
|
|
12
|
-
|
|
28
|
+
triggers: FlowTrigger[];
|
|
13
29
|
execution: ExecutionType;
|
|
14
|
-
config?:
|
|
30
|
+
config?: FlowConfig;
|
|
15
31
|
}
|
|
16
32
|
export interface SimpleResponseModel {
|
|
17
33
|
status: string;
|
|
18
34
|
message: string;
|
|
19
35
|
data?: any;
|
|
20
36
|
}
|
|
37
|
+
export {};
|
|
@@ -41,12 +41,12 @@ const dotenv = __importStar(require("dotenv"));
|
|
|
41
41
|
const fs_1 = __importDefault(require("fs"));
|
|
42
42
|
dotenv.config();
|
|
43
43
|
const client = new chift.API({
|
|
44
|
-
baseUrl: process.env.
|
|
45
|
-
clientId: process.env.
|
|
46
|
-
clientSecret: process.env.
|
|
47
|
-
accountId: process.env.
|
|
44
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
45
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
46
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
47
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
48
48
|
});
|
|
49
|
-
const consumerId = process.env.
|
|
49
|
+
const consumerId = process.env.CHIFT_ACCOUNTING_CONSUMER_ID;
|
|
50
50
|
let consumer;
|
|
51
51
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
52
|
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
@@ -87,6 +87,7 @@ let vatCodes;
|
|
|
87
87
|
name: 'John Doe',
|
|
88
88
|
currency: 'EUR',
|
|
89
89
|
active: false,
|
|
90
|
+
is_company: true,
|
|
90
91
|
addresses: [
|
|
91
92
|
{
|
|
92
93
|
address_type: 'main',
|
|
@@ -131,13 +132,13 @@ let clients;
|
|
|
131
132
|
(0, globals_1.expect)(client).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
132
133
|
(0, globals_1.expect)(client).toHaveProperty('addresses', globals_1.expect.any(Array));
|
|
133
134
|
}));
|
|
134
|
-
|
|
135
|
+
globals_1.test.skip('updateClient', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
136
|
const client = clients.find((client) => client.external_reference === 'sdk test');
|
|
136
137
|
const updatedClient = yield consumer.accounting.updateClient(client === null || client === void 0 ? void 0 : client.id, {
|
|
137
|
-
|
|
138
|
+
website: 'https://test.com',
|
|
138
139
|
});
|
|
139
140
|
(0, globals_1.expect)(updatedClient).toBeTruthy();
|
|
140
|
-
(0, globals_1.expect)(updatedClient).toHaveProperty('
|
|
141
|
+
(0, globals_1.expect)(updatedClient).toHaveProperty('website', 'https://test.com');
|
|
141
142
|
}));
|
|
142
143
|
(0, globals_1.test)('createSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
144
|
const body = {
|
|
@@ -145,6 +146,7 @@ let clients;
|
|
|
145
146
|
name: 'Jane Doe',
|
|
146
147
|
currency: 'EUR',
|
|
147
148
|
active: false,
|
|
149
|
+
is_company: true,
|
|
148
150
|
addresses: [
|
|
149
151
|
{
|
|
150
152
|
address_type: 'main',
|
|
@@ -188,7 +190,7 @@ let suppliers;
|
|
|
188
190
|
(0, globals_1.expect)(supplier).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
189
191
|
(0, globals_1.expect)(supplier).toHaveProperty('addresses', globals_1.expect.any(Array));
|
|
190
192
|
}));
|
|
191
|
-
|
|
193
|
+
globals_1.test.skip('updateSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
194
|
const supplier = suppliers.find((supplier) => supplier.external_reference === 'sdk test');
|
|
193
195
|
const updatedSupplier = yield consumer.accounting.updateSupplier(supplier === null || supplier === void 0 ? void 0 : supplier.id, {
|
|
194
196
|
name: 'Jane Updated Doe',
|
|
@@ -216,6 +218,8 @@ let suppliers;
|
|
|
216
218
|
total: 121,
|
|
217
219
|
partner_id: (_a = clients[0]) === null || _a === void 0 ? void 0 : _a.id,
|
|
218
220
|
journal_id: journal.id,
|
|
221
|
+
status: 'draft',
|
|
222
|
+
currency_exchange_rate: 1,
|
|
219
223
|
lines: [
|
|
220
224
|
{
|
|
221
225
|
description: 'Test',
|
|
@@ -227,6 +231,7 @@ let suppliers;
|
|
|
227
231
|
total: 121,
|
|
228
232
|
account_number: '700000',
|
|
229
233
|
tax_code: vatCode.id,
|
|
234
|
+
line_number: 1,
|
|
230
235
|
},
|
|
231
236
|
],
|
|
232
237
|
};
|
|
@@ -297,6 +302,8 @@ let invoices;
|
|
|
297
302
|
total: 121,
|
|
298
303
|
partner_id: (_b = clients[0]) === null || _b === void 0 ? void 0 : _b.id,
|
|
299
304
|
journal_id: journal.id,
|
|
305
|
+
status: 'draft',
|
|
306
|
+
currency_exchange_rate: 1,
|
|
300
307
|
lines: [
|
|
301
308
|
{
|
|
302
309
|
description: 'Test',
|
|
@@ -308,6 +315,7 @@ let invoices;
|
|
|
308
315
|
total: 121,
|
|
309
316
|
account_number: '700000',
|
|
310
317
|
tax_code: vatCode.id,
|
|
318
|
+
line_number: 1,
|
|
311
319
|
},
|
|
312
320
|
],
|
|
313
321
|
};
|
|
@@ -336,16 +344,12 @@ let analyticAccounts;
|
|
|
336
344
|
analyticAccounts = yield consumer.accounting.getAnalyticAccounts();
|
|
337
345
|
(0, globals_1.expect)(analyticAccounts).toBeInstanceOf(Array);
|
|
338
346
|
(0, globals_1.expect)(analyticAccounts.length).toBeGreaterThan(0);
|
|
339
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('active', globals_1.expect.any(Boolean));
|
|
340
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('code', globals_1.expect.any(String));
|
|
341
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
342
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('currency', globals_1.expect.any(String));
|
|
343
347
|
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
344
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('balance', globals_1.expect.any(Number));
|
|
345
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('debit', globals_1.expect.any(Number));
|
|
346
|
-
(0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('credit', globals_1.expect.any(Number));
|
|
347
348
|
}));
|
|
348
|
-
|
|
349
|
+
globals_1.test.skip('createAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
350
|
+
if (analyticPlans.length === 0) {
|
|
351
|
+
throw new Error('No analytic plans found to create analytic account with multiple plans');
|
|
352
|
+
}
|
|
349
353
|
const analyticAccount = yield consumer.accounting.createAnalyticAccountWithMultiplePlans(analyticPlans[0].id, {
|
|
350
354
|
code: '4000',
|
|
351
355
|
name: 'sdk test',
|
|
@@ -354,51 +358,63 @@ let analyticAccounts;
|
|
|
354
358
|
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
355
359
|
}));
|
|
356
360
|
(0, globals_1.test)('getAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
361
|
+
if (analyticAccounts.length === 0) {
|
|
362
|
+
throw new Error('No analytic accounts found to get analytic account');
|
|
363
|
+
}
|
|
357
364
|
const analyticAccount = yield consumer.accounting.getAnalyticAccount(analyticAccounts[0].id);
|
|
358
365
|
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
359
366
|
}));
|
|
360
|
-
|
|
367
|
+
globals_1.test.skip('updateAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
368
|
+
if (analyticAccounts.length === 0) {
|
|
369
|
+
throw new Error('No analytic accounts found to update analytic account');
|
|
370
|
+
}
|
|
361
371
|
const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'sdk test');
|
|
362
372
|
const analyticAccount = yield consumer.accounting.updateAnalyticAccount(testAnalyticAccount === null || testAnalyticAccount === void 0 ? void 0 : testAnalyticAccount.id, { name: 'test sdk update' });
|
|
363
373
|
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
364
374
|
(0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'test sdk update');
|
|
365
375
|
}));
|
|
366
|
-
|
|
376
|
+
globals_1.test.skip('getAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
377
|
+
if (analyticPlans.length === 0) {
|
|
378
|
+
throw new Error('No analytic plans found to get analytic account with multiple plans');
|
|
379
|
+
}
|
|
367
380
|
const analyticAccount = yield consumer.accounting.getAnalyticAccountWithMultiplePlans(analyticAccounts[0].id, analyticPlans[0].id);
|
|
368
381
|
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
369
382
|
}));
|
|
370
|
-
|
|
383
|
+
globals_1.test.skip('updateAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
384
|
+
if (!analyticAccounts.length) {
|
|
385
|
+
throw new Error('No analytic accounts found to update analytic account with multiple plans');
|
|
386
|
+
}
|
|
371
387
|
const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'test sdk update');
|
|
372
388
|
const analyticAccount = yield consumer.accounting.updateAnalyticAccountWithMultiplePlans(testAnalyticAccount === null || testAnalyticAccount === void 0 ? void 0 : testAnalyticAccount.id, '1', { name: 'test sdk update 2' });
|
|
373
389
|
(0, globals_1.expect)(analyticAccount).toBeTruthy();
|
|
374
390
|
(0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'test sdk update 2');
|
|
375
391
|
}));
|
|
376
|
-
|
|
392
|
+
globals_1.test.skip('getAnalyticAccountsWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
377
393
|
const analyticAccountsWithMultiplePlans = yield consumer.accounting.getAnalyticAccountsWithMultiplePlans();
|
|
378
394
|
(0, globals_1.expect)(analyticAccountsWithMultiplePlans).toBeInstanceOf(Array);
|
|
379
395
|
}));
|
|
380
|
-
|
|
396
|
+
globals_1.test.skip('createJournalEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
381
397
|
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
382
398
|
if (!journal) {
|
|
383
399
|
throw new Error('No journal with type "customer_invoice" found to create journal entry');
|
|
384
400
|
}
|
|
401
|
+
if (!clients.length) {
|
|
402
|
+
throw new Error('No clients found to create journal entry');
|
|
403
|
+
}
|
|
385
404
|
const journalEntry = yield consumer.accounting.createJournalEntry({
|
|
386
405
|
journal_id: journal.id,
|
|
387
|
-
|
|
406
|
+
number: new Date().valueOf(),
|
|
407
|
+
currency: 'EUR',
|
|
388
408
|
date: '2022-01-01',
|
|
389
409
|
items: [
|
|
390
410
|
{
|
|
391
|
-
|
|
411
|
+
account_type: 'customer_account',
|
|
412
|
+
account: clients[0].id,
|
|
392
413
|
credit: 0,
|
|
393
414
|
debit: 10,
|
|
394
|
-
partner_id: clients[0].id,
|
|
395
|
-
currency: 'EUR',
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
account_number: '700000',
|
|
399
|
-
credit: 10,
|
|
400
|
-
debit: 0,
|
|
401
415
|
currency: 'EUR',
|
|
416
|
+
prioritise_thirdparty_account: false,
|
|
417
|
+
analytic_distribution: [],
|
|
402
418
|
},
|
|
403
419
|
],
|
|
404
420
|
});
|
|
@@ -475,7 +491,7 @@ let miscOperations;
|
|
|
475
491
|
});
|
|
476
492
|
(0, globals_1.expect)(chartOfAccounts).toBeTruthy();
|
|
477
493
|
}));
|
|
478
|
-
|
|
494
|
+
globals_1.test.skip('getBalanceOfAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
479
495
|
const balanceOfAccounts = yield consumer.accounting.getBalanceOfAccounts({
|
|
480
496
|
accounts: ['7'],
|
|
481
497
|
start: '2022-01-01',
|
|
@@ -489,30 +505,22 @@ let miscOperations;
|
|
|
489
505
|
const employees = yield consumer.accounting.getEmployees();
|
|
490
506
|
(0, globals_1.expect)(employees).toBeTruthy();
|
|
491
507
|
}));
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
});
|
|
500
|
-
(0, globals_1.expect)(outstandings).toBeTruthy();
|
|
501
|
-
(0, globals_1.expect)(outstandings.items).toBeInstanceOf(Array);
|
|
502
|
-
}
|
|
503
|
-
catch (e) {
|
|
504
|
-
if ((_d = e === null || e === void 0 ? void 0 : e.error) === null || _d === void 0 ? void 0 : _d.error_code) {
|
|
505
|
-
(0, globals_1.expect)(e.error.error_code).toMatch('ERROR_API_RESOURCE_NOT_FOUND');
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
throw e;
|
|
509
|
-
}
|
|
508
|
+
globals_1.test.skip('getOutstandings', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
509
|
+
const outstandings = yield consumer.accounting.getOutstandings({
|
|
510
|
+
type: 'client',
|
|
511
|
+
unposted_allowed: false,
|
|
512
|
+
});
|
|
513
|
+
(0, globals_1.expect)(outstandings).toBeTruthy();
|
|
514
|
+
(0, globals_1.expect)(outstandings.items).toBeInstanceOf(Array);
|
|
510
515
|
}));
|
|
511
516
|
(0, globals_1.test)('createFinancialEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
512
517
|
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
513
518
|
if (!journal) {
|
|
514
519
|
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
515
520
|
}
|
|
521
|
+
if (!clients.length) {
|
|
522
|
+
throw new Error('No clients found to create journal entry');
|
|
523
|
+
}
|
|
516
524
|
const financialEntry = yield consumer.accounting.createFinancialEntry({
|
|
517
525
|
date: '2022-01-01',
|
|
518
526
|
journal_id: journal.id,
|
|
@@ -37,10 +37,10 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
45
|
const consumerName = 'test consumer 2';
|
|
46
46
|
const email = 'support@chift.eu';
|
|
@@ -41,10 +41,10 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
41
41
|
const dotenv = __importStar(require("dotenv"));
|
|
42
42
|
dotenv.config();
|
|
43
43
|
const client = new chift.API({
|
|
44
|
-
baseUrl: process.env.
|
|
45
|
-
clientId: process.env.
|
|
46
|
-
clientSecret: process.env.
|
|
47
|
-
accountId: process.env.
|
|
44
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
45
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
46
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
47
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
48
48
|
});
|
|
49
49
|
const consumerName = 'test consumer';
|
|
50
50
|
const email = 'support@chift.eu';
|
|
@@ -37,12 +37,12 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
|
-
const consumerId = process.env.
|
|
45
|
+
const consumerId = process.env.CHIFT_ECOMMERCE_CONSUMER_ID;
|
|
46
46
|
let consumer;
|
|
47
47
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
48
|
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
@@ -89,16 +89,17 @@ let products;
|
|
|
89
89
|
(0, globals_1.expect)(product).toHaveProperty('variant_attributes_options');
|
|
90
90
|
(0, globals_1.expect)(product).toHaveProperty('common_images');
|
|
91
91
|
}));
|
|
92
|
-
|
|
92
|
+
let productVariant;
|
|
93
|
+
globals_1.test.skip('getProductVariantById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
94
|
if (!(products === null || products === void 0 ? void 0 : products.length)) {
|
|
94
95
|
throw new Error('No product to test');
|
|
95
96
|
}
|
|
96
|
-
if (!products[0].variants) {
|
|
97
|
+
if (!products[0].variants.length) {
|
|
97
98
|
throw new Error('No product variant to test');
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
-
(0, globals_1.expect)(
|
|
101
|
-
(0, globals_1.expect)(
|
|
100
|
+
productVariant = yield consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
|
|
101
|
+
(0, globals_1.expect)(productVariant).toBeTruthy();
|
|
102
|
+
(0, globals_1.expect)(productVariant).toHaveProperty('id', globals_1.expect.any(String));
|
|
102
103
|
}));
|
|
103
104
|
let locations;
|
|
104
105
|
(0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -108,14 +109,14 @@ let locations;
|
|
|
108
109
|
(0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
109
110
|
(0, globals_1.expect)(locations[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
110
111
|
}));
|
|
111
|
-
|
|
112
|
-
if (!
|
|
113
|
-
throw new Error('No product to
|
|
112
|
+
globals_1.test.skip('updateAvailableQuantity', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
if (!productVariant) {
|
|
114
|
+
throw new Error('No product variant found to update available quantity');
|
|
114
115
|
}
|
|
115
|
-
if (!
|
|
116
|
-
throw new Error('No
|
|
116
|
+
if (!(locations === null || locations === void 0 ? void 0 : locations.length)) {
|
|
117
|
+
throw new Error('No location found to update available quantity');
|
|
117
118
|
}
|
|
118
|
-
const product = yield consumer.ecommerce.updateAvailableQuantity(
|
|
119
|
+
const product = yield consumer.ecommerce.updateAvailableQuantity(productVariant.id, {
|
|
119
120
|
location_id: locations[0].id,
|
|
120
121
|
available_quantity: 1,
|
|
121
122
|
});
|
|
@@ -161,12 +162,15 @@ globals_1.test.skip('createOrder', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
161
162
|
let orders;
|
|
162
163
|
(0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
163
164
|
orders = yield consumer.ecommerce.getOrders({
|
|
164
|
-
date_from: '
|
|
165
|
-
date_to: '
|
|
165
|
+
date_from: '2023-01-08',
|
|
166
|
+
date_to: '2023-01-01',
|
|
166
167
|
});
|
|
167
168
|
(0, globals_1.expect)(orders).toBeInstanceOf(Array);
|
|
168
169
|
}));
|
|
169
|
-
|
|
170
|
+
globals_1.test.skip('getOrder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
if (!(orders === null || orders === void 0 ? void 0 : orders.length)) {
|
|
172
|
+
throw new Error('No orders found to test getOrder');
|
|
173
|
+
}
|
|
170
174
|
const order = yield consumer.ecommerce.getOrder(orders[0].id);
|
|
171
175
|
(0, globals_1.expect)(order).toBeTruthy();
|
|
172
176
|
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
@@ -37,10 +37,10 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
45
|
(0, globals_1.test)('getIntegrations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
const integrations = yield client.Integrations.getIntegrations();
|
|
@@ -37,12 +37,12 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
|
-
const consumerId = process.env.
|
|
45
|
+
const consumerId = process.env.CHIFT_INVOICING_CONSUMER_ID;
|
|
46
46
|
let consumer;
|
|
47
47
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
48
|
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
@@ -51,14 +51,15 @@ let invoices;
|
|
|
51
51
|
(0, globals_1.test)('getInvoices', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
52
|
invoices = yield consumer.invoicing.getInvoices({
|
|
53
53
|
invoice_type: 'customer_invoice',
|
|
54
|
-
date_from: '2023-01-01',
|
|
55
|
-
date_to: '2023-01-31',
|
|
56
54
|
});
|
|
57
55
|
(0, globals_1.expect)(invoices).toBeInstanceOf(Array);
|
|
58
56
|
(0, globals_1.expect)(invoices.length).toBeGreaterThan(0);
|
|
59
57
|
(0, globals_1.expect)(invoices[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
60
58
|
}));
|
|
61
59
|
(0, globals_1.test)('getInvoiceById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
if (!invoices.length) {
|
|
61
|
+
throw new Error('No invoices found to test getInvoiceById');
|
|
62
|
+
}
|
|
62
63
|
const invoice = yield consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
|
|
63
64
|
(0, globals_1.expect)(invoice).toHaveProperty('id', globals_1.expect.any(String));
|
|
64
65
|
}));
|
|
@@ -85,13 +86,16 @@ let vatCodes;
|
|
|
85
86
|
(0, globals_1.expect)(tax).toHaveProperty('id', globals_1.expect.any(String));
|
|
86
87
|
}));
|
|
87
88
|
let opportunities;
|
|
88
|
-
|
|
89
|
+
globals_1.test.skip('getOpportunities', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
90
|
opportunities = yield consumer.invoicing.getOpportunities();
|
|
90
91
|
(0, globals_1.expect)(opportunities).toBeInstanceOf(Array);
|
|
91
92
|
(0, globals_1.expect)(opportunities.length).toBeGreaterThan(0);
|
|
92
93
|
(0, globals_1.expect)(opportunities[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
93
94
|
}));
|
|
94
|
-
|
|
95
|
+
globals_1.test.skip('getOpportunitiesById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
if (!opportunities.length) {
|
|
97
|
+
throw new Error('No opportunities found to test getOpportunitiesById');
|
|
98
|
+
}
|
|
95
99
|
const opportunity = yield consumer.invoicing.getOpportunitiesById(opportunities[0].id);
|
|
96
100
|
(0, globals_1.expect)(opportunity).toHaveProperty('id', globals_1.expect.any(String));
|
|
97
101
|
}));
|
|
@@ -103,6 +107,9 @@ let contacts;
|
|
|
103
107
|
(0, globals_1.expect)(contacts[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
104
108
|
}));
|
|
105
109
|
(0, globals_1.test)('getContactById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
if (!contacts.length) {
|
|
111
|
+
throw new Error('No contacts found to test getContactById');
|
|
112
|
+
}
|
|
106
113
|
const contact = yield consumer.invoicing.getContactById(contacts[0].id);
|
|
107
114
|
(0, globals_1.expect)(contact).toHaveProperty('id', globals_1.expect.any(String));
|
|
108
115
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
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_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
|
+
});
|
|
45
|
+
// TODO: Setup Payment test data
|
|
46
|
+
const consumerId = process.env.CHIFT_PAYMENT_CONSUMER_ID;
|
|
47
|
+
let consumer;
|
|
48
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
50
|
+
}));
|
|
51
|
+
let payments;
|
|
52
|
+
(0, globals_1.test)('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
payments = yield consumer.payment.getPayments();
|
|
54
|
+
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
55
|
+
(0, globals_1.expect)(payments.length).toBeGreaterThan(0);
|
|
56
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
57
|
+
}));
|
|
58
|
+
(0, globals_1.test)('getBalances', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
const balances = yield consumer.payment.getBalances();
|
|
60
|
+
(0, globals_1.expect)(balances).toBeInstanceOf(Array);
|
|
61
|
+
(0, globals_1.expect)(balances.length).toBeGreaterThan(0);
|
|
62
|
+
(0, globals_1.expect)(balances[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
63
|
+
}));
|
|
64
|
+
globals_1.test.skip('getTransactions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
const transactions = yield consumer.payment.getTransactions();
|
|
66
|
+
(0, globals_1.expect)(transactions).toBeInstanceOf(Array);
|
|
67
|
+
(0, globals_1.expect)(transactions.length).toBeGreaterThan(0);
|
|
68
|
+
(0, globals_1.expect)(transactions[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
69
|
+
}));
|
|
70
|
+
globals_1.test.skip('getPayment', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
if (!payments.length) {
|
|
72
|
+
throw new Error('No payments found to test getPayment');
|
|
73
|
+
}
|
|
74
|
+
const payment = yield consumer.payment.getPayment({
|
|
75
|
+
payment_id: payments[0].id,
|
|
76
|
+
});
|
|
77
|
+
(0, globals_1.expect)(payment).toHaveProperty('id', payments[0].id);
|
|
78
|
+
}));
|
|
79
|
+
globals_1.test.skip('getRefunds', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const refunds = yield consumer.payment.getRefunds({
|
|
81
|
+
date_from: '2023-01-01',
|
|
82
|
+
date_to: '2023-01-31',
|
|
83
|
+
payment_id: payments[0].id,
|
|
84
|
+
});
|
|
85
|
+
(0, globals_1.expect)(refunds).toBeInstanceOf(Array);
|
|
86
|
+
(0, globals_1.expect)(refunds.length).toBeGreaterThan(0);
|
|
87
|
+
(0, globals_1.expect)(refunds[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
88
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|