@chift/chift-nodejs 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -2
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -25
- package/.github/workflows/ci.yml +0 -75
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -1
- package/.prettierrc.json +0 -7
- package/CHANGELOG.md +0 -108
- package/dist/src/helpers/openapi.d.ts +0 -3
- package/dist/src/helpers/openapi.js +0 -18
- package/dist/src/helpers/settings.d.ts +0 -4
- package/dist/src/helpers/settings.js +0 -5
- package/dist/src/index.d.ts +0 -1
- package/dist/src/modules/accounting.d.ts +0 -68
- package/dist/src/modules/accounting.js +0 -326
- package/dist/src/modules/api.d.ts +0 -18351
- package/dist/src/modules/api.js +0 -36
- package/dist/src/modules/consumer.d.ts +0 -3622
- package/dist/src/modules/consumer.js +0 -142
- package/dist/src/modules/consumers.d.ts +0 -18237
- package/dist/src/modules/consumers.js +0 -51
- package/dist/src/modules/custom.d.ts +0 -8
- package/dist/src/modules/custom.js +0 -36
- package/dist/src/modules/datastores.d.ts +0 -18
- package/dist/src/modules/datastores.js +0 -23
- package/dist/src/modules/ecommerce.d.ts +0 -24
- package/dist/src/modules/ecommerce.js +0 -97
- package/dist/src/modules/flow.d.ts +0 -15
- package/dist/src/modules/flow.js +0 -156
- package/dist/src/modules/integrations.d.ts +0 -23
- package/dist/src/modules/integrations.js +0 -23
- package/dist/src/modules/internalApi.d.ts +0 -24
- package/dist/src/modules/internalApi.js +0 -175
- package/dist/src/modules/invoicing.d.ts +0 -20
- package/dist/src/modules/invoicing.js +0 -90
- package/dist/src/modules/payment.d.ts +0 -14
- package/dist/src/modules/payment.js +0 -41
- package/dist/src/modules/pms.d.ts +0 -15
- package/dist/src/modules/pms.js +0 -47
- package/dist/src/modules/pos.d.ts +0 -26
- package/dist/src/modules/pos.js +0 -101
- package/dist/src/modules/sync.d.ts +0 -14654
- package/dist/src/modules/sync.js +0 -73
- package/dist/src/modules/syncs.d.ts +0 -11
- package/dist/src/modules/syncs.js +0 -39
- package/dist/src/modules/webhooks.d.ts +0 -58
- package/dist/src/modules/webhooks.js +0 -53
- package/dist/src/types/api.d.ts +0 -29
- package/dist/src/types/api.js +0 -2
- package/dist/src/types/consumers.d.ts +0 -8
- package/dist/src/types/consumers.js +0 -2
- package/dist/src/types/public-api/mappings.d.ts +0 -21
- package/dist/src/types/public-api/mappings.js +0 -2
- package/dist/src/types/sync.d.ts +0 -37
- package/dist/src/types/sync.js +0 -2
- package/dist/test/modules/accounting.test.d.ts +0 -1
- package/dist/test/modules/accounting.test.js +0 -590
- package/dist/test/modules/consumer.test.d.ts +0 -1
- package/dist/test/modules/consumer.test.js +0 -89
- package/dist/test/modules/consumers.test.d.ts +0 -1
- package/dist/test/modules/consumers.test.js +0 -109
- package/dist/test/modules/ecommerce.test.d.ts +0 -1
- package/dist/test/modules/ecommerce.test.js +0 -224
- package/dist/test/modules/integrations.test.d.ts +0 -1
- package/dist/test/modules/integrations.test.js +0 -54
- package/dist/test/modules/invoicing.test.d.ts +0 -1
- package/dist/test/modules/invoicing.test.js +0 -115
- package/dist/test/modules/payment.test.d.ts +0 -1
- package/dist/test/modules/payment.test.js +0 -88
- package/dist/test/modules/pms.test.d.ts +0 -1
- package/dist/test/modules/pms.test.js +0 -90
- package/dist/test/modules/pos.test.d.ts +0 -1
- package/dist/test/modules/pos.test.js +0 -179
- package/dist/test/modules/sync.test.d.ts +0 -1
- package/dist/test/modules/sync.test.js +0 -93
- package/dist/test/modules/syncs.test.d.ts +0 -1
- package/dist/test/modules/syncs.test.js +0 -53
- package/dist/test/modules/webhooks.test.d.ts +0 -1
- package/dist/test/modules/webhooks.test.js +0 -120
- package/jest.config.ts +0 -195
- package/src/helpers/openapi.ts +0 -22
- package/src/helpers/settings.ts +0 -3
- package/src/index.ts +0 -1
- package/src/modules/accounting.ts +0 -510
- package/src/modules/api.ts +0 -35
- package/src/modules/consumer.ts +0 -216
- package/src/modules/consumers.ts +0 -82
- package/src/modules/custom.ts +0 -36
- package/src/modules/datastores.ts +0 -19
- package/src/modules/ecommerce.ts +0 -129
- package/src/modules/flow.ts +0 -168
- package/src/modules/integrations.ts +0 -24
- package/src/modules/internalApi.ts +0 -182
- package/src/modules/invoicing.ts +0 -118
- package/src/modules/payment.ts +0 -59
- package/src/modules/pms.ts +0 -67
- package/src/modules/pos.ts +0 -144
- package/src/modules/sync.ts +0 -77
- package/src/modules/syncs.ts +0 -59
- package/src/modules/webhooks.ts +0 -86
- package/test/data/accounting_invoice.pdf +0 -0
- package/test/modules/accounting.test.ts +0 -647
- package/test/modules/consumer.test.ts +0 -68
- package/test/modules/consumers.test.ts +0 -85
- package/test/modules/ecommerce.test.ts +0 -213
- package/test/modules/integrations.test.ts +0 -22
- package/test/modules/invoicing.test.ts +0 -98
- package/test/modules/payment.test.ts +0 -65
- package/test/modules/pms.test.ts +0 -69
- package/test/modules/pos.test.ts +0 -164
- package/test/modules/sync.test.ts +0 -74
- package/test/modules/syncs.test.ts +0 -23
- package/test/modules/webhooks.test.ts +0 -92
- package/tsconfig.json +0 -107
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
|
|
14
|
-
const consumerName = 'test consumer 2';
|
|
15
|
-
const email = 'support@chift.eu';
|
|
16
|
-
const redirect_url = 'https://chift.eu';
|
|
17
|
-
|
|
18
|
-
let syncConsumer: any;
|
|
19
|
-
let consumer: any;
|
|
20
|
-
let connection: any;
|
|
21
|
-
|
|
22
|
-
beforeAll(async () => {
|
|
23
|
-
consumer = await client.Consumers.createConsumer({
|
|
24
|
-
email,
|
|
25
|
-
redirect_url,
|
|
26
|
-
name: consumerName,
|
|
27
|
-
});
|
|
28
|
-
syncConsumer = await client.Consumers.getConsumerById(
|
|
29
|
-
process.env.CHIFT_SYNC_CONSUMER_ID as string
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('createConnection', async () => {
|
|
34
|
-
const body = { integrationid: 1000, name: 'odoo test sdk' };
|
|
35
|
-
const result = await consumer.createConnection(body);
|
|
36
|
-
expect(result).toHaveProperty('url', expect.any(String));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
let connections: components['schemas']['backbone_api__app__routers__connections__ConnectionItem'][];
|
|
40
|
-
|
|
41
|
-
test('getConnections', async () => {
|
|
42
|
-
connections = await syncConsumer.getConnections();
|
|
43
|
-
expect(connections).toBeInstanceOf(Array);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test.skip('updateConnection', async () => {
|
|
47
|
-
const updatedConnection = await syncConsumer.updateConnection(connections[0]?.connectionid, {
|
|
48
|
-
name: 'updated connection name',
|
|
49
|
-
});
|
|
50
|
-
expect(updatedConnection).toHaveProperty('name', 'updated connection name');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test.skip('deleteConnection', async () => {
|
|
54
|
-
await consumer.deleteConnection(connection.connectionId);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('getSyncUrl', async () => {
|
|
58
|
-
const result = await syncConsumer.getSyncUrl({
|
|
59
|
-
syncid: process.env.CHIFT_TEST_SYNC_ID as string,
|
|
60
|
-
integrationids: [],
|
|
61
|
-
});
|
|
62
|
-
expect(result).toHaveProperty('url', expect.any(String));
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('getSyncData', async () => {
|
|
66
|
-
const syncData = await syncConsumer.getSyncData(process.env.CHIFT_TEST_SYNC_ID as string);
|
|
67
|
-
expect(syncData).toBeTruthy();
|
|
68
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { beforeAll, expect, test } from '@jest/globals';
|
|
2
|
-
import * as chift from '../../src/index';
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
import * as dotenv from 'dotenv';
|
|
5
|
-
|
|
6
|
-
dotenv.config();
|
|
7
|
-
|
|
8
|
-
const client = new chift.API({
|
|
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
|
-
});
|
|
14
|
-
|
|
15
|
-
const consumerName = 'test consumer';
|
|
16
|
-
const email = 'support@chift.eu';
|
|
17
|
-
const redirect_url = 'https://chift.eu';
|
|
18
|
-
|
|
19
|
-
let consumer: any;
|
|
20
|
-
|
|
21
|
-
beforeAll(async () => {
|
|
22
|
-
consumer = await client.Consumers.createConsumer({
|
|
23
|
-
email,
|
|
24
|
-
redirect_url,
|
|
25
|
-
name: consumerName,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('createConsumer', async () => {
|
|
30
|
-
expect(consumer).toHaveProperty('consumerId');
|
|
31
|
-
expect(consumer).toHaveProperty('getConnections');
|
|
32
|
-
expect(consumer).toHaveProperty('createConnection');
|
|
33
|
-
expect(consumer).toHaveProperty('updateConnection');
|
|
34
|
-
expect(consumer).toHaveProperty('deleteConnection');
|
|
35
|
-
expect(consumer).toHaveProperty('getSyncUrl');
|
|
36
|
-
expect(consumer).toHaveProperty('name', consumerName);
|
|
37
|
-
expect(consumer).toHaveProperty('redirect_url', redirect_url);
|
|
38
|
-
expect(consumer).toHaveProperty('email', email);
|
|
39
|
-
expect(consumer).toHaveProperty('pos');
|
|
40
|
-
expect(consumer).toHaveProperty('accounting');
|
|
41
|
-
expect(consumer).toHaveProperty('invoicing');
|
|
42
|
-
expect(consumer).toHaveProperty('ecommerce');
|
|
43
|
-
expect(consumer).toHaveProperty('custom');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('getConsumers', async () => {
|
|
47
|
-
const consumers = await client.Consumers.getConsumers();
|
|
48
|
-
expect(consumers).toBeInstanceOf(Array);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('getConsumersByName', async () => {
|
|
52
|
-
const consumersWithName = await client.Consumers.getConsumersByName(consumerName);
|
|
53
|
-
expect(consumersWithName).toBeInstanceOf(Array);
|
|
54
|
-
expect(consumersWithName.some((consumer: any) => consumer.name.includes(consumerName))).toBe(
|
|
55
|
-
true
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('getConsumerById', async () => {
|
|
60
|
-
const consumerWithId = await client.Consumers.getConsumerById(consumer.consumerId);
|
|
61
|
-
expect(consumerWithId).toHaveProperty('consumerId', consumer.consumerId);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('updateConsumerById', async () => {
|
|
65
|
-
const updatedName = 'updated test consumer';
|
|
66
|
-
const updatedConsumer = await client.Consumers.updateConsumerById(consumer.consumerId, {
|
|
67
|
-
name: updatedName,
|
|
68
|
-
});
|
|
69
|
-
expect(updatedConsumer).toHaveProperty('name', updatedName);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('deleteConsumerById', async () => {
|
|
73
|
-
expect.assertions(1);
|
|
74
|
-
try {
|
|
75
|
-
await client.Consumers.deleteConsumerById(consumer.consumerId);
|
|
76
|
-
await client.Consumers.getConsumerById(consumer.consumerId);
|
|
77
|
-
} catch (e: unknown) {
|
|
78
|
-
if (axios.isAxiosError(e)) {
|
|
79
|
-
expect(e.message).toMatch('Request failed with status code 404');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
throw e;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
|
|
14
|
-
const consumerId = process.env.CHIFT_ECOMMERCE_CONSUMER_ID as string;
|
|
15
|
-
|
|
16
|
-
let consumer: any;
|
|
17
|
-
beforeAll(async () => {
|
|
18
|
-
consumer = await client.Consumers.getConsumerById(consumerId);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
let customers: components['schemas']['CommerceCustomerItem'][];
|
|
22
|
-
test('getCustomers', async () => {
|
|
23
|
-
customers = await consumer.ecommerce.getCustomers();
|
|
24
|
-
expect(customers).toBeInstanceOf(Array);
|
|
25
|
-
expect(customers.length).toBeGreaterThan(0);
|
|
26
|
-
expect(customers[0]).toHaveProperty('id', expect.any(String));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
let products: components['schemas']['backbone_api__app__routers__commerce__ProductItem'][];
|
|
30
|
-
test('getProducts', async () => {
|
|
31
|
-
products = await consumer.ecommerce.getProducts();
|
|
32
|
-
expect(products).toBeInstanceOf(Array);
|
|
33
|
-
expect(products.length).toBeGreaterThan(0);
|
|
34
|
-
expect(products[0]).toHaveProperty('id', expect.any(String));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('getCustomer', async () => {
|
|
38
|
-
const customer = await consumer.ecommerce.getCustomer(customers[0].id);
|
|
39
|
-
expect(customer).toHaveProperty('id', customers[0].id);
|
|
40
|
-
expect(customer).toHaveProperty('first_name');
|
|
41
|
-
expect(customer).toHaveProperty('last_name');
|
|
42
|
-
expect(customer).toHaveProperty('phone');
|
|
43
|
-
expect(customer).toHaveProperty('email');
|
|
44
|
-
expect(customer).toHaveProperty('language');
|
|
45
|
-
expect(customer).toHaveProperty('internal_notes');
|
|
46
|
-
expect(customer).toHaveProperty('currency');
|
|
47
|
-
expect(customer).toHaveProperty('addresses');
|
|
48
|
-
expect(customer).toHaveProperty('created_on');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('getProduct', async () => {
|
|
52
|
-
const product = await consumer.ecommerce.getProduct(products[0].id);
|
|
53
|
-
expect(product).toBeTruthy();
|
|
54
|
-
expect(product).toHaveProperty('id', products[0].id);
|
|
55
|
-
expect(product).toHaveProperty('name', expect.any(String));
|
|
56
|
-
expect(product).toHaveProperty('description');
|
|
57
|
-
expect(product).toHaveProperty('description_html');
|
|
58
|
-
expect(product).toHaveProperty('categories');
|
|
59
|
-
expect(product).toHaveProperty('created_on');
|
|
60
|
-
expect(product).toHaveProperty('variants');
|
|
61
|
-
expect(product).toHaveProperty('status');
|
|
62
|
-
expect(product).toHaveProperty('common_attributes');
|
|
63
|
-
expect(product).toHaveProperty('variant_attributes_options');
|
|
64
|
-
expect(product).toHaveProperty('common_images');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
let productVariant: components['schemas']['VariantItem'];
|
|
68
|
-
test.skip('getProductVariantById', async () => {
|
|
69
|
-
if (!products?.length) {
|
|
70
|
-
throw new Error('No product to test');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!products[0].variants.length) {
|
|
74
|
-
throw new Error('No product variant to test');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
productVariant = await consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
|
|
78
|
-
expect(productVariant).toBeTruthy();
|
|
79
|
-
expect(productVariant).toHaveProperty('id', expect.any(String));
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
let locations: components['schemas']['CommerceLocationItem'][];
|
|
83
|
-
test('getLocations', async () => {
|
|
84
|
-
locations = await consumer.ecommerce.getLocations();
|
|
85
|
-
expect(locations).toBeInstanceOf(Array);
|
|
86
|
-
expect(locations.length).toBeGreaterThan(0);
|
|
87
|
-
expect(locations[0]).toHaveProperty('id', expect.any(String));
|
|
88
|
-
expect(locations[0]).toHaveProperty('name', expect.any(String));
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test.skip('updateAvailableQuantity', async () => {
|
|
92
|
-
if (!productVariant) {
|
|
93
|
-
throw new Error('No product variant found to update available quantity');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (!locations?.length) {
|
|
97
|
-
throw new Error('No location found to update available quantity');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const product = await consumer.ecommerce.updateAvailableQuantity(productVariant.id, {
|
|
101
|
-
location_id: locations[0].id,
|
|
102
|
-
available_quantity: 1,
|
|
103
|
-
});
|
|
104
|
-
expect(product).toBeTruthy();
|
|
105
|
-
expect(product).toHaveProperty('available_quantity', expect.any(Number));
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// TODO: Fix create order test
|
|
109
|
-
test.skip('createOrder', async () => {
|
|
110
|
-
const order = await consumer.ecommerce.createOrder({
|
|
111
|
-
customer: {
|
|
112
|
-
email: 'test@test.com',
|
|
113
|
-
},
|
|
114
|
-
billing_address: {
|
|
115
|
-
first_name: 'Test',
|
|
116
|
-
last_name: 'Test',
|
|
117
|
-
street: 'Test',
|
|
118
|
-
number: '1',
|
|
119
|
-
city: 'Test',
|
|
120
|
-
country: 'BE',
|
|
121
|
-
},
|
|
122
|
-
shipping_address: {
|
|
123
|
-
first_name: 'Test',
|
|
124
|
-
last_name: 'Test',
|
|
125
|
-
street: 'Test',
|
|
126
|
-
number: '1',
|
|
127
|
-
city: 'Test',
|
|
128
|
-
country: 'BE',
|
|
129
|
-
},
|
|
130
|
-
currency: 'EUR',
|
|
131
|
-
lines: [
|
|
132
|
-
{
|
|
133
|
-
variant_id: '1',
|
|
134
|
-
quantity: 1,
|
|
135
|
-
tax_rate: 21.0,
|
|
136
|
-
unit_price: 10.0,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
payment_method: 'bank-transfer',
|
|
140
|
-
});
|
|
141
|
-
expect(order).toBeTruthy();
|
|
142
|
-
expect(order).toHaveProperty('id', expect.any(String));
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
let orders: components['schemas']['OrderItemOut'][];
|
|
146
|
-
test('getOrders', async () => {
|
|
147
|
-
orders = await consumer.ecommerce.getOrders({
|
|
148
|
-
date_from: '2023-01-08',
|
|
149
|
-
date_to: '2023-01-01',
|
|
150
|
-
});
|
|
151
|
-
expect(orders).toBeInstanceOf(Array);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test.skip('getOrder', async () => {
|
|
155
|
-
if (!orders?.length) {
|
|
156
|
-
throw new Error('No orders found to test getOrder');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const order = await consumer.ecommerce.getOrder(orders[0].id);
|
|
160
|
-
expect(order).toBeTruthy();
|
|
161
|
-
expect(order).toHaveProperty('id', expect.any(String));
|
|
162
|
-
expect(order).toHaveProperty('order_number');
|
|
163
|
-
expect(order).toHaveProperty('billing_address');
|
|
164
|
-
expect(order).toHaveProperty('shipping_address');
|
|
165
|
-
expect(order).toHaveProperty('created_on');
|
|
166
|
-
expect(order).toHaveProperty('confirmed_on');
|
|
167
|
-
expect(order).toHaveProperty('cancelled_on');
|
|
168
|
-
expect(order).toHaveProperty('status', expect.any(String));
|
|
169
|
-
expect(order).toHaveProperty('discount_amount', expect.any(Number));
|
|
170
|
-
expect(order).toHaveProperty('untaxed_amount_without_fees', expect.any(Number));
|
|
171
|
-
expect(order).toHaveProperty('tax_amount_without_fees', expect.any(Number));
|
|
172
|
-
expect(order).toHaveProperty('total_without_fees', expect.any(Number));
|
|
173
|
-
expect(order).toHaveProperty('untaxed_amount', expect.any(Number));
|
|
174
|
-
expect(order).toHaveProperty('tax_amount', expect.any(Number));
|
|
175
|
-
expect(order).toHaveProperty('total', expect.any(Number));
|
|
176
|
-
expect(order).toHaveProperty('refunded_amount', expect.any(Number));
|
|
177
|
-
expect(order).toHaveProperty('currency');
|
|
178
|
-
expect(order).toHaveProperty('note');
|
|
179
|
-
expect(order).toHaveProperty('lines', expect.any(Array));
|
|
180
|
-
expect(order).toHaveProperty('other_fees');
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test('getPaymentMethods', async () => {
|
|
184
|
-
const paymentMethods = await consumer.ecommerce.getPaymentMethods();
|
|
185
|
-
expect(paymentMethods).toBeInstanceOf(Array);
|
|
186
|
-
expect(paymentMethods.length).toBeGreaterThan(0);
|
|
187
|
-
expect(paymentMethods[0]).toHaveProperty('id', expect.any(String));
|
|
188
|
-
expect(paymentMethods[0]).toHaveProperty('name', expect.any(String));
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('getProductCategories', async () => {
|
|
192
|
-
const productCategories = await consumer.ecommerce.getProductCategories();
|
|
193
|
-
expect(productCategories).toBeInstanceOf(Array);
|
|
194
|
-
expect(productCategories.length).toBeGreaterThan(0);
|
|
195
|
-
expect(productCategories[0]).toHaveProperty('id', expect.any(String));
|
|
196
|
-
expect(productCategories[0]).toHaveProperty('name', expect.any(String));
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
test('getCountries', async () => {
|
|
200
|
-
const countries = await consumer.ecommerce.getCountries();
|
|
201
|
-
expect(countries).toBeInstanceOf(Array);
|
|
202
|
-
expect(countries.length).toBeGreaterThan(0);
|
|
203
|
-
expect(countries[0]).toHaveProperty('code', expect.any(String));
|
|
204
|
-
expect(countries[0]).toHaveProperty('name', expect.any(String));
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test('getTaxes', async () => {
|
|
208
|
-
const taxes = await consumer.ecommerce.getTaxes();
|
|
209
|
-
expect(taxes).toBeInstanceOf(Array);
|
|
210
|
-
expect(taxes.length).toBeGreaterThan(0);
|
|
211
|
-
expect(taxes[0]).toHaveProperty('id', expect.any(String));
|
|
212
|
-
expect(taxes[0]).toHaveProperty('rate', expect.any(Number));
|
|
213
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { expect, test } from '@jest/globals';
|
|
2
|
-
import * as chift from '../../src/index';
|
|
3
|
-
import * as dotenv from 'dotenv';
|
|
4
|
-
dotenv.config();
|
|
5
|
-
|
|
6
|
-
const client = new chift.API({
|
|
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
|
-
});
|
|
12
|
-
|
|
13
|
-
test('getIntegrations', async () => {
|
|
14
|
-
const integrations = await client.Integrations.getIntegrations();
|
|
15
|
-
expect(integrations).toBeInstanceOf(Array);
|
|
16
|
-
expect(integrations.length).toBeGreaterThan(0);
|
|
17
|
-
expect(integrations[0]).toHaveProperty('integrationid', expect.any(Number));
|
|
18
|
-
expect(integrations[0]).toHaveProperty('name', expect.any(String));
|
|
19
|
-
expect(integrations[0]).toHaveProperty('status', expect.stringMatching(/^(active|inactive)$/));
|
|
20
|
-
expect(integrations[0]).toHaveProperty('api', expect.any(String));
|
|
21
|
-
expect(integrations[0]).toHaveProperty('credentials', expect.any(Array));
|
|
22
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
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
|
-
|
|
14
|
-
const consumerId = process.env.CHIFT_INVOICING_CONSUMER_ID as string;
|
|
15
|
-
|
|
16
|
-
let consumer: any;
|
|
17
|
-
beforeAll(async () => {
|
|
18
|
-
consumer = await client.Consumers.getConsumerById(consumerId);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
let invoices: components['schemas']['InvoiceItemOut'][];
|
|
22
|
-
test('getInvoices', async () => {
|
|
23
|
-
invoices = await consumer.invoicing.getInvoices({
|
|
24
|
-
invoice_type: 'customer_invoice',
|
|
25
|
-
});
|
|
26
|
-
expect(invoices).toBeInstanceOf(Array);
|
|
27
|
-
expect(invoices.length).toBeGreaterThan(0);
|
|
28
|
-
expect(invoices[0]).toHaveProperty('id', expect.any(String));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('getInvoiceById', async () => {
|
|
32
|
-
if (!invoices.length) {
|
|
33
|
-
throw new Error('No invoices found to test getInvoiceById');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const invoice = await consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
|
|
37
|
-
expect(invoice).toHaveProperty('id', expect.any(String));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
let products: components['schemas']['ProductItemOut'][];
|
|
41
|
-
test('getProducts', async () => {
|
|
42
|
-
products = await consumer.invoicing.getProducts();
|
|
43
|
-
expect(products).toBeInstanceOf(Array);
|
|
44
|
-
expect(products.length).toBeGreaterThan(0);
|
|
45
|
-
expect(products[0]).toHaveProperty('id', expect.any(String));
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('getProductById', async () => {
|
|
49
|
-
const product = await consumer.invoicing.getProductById(products[0].id);
|
|
50
|
-
expect(product).toHaveProperty('id', expect.any(String));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
let vatCodes: components['schemas']['backbone_common__models__invoicing__VatCode'][];
|
|
54
|
-
test('getTaxes', async () => {
|
|
55
|
-
vatCodes = await consumer.invoicing.getTaxes();
|
|
56
|
-
expect(vatCodes).toBeInstanceOf(Array);
|
|
57
|
-
expect(vatCodes.length).toBeGreaterThan(0);
|
|
58
|
-
expect(vatCodes[0]).toHaveProperty('id', expect.any(String));
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('getTaxById', async () => {
|
|
62
|
-
const tax = await consumer.invoicing.getTaxById(vatCodes[0].id);
|
|
63
|
-
expect(tax).toHaveProperty('id', expect.any(String));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
let opportunities: components['schemas']['OpportunityItem'][];
|
|
67
|
-
test.skip('getOpportunities', async () => {
|
|
68
|
-
opportunities = await consumer.invoicing.getOpportunities();
|
|
69
|
-
expect(opportunities).toBeInstanceOf(Array);
|
|
70
|
-
expect(opportunities.length).toBeGreaterThan(0);
|
|
71
|
-
expect(opportunities[0]).toHaveProperty('id', expect.any(String));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test.skip('getOpportunitiesById', async () => {
|
|
75
|
-
if (!opportunities.length) {
|
|
76
|
-
throw new Error('No opportunities found to test getOpportunitiesById');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const opportunity = await consumer.invoicing.getOpportunitiesById(opportunities[0].id);
|
|
80
|
-
expect(opportunity).toHaveProperty('id', expect.any(String));
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
let contacts: components['schemas']['ContactItemOut'][];
|
|
84
|
-
test('getContacts', async () => {
|
|
85
|
-
contacts = await consumer.invoicing.getContacts();
|
|
86
|
-
expect(contacts).toBeInstanceOf(Array);
|
|
87
|
-
expect(contacts.length).toBeGreaterThan(0);
|
|
88
|
-
expect(contacts[0]).toHaveProperty('id', expect.any(String));
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('getContactById', async () => {
|
|
92
|
-
if (!contacts.length) {
|
|
93
|
-
throw new Error('No contacts found to test getContactById');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const contact = await consumer.invoicing.getContactById(contacts[0].id);
|
|
97
|
-
expect(contact).toHaveProperty('id', expect.any(String));
|
|
98
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
});
|
package/test/modules/pms.test.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
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
|
-
});
|