@chift/chift-nodejs 1.0.16 → 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 +12 -2
- package/README.md +3 -3
- package/dist/src/modules/accounting.d.ts +3 -3
- package/dist/src/modules/api.d.ts +4322 -2766
- package/dist/src/modules/consumer.d.ts +821 -512
- package/dist/src/modules/consumer.js +3 -0
- package/dist/src/modules/consumers.d.ts +4349 -2796
- 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 +6 -6
- 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 +3471 -2231
- 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 +4 -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 +4071 -850
- 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 -12003
- package/dist/src/types/public-api/schema.js +0 -6
- package/src/types/public-api/schema.ts +0 -12073
- package/test/set_envs.sh +0 -14
package/src/types/sync.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface FlowTriggerOptions {
|
|
2
|
+
autostart?: boolean;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface FlowTrigger {
|
|
6
|
+
id: string;
|
|
7
|
+
type: 'event' | 'timer';
|
|
8
|
+
cronschedules?: string[];
|
|
9
|
+
definitionFields?: any[];
|
|
10
|
+
visible?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
options?: FlowTriggerOptions;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface FlowConfig {
|
|
16
|
+
datastores?: { id: string; name: string }[];
|
|
17
|
+
definitionFields?: Record<string, unknown>[];
|
|
18
|
+
doorkeyFields?: Record<string, unknown>[];
|
|
4
19
|
}
|
|
5
20
|
|
|
6
21
|
export interface ExecutionType {
|
|
@@ -11,9 +26,9 @@ export interface ExecutionType {
|
|
|
11
26
|
export interface ContextType {
|
|
12
27
|
name: string;
|
|
13
28
|
description?: string;
|
|
14
|
-
|
|
29
|
+
triggers: FlowTrigger[];
|
|
15
30
|
execution: ExecutionType;
|
|
16
|
-
config?:
|
|
31
|
+
config?: FlowConfig;
|
|
17
32
|
}
|
|
18
33
|
|
|
19
34
|
export interface SimpleResponseModel {
|
|
@@ -7,13 +7,13 @@ import fs from 'fs';
|
|
|
7
7
|
dotenv.config();
|
|
8
8
|
|
|
9
9
|
const client = new chift.API({
|
|
10
|
-
baseUrl: process.env.
|
|
11
|
-
clientId: process.env.
|
|
12
|
-
clientSecret: process.env.
|
|
13
|
-
accountId: process.env.
|
|
10
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
11
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
12
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
13
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
const consumerId = process.env.
|
|
16
|
+
const consumerId = process.env.CHIFT_ACCOUNTING_CONSUMER_ID as string;
|
|
17
17
|
|
|
18
18
|
let consumer: any;
|
|
19
19
|
beforeAll(async () => {
|
|
@@ -40,7 +40,7 @@ test('getJournals', async () => {
|
|
|
40
40
|
expect(journals[0]).toHaveProperty('journal_type', expect.any(String));
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
let vatCodes: components['schemas']['
|
|
43
|
+
let vatCodes: components['schemas']['backbone_api__app__routers__accounting__VatCode'][];
|
|
44
44
|
test('getVatCodes', async () => {
|
|
45
45
|
vatCodes = await consumer.accounting.getVatCodes();
|
|
46
46
|
expect(vatCodes).toBeInstanceOf(Array);
|
|
@@ -59,6 +59,7 @@ test('createClient', async () => {
|
|
|
59
59
|
name: 'John Doe',
|
|
60
60
|
currency: 'EUR',
|
|
61
61
|
active: false,
|
|
62
|
+
is_company: true,
|
|
62
63
|
addresses: [
|
|
63
64
|
{
|
|
64
65
|
address_type: 'main',
|
|
@@ -106,13 +107,13 @@ test('getClient', async () => {
|
|
|
106
107
|
expect(client).toHaveProperty('addresses', expect.any(Array));
|
|
107
108
|
});
|
|
108
109
|
|
|
109
|
-
test('updateClient', async () => {
|
|
110
|
+
test.skip('updateClient', async () => {
|
|
110
111
|
const client = clients.find((client) => client.external_reference === 'sdk test');
|
|
111
112
|
const updatedClient = await consumer.accounting.updateClient(client?.id, {
|
|
112
|
-
|
|
113
|
+
website: 'https://test.com',
|
|
113
114
|
});
|
|
114
115
|
expect(updatedClient).toBeTruthy();
|
|
115
|
-
expect(updatedClient).toHaveProperty('
|
|
116
|
+
expect(updatedClient).toHaveProperty('website', 'https://test.com');
|
|
116
117
|
});
|
|
117
118
|
|
|
118
119
|
test('createSupplier', async () => {
|
|
@@ -121,6 +122,7 @@ test('createSupplier', async () => {
|
|
|
121
122
|
name: 'Jane Doe',
|
|
122
123
|
currency: 'EUR',
|
|
123
124
|
active: false,
|
|
125
|
+
is_company: true,
|
|
124
126
|
addresses: [
|
|
125
127
|
{
|
|
126
128
|
address_type: 'main',
|
|
@@ -167,7 +169,7 @@ test('getSupplier', async () => {
|
|
|
167
169
|
expect(supplier).toHaveProperty('addresses', expect.any(Array));
|
|
168
170
|
});
|
|
169
171
|
|
|
170
|
-
test('updateSupplier', async () => {
|
|
172
|
+
test.skip('updateSupplier', async () => {
|
|
171
173
|
const supplier = suppliers.find((supplier) => supplier.external_reference === 'sdk test');
|
|
172
174
|
const updatedSupplier = await consumer.accounting.updateSupplier(supplier?.id, {
|
|
173
175
|
name: 'Jane Updated Doe',
|
|
@@ -197,6 +199,8 @@ test('createInvoice', async () => {
|
|
|
197
199
|
total: 121,
|
|
198
200
|
partner_id: clients[0]?.id as string,
|
|
199
201
|
journal_id: journal.id,
|
|
202
|
+
status: 'draft',
|
|
203
|
+
currency_exchange_rate: 1,
|
|
200
204
|
lines: [
|
|
201
205
|
{
|
|
202
206
|
description: 'Test',
|
|
@@ -208,6 +212,7 @@ test('createInvoice', async () => {
|
|
|
208
212
|
total: 121,
|
|
209
213
|
account_number: '700000',
|
|
210
214
|
tax_code: vatCode.id,
|
|
215
|
+
line_number: 1,
|
|
211
216
|
},
|
|
212
217
|
],
|
|
213
218
|
};
|
|
@@ -288,6 +293,8 @@ test('createInvoiceWithMultiplePlans', async () => {
|
|
|
288
293
|
total: 121,
|
|
289
294
|
partner_id: clients[0]?.id as string,
|
|
290
295
|
journal_id: journal.id,
|
|
296
|
+
status: 'draft',
|
|
297
|
+
currency_exchange_rate: 1,
|
|
291
298
|
lines: [
|
|
292
299
|
{
|
|
293
300
|
description: 'Test',
|
|
@@ -299,6 +306,7 @@ test('createInvoiceWithMultiplePlans', async () => {
|
|
|
299
306
|
total: 121,
|
|
300
307
|
account_number: '700000',
|
|
301
308
|
tax_code: vatCode.id,
|
|
309
|
+
line_number: 1,
|
|
302
310
|
},
|
|
303
311
|
],
|
|
304
312
|
};
|
|
@@ -330,17 +338,14 @@ test('getAnalyticAccounts', async () => {
|
|
|
330
338
|
analyticAccounts = await consumer.accounting.getAnalyticAccounts();
|
|
331
339
|
expect(analyticAccounts).toBeInstanceOf(Array);
|
|
332
340
|
expect(analyticAccounts.length).toBeGreaterThan(0);
|
|
333
|
-
expect(analyticAccounts[0]).toHaveProperty('active', expect.any(Boolean));
|
|
334
|
-
expect(analyticAccounts[0]).toHaveProperty('code', expect.any(String));
|
|
335
|
-
expect(analyticAccounts[0]).toHaveProperty('name', expect.any(String));
|
|
336
|
-
expect(analyticAccounts[0]).toHaveProperty('currency', expect.any(String));
|
|
337
341
|
expect(analyticAccounts[0]).toHaveProperty('id', expect.any(String));
|
|
338
|
-
expect(analyticAccounts[0]).toHaveProperty('balance', expect.any(Number));
|
|
339
|
-
expect(analyticAccounts[0]).toHaveProperty('debit', expect.any(Number));
|
|
340
|
-
expect(analyticAccounts[0]).toHaveProperty('credit', expect.any(Number));
|
|
341
342
|
});
|
|
342
343
|
|
|
343
|
-
test('createAnalyticAccountWithMultiplePlans', async () => {
|
|
344
|
+
test.skip('createAnalyticAccountWithMultiplePlans', async () => {
|
|
345
|
+
if (analyticPlans.length === 0) {
|
|
346
|
+
throw new Error('No analytic plans found to create analytic account with multiple plans');
|
|
347
|
+
}
|
|
348
|
+
|
|
344
349
|
const analyticAccount = await consumer.accounting.createAnalyticAccountWithMultiplePlans(
|
|
345
350
|
analyticPlans[0].id,
|
|
346
351
|
{
|
|
@@ -353,11 +358,19 @@ test('createAnalyticAccountWithMultiplePlans', async () => {
|
|
|
353
358
|
});
|
|
354
359
|
|
|
355
360
|
test('getAnalyticAccount', async () => {
|
|
361
|
+
if (analyticAccounts.length === 0) {
|
|
362
|
+
throw new Error('No analytic accounts found to get analytic account');
|
|
363
|
+
}
|
|
364
|
+
|
|
356
365
|
const analyticAccount = await consumer.accounting.getAnalyticAccount(analyticAccounts[0].id);
|
|
357
366
|
expect(analyticAccount).toBeTruthy();
|
|
358
367
|
});
|
|
359
368
|
|
|
360
|
-
test('updateAnalyticAccount', async () => {
|
|
369
|
+
test.skip('updateAnalyticAccount', async () => {
|
|
370
|
+
if (analyticAccounts.length === 0) {
|
|
371
|
+
throw new Error('No analytic accounts found to update analytic account');
|
|
372
|
+
}
|
|
373
|
+
|
|
361
374
|
const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'sdk test');
|
|
362
375
|
const analyticAccount = await consumer.accounting.updateAnalyticAccount(
|
|
363
376
|
testAnalyticAccount?.id,
|
|
@@ -367,7 +380,11 @@ test('updateAnalyticAccount', async () => {
|
|
|
367
380
|
expect(analyticAccount).toHaveProperty('name', 'test sdk update');
|
|
368
381
|
});
|
|
369
382
|
|
|
370
|
-
test('getAnalyticAccountWithMultiplePlans', async () => {
|
|
383
|
+
test.skip('getAnalyticAccountWithMultiplePlans', async () => {
|
|
384
|
+
if (analyticPlans.length === 0) {
|
|
385
|
+
throw new Error('No analytic plans found to get analytic account with multiple plans');
|
|
386
|
+
}
|
|
387
|
+
|
|
371
388
|
const analyticAccount = await consumer.accounting.getAnalyticAccountWithMultiplePlans(
|
|
372
389
|
analyticAccounts[0].id,
|
|
373
390
|
analyticPlans[0].id
|
|
@@ -375,7 +392,13 @@ test('getAnalyticAccountWithMultiplePlans', async () => {
|
|
|
375
392
|
expect(analyticAccount).toBeTruthy();
|
|
376
393
|
});
|
|
377
394
|
|
|
378
|
-
test('updateAnalyticAccountWithMultiplePlans', async () => {
|
|
395
|
+
test.skip('updateAnalyticAccountWithMultiplePlans', async () => {
|
|
396
|
+
if (!analyticAccounts.length) {
|
|
397
|
+
throw new Error(
|
|
398
|
+
'No analytic accounts found to update analytic account with multiple plans'
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
379
402
|
const testAnalyticAccount = analyticAccounts.find(
|
|
380
403
|
(account) => account.name === 'test sdk update'
|
|
381
404
|
);
|
|
@@ -389,34 +412,36 @@ test('updateAnalyticAccountWithMultiplePlans', async () => {
|
|
|
389
412
|
expect(analyticAccount).toHaveProperty('name', 'test sdk update 2');
|
|
390
413
|
});
|
|
391
414
|
|
|
392
|
-
test('getAnalyticAccountsWithMultiplePlans', async () => {
|
|
415
|
+
test.skip('getAnalyticAccountsWithMultiplePlans', async () => {
|
|
393
416
|
const analyticAccountsWithMultiplePlans =
|
|
394
417
|
await consumer.accounting.getAnalyticAccountsWithMultiplePlans();
|
|
395
418
|
expect(analyticAccountsWithMultiplePlans).toBeInstanceOf(Array);
|
|
396
419
|
});
|
|
397
420
|
|
|
398
|
-
test('createJournalEntry', async () => {
|
|
421
|
+
test.skip('createJournalEntry', async () => {
|
|
399
422
|
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
400
423
|
if (!journal) {
|
|
401
424
|
throw new Error('No journal with type "customer_invoice" found to create journal entry');
|
|
402
425
|
}
|
|
426
|
+
|
|
427
|
+
if (!clients.length) {
|
|
428
|
+
throw new Error('No clients found to create journal entry');
|
|
429
|
+
}
|
|
430
|
+
|
|
403
431
|
const journalEntry = await consumer.accounting.createJournalEntry({
|
|
404
432
|
journal_id: journal.id,
|
|
405
|
-
|
|
433
|
+
number: new Date().valueOf(),
|
|
434
|
+
currency: 'EUR',
|
|
406
435
|
date: '2022-01-01',
|
|
407
436
|
items: [
|
|
408
437
|
{
|
|
409
|
-
|
|
438
|
+
account_type: 'customer_account',
|
|
439
|
+
account: clients[0].id,
|
|
410
440
|
credit: 0,
|
|
411
441
|
debit: 10,
|
|
412
|
-
partner_id: clients[0].id,
|
|
413
|
-
currency: 'EUR',
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
account_number: '700000',
|
|
417
|
-
credit: 10,
|
|
418
|
-
debit: 0,
|
|
419
442
|
currency: 'EUR',
|
|
443
|
+
prioritise_thirdparty_account: false,
|
|
444
|
+
analytic_distribution: [],
|
|
420
445
|
},
|
|
421
446
|
],
|
|
422
447
|
});
|
|
@@ -509,7 +534,7 @@ test('getChartOfAccounts', async () => {
|
|
|
509
534
|
expect(chartOfAccounts).toBeTruthy();
|
|
510
535
|
});
|
|
511
536
|
|
|
512
|
-
test('getBalanceOfAccounts', async () => {
|
|
537
|
+
test.skip('getBalanceOfAccounts', async () => {
|
|
513
538
|
const balanceOfAccounts = await consumer.accounting.getBalanceOfAccounts({
|
|
514
539
|
accounts: ['7'],
|
|
515
540
|
start: '2022-01-01',
|
|
@@ -525,23 +550,13 @@ test('getEmployees', async () => {
|
|
|
525
550
|
expect(employees).toBeTruthy();
|
|
526
551
|
});
|
|
527
552
|
|
|
528
|
-
test('getOutstandings', async () => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
expect(outstandings).toBeTruthy();
|
|
536
|
-
expect(outstandings.items).toBeInstanceOf(Array);
|
|
537
|
-
} catch (e: any) {
|
|
538
|
-
if (e?.error?.error_code) {
|
|
539
|
-
expect(e.error.error_code).toMatch('ERROR_API_RESOURCE_NOT_FOUND');
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
throw e;
|
|
544
|
-
}
|
|
553
|
+
test.skip('getOutstandings', async () => {
|
|
554
|
+
const outstandings = await consumer.accounting.getOutstandings({
|
|
555
|
+
type: 'client',
|
|
556
|
+
unposted_allowed: false,
|
|
557
|
+
});
|
|
558
|
+
expect(outstandings).toBeTruthy();
|
|
559
|
+
expect(outstandings.items).toBeInstanceOf(Array);
|
|
545
560
|
});
|
|
546
561
|
|
|
547
562
|
test('createFinancialEntry', async () => {
|
|
@@ -552,6 +567,10 @@ test('createFinancialEntry', async () => {
|
|
|
552
567
|
);
|
|
553
568
|
}
|
|
554
569
|
|
|
570
|
+
if (!clients.length) {
|
|
571
|
+
throw new Error('No clients found to create journal entry');
|
|
572
|
+
}
|
|
573
|
+
|
|
555
574
|
const financialEntry = await consumer.accounting.createFinancialEntry({
|
|
556
575
|
date: '2022-01-01',
|
|
557
576
|
journal_id: journal.id,
|
|
@@ -5,10 +5,10 @@ import { components } from '../../src/types/public-api/schema';
|
|
|
5
5
|
dotenv.config();
|
|
6
6
|
|
|
7
7
|
const client = new chift.API({
|
|
8
|
-
baseUrl: process.env.
|
|
9
|
-
clientId: process.env.
|
|
10
|
-
clientSecret: process.env.
|
|
11
|
-
accountId: process.env.
|
|
8
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
9
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
10
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
11
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
const consumerName = 'test consumer 2';
|
|
@@ -36,7 +36,7 @@ test('createConnection', async () => {
|
|
|
36
36
|
expect(result).toHaveProperty('url', expect.any(String));
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
let connections: components['schemas']['
|
|
39
|
+
let connections: components['schemas']['backbone_api__app__routers__connections__ConnectionItem'][];
|
|
40
40
|
|
|
41
41
|
test('getConnections', async () => {
|
|
42
42
|
connections = await syncConsumer.getConnections();
|
|
@@ -6,10 +6,10 @@ import * as dotenv from 'dotenv';
|
|
|
6
6
|
dotenv.config();
|
|
7
7
|
|
|
8
8
|
const client = new chift.API({
|
|
9
|
-
baseUrl: process.env.
|
|
10
|
-
clientId: process.env.
|
|
11
|
-
clientSecret: process.env.
|
|
12
|
-
accountId: process.env.
|
|
9
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
10
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
11
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
12
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
const consumerName = 'test consumer';
|
|
@@ -5,13 +5,13 @@ import { components } from '../../src/types/public-api/schema';
|
|
|
5
5
|
dotenv.config();
|
|
6
6
|
|
|
7
7
|
const client = new chift.API({
|
|
8
|
-
baseUrl: process.env.
|
|
9
|
-
clientId: process.env.
|
|
10
|
-
clientSecret: process.env.
|
|
11
|
-
accountId: process.env.
|
|
8
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
9
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
10
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
11
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const consumerId = process.env.
|
|
14
|
+
const consumerId = process.env.CHIFT_ECOMMERCE_CONSUMER_ID as string;
|
|
15
15
|
|
|
16
16
|
let consumer: any;
|
|
17
17
|
beforeAll(async () => {
|
|
@@ -26,7 +26,7 @@ test('getCustomers', async () => {
|
|
|
26
26
|
expect(customers[0]).toHaveProperty('id', expect.any(String));
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
let products: components['schemas']['
|
|
29
|
+
let products: components['schemas']['backbone_api__app__routers__commerce__ProductItem'][];
|
|
30
30
|
test('getProducts', async () => {
|
|
31
31
|
products = await consumer.ecommerce.getProducts();
|
|
32
32
|
expect(products).toBeInstanceOf(Array);
|
|
@@ -64,18 +64,19 @@ test('getProduct', async () => {
|
|
|
64
64
|
expect(product).toHaveProperty('common_images');
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
let productVariant: components['schemas']['VariantItem'];
|
|
68
|
+
test.skip('getProductVariantById', async () => {
|
|
68
69
|
if (!products?.length) {
|
|
69
70
|
throw new Error('No product to test');
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
if (!products[0].variants) {
|
|
73
|
+
if (!products[0].variants.length) {
|
|
73
74
|
throw new Error('No product variant to test');
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
expect(
|
|
78
|
-
expect(
|
|
77
|
+
productVariant = await consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
|
|
78
|
+
expect(productVariant).toBeTruthy();
|
|
79
|
+
expect(productVariant).toHaveProperty('id', expect.any(String));
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
let locations: components['schemas']['CommerceLocationItem'][];
|
|
@@ -87,16 +88,16 @@ test('getLocations', async () => {
|
|
|
87
88
|
expect(locations[0]).toHaveProperty('name', expect.any(String));
|
|
88
89
|
});
|
|
89
90
|
|
|
90
|
-
test('updateAvailableQuantity', async () => {
|
|
91
|
-
if (!
|
|
92
|
-
throw new Error('No product to
|
|
91
|
+
test.skip('updateAvailableQuantity', async () => {
|
|
92
|
+
if (!productVariant) {
|
|
93
|
+
throw new Error('No product variant found to update available quantity');
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
if (!
|
|
96
|
-
throw new Error('No
|
|
96
|
+
if (!locations?.length) {
|
|
97
|
+
throw new Error('No location found to update available quantity');
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
const product = await consumer.ecommerce.updateAvailableQuantity(
|
|
100
|
+
const product = await consumer.ecommerce.updateAvailableQuantity(productVariant.id, {
|
|
100
101
|
location_id: locations[0].id,
|
|
101
102
|
available_quantity: 1,
|
|
102
103
|
});
|
|
@@ -144,13 +145,17 @@ test.skip('createOrder', async () => {
|
|
|
144
145
|
let orders: components['schemas']['OrderItemOut'][];
|
|
145
146
|
test('getOrders', async () => {
|
|
146
147
|
orders = await consumer.ecommerce.getOrders({
|
|
147
|
-
date_from: '
|
|
148
|
-
date_to: '
|
|
148
|
+
date_from: '2023-01-08',
|
|
149
|
+
date_to: '2023-01-01',
|
|
149
150
|
});
|
|
150
151
|
expect(orders).toBeInstanceOf(Array);
|
|
151
152
|
});
|
|
152
153
|
|
|
153
|
-
test('getOrder', async () => {
|
|
154
|
+
test.skip('getOrder', async () => {
|
|
155
|
+
if (!orders?.length) {
|
|
156
|
+
throw new Error('No orders found to test getOrder');
|
|
157
|
+
}
|
|
158
|
+
|
|
154
159
|
const order = await consumer.ecommerce.getOrder(orders[0].id);
|
|
155
160
|
expect(order).toBeTruthy();
|
|
156
161
|
expect(order).toHaveProperty('id', expect.any(String));
|
|
@@ -4,10 +4,10 @@ import * as dotenv from 'dotenv';
|
|
|
4
4
|
dotenv.config();
|
|
5
5
|
|
|
6
6
|
const client = new chift.API({
|
|
7
|
-
baseUrl: process.env.
|
|
8
|
-
clientId: process.env.
|
|
9
|
-
clientSecret: process.env.
|
|
10
|
-
accountId: process.env.
|
|
7
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
8
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
9
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
10
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
test('getIntegrations', async () => {
|
|
@@ -5,13 +5,13 @@ import { components } from '../../src/types/public-api/schema';
|
|
|
5
5
|
dotenv.config();
|
|
6
6
|
|
|
7
7
|
const client = new chift.API({
|
|
8
|
-
baseUrl: process.env.
|
|
9
|
-
clientId: process.env.
|
|
10
|
-
clientSecret: process.env.
|
|
11
|
-
accountId: process.env.
|
|
8
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
9
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
10
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
11
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const consumerId = process.env.
|
|
14
|
+
const consumerId = process.env.CHIFT_INVOICING_CONSUMER_ID as string;
|
|
15
15
|
|
|
16
16
|
let consumer: any;
|
|
17
17
|
beforeAll(async () => {
|
|
@@ -22,8 +22,6 @@ let invoices: components['schemas']['InvoiceItemOut'][];
|
|
|
22
22
|
test('getInvoices', async () => {
|
|
23
23
|
invoices = await consumer.invoicing.getInvoices({
|
|
24
24
|
invoice_type: 'customer_invoice',
|
|
25
|
-
date_from: '2023-01-01',
|
|
26
|
-
date_to: '2023-01-31',
|
|
27
25
|
});
|
|
28
26
|
expect(invoices).toBeInstanceOf(Array);
|
|
29
27
|
expect(invoices.length).toBeGreaterThan(0);
|
|
@@ -31,6 +29,10 @@ test('getInvoices', async () => {
|
|
|
31
29
|
});
|
|
32
30
|
|
|
33
31
|
test('getInvoiceById', async () => {
|
|
32
|
+
if (!invoices.length) {
|
|
33
|
+
throw new Error('No invoices found to test getInvoiceById');
|
|
34
|
+
}
|
|
35
|
+
|
|
34
36
|
const invoice = await consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
|
|
35
37
|
expect(invoice).toHaveProperty('id', expect.any(String));
|
|
36
38
|
});
|
|
@@ -48,7 +50,7 @@ test('getProductById', async () => {
|
|
|
48
50
|
expect(product).toHaveProperty('id', expect.any(String));
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
let vatCodes: components['schemas']['
|
|
53
|
+
let vatCodes: components['schemas']['backbone_common__models__invoicing__VatCode'][];
|
|
52
54
|
test('getTaxes', async () => {
|
|
53
55
|
vatCodes = await consumer.invoicing.getTaxes();
|
|
54
56
|
expect(vatCodes).toBeInstanceOf(Array);
|
|
@@ -62,14 +64,18 @@ test('getTaxById', async () => {
|
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
let opportunities: components['schemas']['OpportunityItem'][];
|
|
65
|
-
test('getOpportunities', async () => {
|
|
67
|
+
test.skip('getOpportunities', async () => {
|
|
66
68
|
opportunities = await consumer.invoicing.getOpportunities();
|
|
67
69
|
expect(opportunities).toBeInstanceOf(Array);
|
|
68
70
|
expect(opportunities.length).toBeGreaterThan(0);
|
|
69
71
|
expect(opportunities[0]).toHaveProperty('id', expect.any(String));
|
|
70
72
|
});
|
|
71
73
|
|
|
72
|
-
test('getOpportunitiesById', async () => {
|
|
74
|
+
test.skip('getOpportunitiesById', async () => {
|
|
75
|
+
if (!opportunities.length) {
|
|
76
|
+
throw new Error('No opportunities found to test getOpportunitiesById');
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
const opportunity = await consumer.invoicing.getOpportunitiesById(opportunities[0].id);
|
|
74
80
|
expect(opportunity).toHaveProperty('id', expect.any(String));
|
|
75
81
|
});
|
|
@@ -83,6 +89,10 @@ test('getContacts', async () => {
|
|
|
83
89
|
});
|
|
84
90
|
|
|
85
91
|
test('getContactById', async () => {
|
|
92
|
+
if (!contacts.length) {
|
|
93
|
+
throw new Error('No contacts found to test getContactById');
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
const contact = await consumer.invoicing.getContactById(contacts[0].id);
|
|
87
97
|
expect(contact).toHaveProperty('id', expect.any(String));
|
|
88
98
|
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { beforeAll, expect, test } from '@jest/globals';
|
|
2
|
+
import * as chift from '../../src/index';
|
|
3
|
+
import * as dotenv from 'dotenv';
|
|
4
|
+
import { components } from '../../src/types/public-api/schema';
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
const client = new chift.API({
|
|
8
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
9
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
10
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
11
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
12
|
+
});
|
|
13
|
+
// TODO: Setup Payment test data
|
|
14
|
+
const consumerId = process.env.CHIFT_PAYMENT_CONSUMER_ID as string;
|
|
15
|
+
|
|
16
|
+
let consumer: any;
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
consumer = await client.Consumers.getConsumerById(consumerId);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
let payments: components['schemas']['PaymentItemOut'][];
|
|
22
|
+
test('getPayments', async () => {
|
|
23
|
+
payments = await consumer.payment.getPayments();
|
|
24
|
+
expect(payments).toBeInstanceOf(Array);
|
|
25
|
+
expect(payments.length).toBeGreaterThan(0);
|
|
26
|
+
expect(payments[0]).toHaveProperty('id', expect.any(String));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('getBalances', async () => {
|
|
30
|
+
const balances: components['schemas']['BalanceItemOut'][] =
|
|
31
|
+
await consumer.payment.getBalances();
|
|
32
|
+
expect(balances).toBeInstanceOf(Array);
|
|
33
|
+
expect(balances.length).toBeGreaterThan(0);
|
|
34
|
+
expect(balances[0]).toHaveProperty('id', expect.any(String));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test.skip('getTransactions', async () => {
|
|
38
|
+
const transactions: components['schemas']['TransactionItemOut'][] =
|
|
39
|
+
await consumer.payment.getTransactions();
|
|
40
|
+
expect(transactions).toBeInstanceOf(Array);
|
|
41
|
+
expect(transactions.length).toBeGreaterThan(0);
|
|
42
|
+
expect(transactions[0]).toHaveProperty('id', expect.any(String));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test.skip('getPayment', async () => {
|
|
46
|
+
if (!payments.length) {
|
|
47
|
+
throw new Error('No payments found to test getPayment');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const payment: components['schemas']['PaymentItemOut'] = await consumer.payment.getPayment({
|
|
51
|
+
payment_id: payments[0].id,
|
|
52
|
+
});
|
|
53
|
+
expect(payment).toHaveProperty('id', payments[0].id);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test.skip('getRefunds', async () => {
|
|
57
|
+
const refunds: components['schemas']['RefundItemOut'][] = await consumer.payment.getRefunds({
|
|
58
|
+
date_from: '2023-01-01',
|
|
59
|
+
date_to: '2023-01-31',
|
|
60
|
+
payment_id: payments[0].id,
|
|
61
|
+
});
|
|
62
|
+
expect(refunds).toBeInstanceOf(Array);
|
|
63
|
+
expect(refunds.length).toBeGreaterThan(0);
|
|
64
|
+
expect(refunds[0]).toHaveProperty('id', expect.any(String));
|
|
65
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { beforeAll, expect, test } from '@jest/globals';
|
|
2
|
+
import * as chift from '../../src/index';
|
|
3
|
+
import * as dotenv from 'dotenv';
|
|
4
|
+
import { components } from '../../src/types/public-api/schema';
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
const client = new chift.API({
|
|
8
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
9
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID as string,
|
|
10
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET as string,
|
|
11
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID as string,
|
|
12
|
+
});
|
|
13
|
+
// TODO: Setup PMS test data
|
|
14
|
+
const consumerId = process.env.CHIFT_PMS_CONSUMER_ID as string;
|
|
15
|
+
|
|
16
|
+
let consumer: any;
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
consumer = await client.Consumers.getConsumerById(consumerId);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test.skip('getLocations', async () => {
|
|
22
|
+
const locations: components['schemas']['PMSLocationItem'][] = await consumer.pms.getLocations();
|
|
23
|
+
expect(locations).toBeInstanceOf(Array);
|
|
24
|
+
expect(locations.length).toBeGreaterThan(0);
|
|
25
|
+
expect(locations[0]).toHaveProperty('id', expect.any(String));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test.skip('getOrders', async () => {
|
|
29
|
+
const orders: components['schemas']['PMSOrderItem'][] = await consumer.pms.getOrders({
|
|
30
|
+
date_from: '2023-01-01',
|
|
31
|
+
date_to: '2023-01-31',
|
|
32
|
+
});
|
|
33
|
+
expect(orders).toBeInstanceOf(Array);
|
|
34
|
+
expect(orders.length).toBeGreaterThan(0);
|
|
35
|
+
expect(orders[0]).toHaveProperty('id', expect.any(String));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test.skip('getPaymentMethods', async () => {
|
|
39
|
+
const paymentMethods: components['schemas']['PMSPaymentMethods'][] =
|
|
40
|
+
await consumer.pms.getPaymentMethods();
|
|
41
|
+
expect(paymentMethods).toBeInstanceOf(Array);
|
|
42
|
+
expect(paymentMethods.length).toBeGreaterThan(0);
|
|
43
|
+
expect(paymentMethods[0]).toHaveProperty('id', expect.any(String));
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test.skip('getClosure', async () => {
|
|
47
|
+
const closure: components['schemas']['PMSClosureItem'] = await consumer.pms.getClosure(
|
|
48
|
+
'2023-01-01'
|
|
49
|
+
);
|
|
50
|
+
expect(closure).toHaveProperty('id', expect.any(String));
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test.skip('getPayments', async () => {
|
|
54
|
+
const payments: components['schemas']['PMSPaymentItem'][] = await consumer.pms.getPayments({
|
|
55
|
+
date_from: '2023-01-01',
|
|
56
|
+
date_to: '2023-01-31',
|
|
57
|
+
});
|
|
58
|
+
expect(payments).toBeInstanceOf(Array);
|
|
59
|
+
expect(payments.length).toBeGreaterThan(0);
|
|
60
|
+
expect(payments[0]).toHaveProperty('id', expect.any(String));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test.skip('getAccountingCategories', async () => {
|
|
64
|
+
const accountingCategories: components['schemas']['PMSAccountingCategoryItem'][] =
|
|
65
|
+
await consumer.pms.getAccountingCategories();
|
|
66
|
+
expect(accountingCategories).toBeInstanceOf(Array);
|
|
67
|
+
expect(accountingCategories.length).toBeGreaterThan(0);
|
|
68
|
+
expect(accountingCategories[0]).toHaveProperty('id', expect.any(String));
|
|
69
|
+
});
|