@chift/chift-nodejs 1.0.16 → 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.
Files changed (145) hide show
  1. package/README.md +3 -3
  2. package/package.json +5 -2
  3. package/src/types/public-api/schema.d.ts +4071 -850
  4. package/src/types/sync.ts +20 -5
  5. package/.eslintcache +0 -1
  6. package/.eslintignore +0 -1
  7. package/.eslintrc.json +0 -25
  8. package/.github/workflows/ci.yml +0 -75
  9. package/.husky/pre-commit +0 -4
  10. package/.prettierignore +0 -1
  11. package/.prettierrc.json +0 -7
  12. package/CHANGELOG.md +0 -98
  13. package/coverage/clover.xml +0 -1645
  14. package/coverage/coverage-final.json +0 -19
  15. package/coverage/lcov-report/base.css +0 -224
  16. package/coverage/lcov-report/block-navigation.js +0 -87
  17. package/coverage/lcov-report/favicon.png +0 -0
  18. package/coverage/lcov-report/index.html +0 -146
  19. package/coverage/lcov-report/prettify.css +0 -1
  20. package/coverage/lcov-report/prettify.js +0 -2
  21. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  22. package/coverage/lcov-report/sorter.js +0 -196
  23. package/coverage/lcov-report/src/helpers/index.html +0 -131
  24. package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
  25. package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
  26. package/coverage/lcov-report/src/index.html +0 -116
  27. package/coverage/lcov-report/src/index.ts.html +0 -88
  28. package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
  29. package/coverage/lcov-report/src/modules/api.ts.html +0 -190
  30. package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
  31. package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
  32. package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
  33. package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
  34. package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
  35. package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
  36. package/coverage/lcov-report/src/modules/index.html +0 -326
  37. package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
  38. package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
  39. package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
  40. package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
  41. package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
  42. package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
  43. package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
  44. package/coverage/lcov.info +0 -1976
  45. package/dist/src/helpers/openapi.d.ts +0 -3
  46. package/dist/src/helpers/openapi.js +0 -18
  47. package/dist/src/helpers/settings.d.ts +0 -4
  48. package/dist/src/helpers/settings.js +0 -5
  49. package/dist/src/index.d.ts +0 -1
  50. package/dist/src/modules/accounting.d.ts +0 -68
  51. package/dist/src/modules/accounting.js +0 -326
  52. package/dist/src/modules/api.d.ts +0 -16795
  53. package/dist/src/modules/api.js +0 -36
  54. package/dist/src/modules/consumer.d.ts +0 -3313
  55. package/dist/src/modules/consumer.js +0 -139
  56. package/dist/src/modules/consumers.d.ts +0 -16684
  57. package/dist/src/modules/consumers.js +0 -51
  58. package/dist/src/modules/custom.d.ts +0 -8
  59. package/dist/src/modules/custom.js +0 -36
  60. package/dist/src/modules/datastores.d.ts +0 -18
  61. package/dist/src/modules/datastores.js +0 -23
  62. package/dist/src/modules/ecommerce.d.ts +0 -24
  63. package/dist/src/modules/ecommerce.js +0 -97
  64. package/dist/src/modules/flow.d.ts +0 -15
  65. package/dist/src/modules/flow.js +0 -156
  66. package/dist/src/modules/integrations.d.ts +0 -23
  67. package/dist/src/modules/integrations.js +0 -23
  68. package/dist/src/modules/internalApi.d.ts +0 -24
  69. package/dist/src/modules/internalApi.js +0 -175
  70. package/dist/src/modules/invoicing.d.ts +0 -20
  71. package/dist/src/modules/invoicing.js +0 -90
  72. package/dist/src/modules/pms.d.ts +0 -15
  73. package/dist/src/modules/pms.js +0 -47
  74. package/dist/src/modules/pos.d.ts +0 -26
  75. package/dist/src/modules/pos.js +0 -101
  76. package/dist/src/modules/sync.d.ts +0 -13414
  77. package/dist/src/modules/sync.js +0 -73
  78. package/dist/src/modules/syncs.d.ts +0 -11
  79. package/dist/src/modules/syncs.js +0 -39
  80. package/dist/src/modules/webhooks.d.ts +0 -55
  81. package/dist/src/modules/webhooks.js +0 -53
  82. package/dist/src/types/api.d.ts +0 -29
  83. package/dist/src/types/api.js +0 -2
  84. package/dist/src/types/consumers.d.ts +0 -8
  85. package/dist/src/types/consumers.js +0 -2
  86. package/dist/src/types/public-api/mappings.d.ts +0 -21
  87. package/dist/src/types/public-api/mappings.js +0 -2
  88. package/dist/src/types/public-api/schema.d.ts +0 -12003
  89. package/dist/src/types/public-api/schema.js +0 -6
  90. package/dist/src/types/sync.d.ts +0 -20
  91. package/dist/src/types/sync.js +0 -2
  92. package/dist/test/modules/accounting.test.d.ts +0 -1
  93. package/dist/test/modules/accounting.test.js +0 -582
  94. package/dist/test/modules/consumer.test.d.ts +0 -1
  95. package/dist/test/modules/consumer.test.js +0 -89
  96. package/dist/test/modules/consumers.test.d.ts +0 -1
  97. package/dist/test/modules/consumers.test.js +0 -109
  98. package/dist/test/modules/ecommerce.test.d.ts +0 -1
  99. package/dist/test/modules/ecommerce.test.js +0 -220
  100. package/dist/test/modules/integrations.test.d.ts +0 -1
  101. package/dist/test/modules/integrations.test.js +0 -54
  102. package/dist/test/modules/invoicing.test.d.ts +0 -1
  103. package/dist/test/modules/invoicing.test.js +0 -108
  104. package/dist/test/modules/pos.test.d.ts +0 -1
  105. package/dist/test/modules/pos.test.js +0 -182
  106. package/dist/test/modules/sync.test.d.ts +0 -1
  107. package/dist/test/modules/sync.test.js +0 -81
  108. package/dist/test/modules/syncs.test.d.ts +0 -1
  109. package/dist/test/modules/syncs.test.js +0 -53
  110. package/dist/test/modules/webhooks.test.d.ts +0 -1
  111. package/dist/test/modules/webhooks.test.js +0 -120
  112. package/jest.config.ts +0 -195
  113. package/src/helpers/openapi.ts +0 -22
  114. package/src/helpers/settings.ts +0 -3
  115. package/src/index.ts +0 -1
  116. package/src/modules/accounting.ts +0 -510
  117. package/src/modules/api.ts +0 -35
  118. package/src/modules/consumer.ts +0 -213
  119. package/src/modules/consumers.ts +0 -82
  120. package/src/modules/custom.ts +0 -36
  121. package/src/modules/datastores.ts +0 -19
  122. package/src/modules/ecommerce.ts +0 -127
  123. package/src/modules/flow.ts +0 -168
  124. package/src/modules/integrations.ts +0 -24
  125. package/src/modules/internalApi.ts +0 -182
  126. package/src/modules/invoicing.ts +0 -114
  127. package/src/modules/pms.ts +0 -67
  128. package/src/modules/pos.ts +0 -144
  129. package/src/modules/sync.ts +0 -77
  130. package/src/modules/syncs.ts +0 -59
  131. package/src/modules/webhooks.ts +0 -86
  132. package/src/types/public-api/schema.ts +0 -12073
  133. package/test/data/accounting_invoice.pdf +0 -0
  134. package/test/modules/accounting.test.ts +0 -628
  135. package/test/modules/consumer.test.ts +0 -68
  136. package/test/modules/consumers.test.ts +0 -85
  137. package/test/modules/ecommerce.test.ts +0 -208
  138. package/test/modules/integrations.test.ts +0 -22
  139. package/test/modules/invoicing.test.ts +0 -88
  140. package/test/modules/pos.test.ts +0 -166
  141. package/test/modules/sync.test.ts +0 -60
  142. package/test/modules/syncs.test.ts +0 -23
  143. package/test/modules/webhooks.test.ts +0 -92
  144. package/test/set_envs.sh +0 -14
  145. package/tsconfig.json +0 -107
@@ -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_BASE_URL,
10
- clientId: process.env.CHIFT_CLIENT_ID as string,
11
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
12
- accountId: process.env.CHIFT_ACCOUNT_ID 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,208 +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_BASE_URL,
9
- clientId: process.env.CHIFT_CLIENT_ID as string,
10
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
11
- accountId: process.env.CHIFT_ACCOUNT_ID as string,
12
- });
13
-
14
- const consumerId = process.env.CHIFT_WOOCOMMERCE_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']['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
- test('getProductVariantById', async () => {
68
- if (!products?.length) {
69
- throw new Error('No product to test');
70
- }
71
-
72
- if (!products[0].variants) {
73
- throw new Error('No product variant to test');
74
- }
75
-
76
- const variant = await consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
77
- expect(variant).toBeTruthy();
78
- expect(variant).toHaveProperty('id', expect.any(String));
79
- });
80
-
81
- let locations: components['schemas']['CommerceLocationItem'][];
82
- test('getLocations', async () => {
83
- locations = await consumer.ecommerce.getLocations();
84
- expect(locations).toBeInstanceOf(Array);
85
- expect(locations.length).toBeGreaterThan(0);
86
- expect(locations[0]).toHaveProperty('id', expect.any(String));
87
- expect(locations[0]).toHaveProperty('name', expect.any(String));
88
- });
89
-
90
- test('updateAvailableQuantity', async () => {
91
- if (!products?.length) {
92
- throw new Error('No product to test');
93
- }
94
-
95
- if (!products[0].variants) {
96
- throw new Error('No product variant to test');
97
- }
98
-
99
- const product = await consumer.ecommerce.updateAvailableQuantity(products[0].variants[0].id, {
100
- location_id: locations[0].id,
101
- available_quantity: 1,
102
- });
103
- expect(product).toBeTruthy();
104
- expect(product).toHaveProperty('available_quantity', expect.any(Number));
105
- });
106
-
107
- // TODO: Fix create order test
108
- test.skip('createOrder', async () => {
109
- const order = await consumer.ecommerce.createOrder({
110
- customer: {
111
- email: 'test@test.com',
112
- },
113
- billing_address: {
114
- first_name: 'Test',
115
- last_name: 'Test',
116
- street: 'Test',
117
- number: '1',
118
- city: 'Test',
119
- country: 'BE',
120
- },
121
- shipping_address: {
122
- first_name: 'Test',
123
- last_name: 'Test',
124
- street: 'Test',
125
- number: '1',
126
- city: 'Test',
127
- country: 'BE',
128
- },
129
- currency: 'EUR',
130
- lines: [
131
- {
132
- variant_id: '1',
133
- quantity: 1,
134
- tax_rate: 21.0,
135
- unit_price: 10.0,
136
- },
137
- ],
138
- payment_method: 'bank-transfer',
139
- });
140
- expect(order).toBeTruthy();
141
- expect(order).toHaveProperty('id', expect.any(String));
142
- });
143
-
144
- let orders: components['schemas']['OrderItemOut'][];
145
- test('getOrders', async () => {
146
- orders = await consumer.ecommerce.getOrders({
147
- date_from: '2021-10-01',
148
- date_to: '2021-12-31',
149
- });
150
- expect(orders).toBeInstanceOf(Array);
151
- });
152
-
153
- test('getOrder', async () => {
154
- const order = await consumer.ecommerce.getOrder(orders[0].id);
155
- expect(order).toBeTruthy();
156
- expect(order).toHaveProperty('id', expect.any(String));
157
- expect(order).toHaveProperty('order_number');
158
- expect(order).toHaveProperty('billing_address');
159
- expect(order).toHaveProperty('shipping_address');
160
- expect(order).toHaveProperty('created_on');
161
- expect(order).toHaveProperty('confirmed_on');
162
- expect(order).toHaveProperty('cancelled_on');
163
- expect(order).toHaveProperty('status', expect.any(String));
164
- expect(order).toHaveProperty('discount_amount', expect.any(Number));
165
- expect(order).toHaveProperty('untaxed_amount_without_fees', expect.any(Number));
166
- expect(order).toHaveProperty('tax_amount_without_fees', expect.any(Number));
167
- expect(order).toHaveProperty('total_without_fees', expect.any(Number));
168
- expect(order).toHaveProperty('untaxed_amount', expect.any(Number));
169
- expect(order).toHaveProperty('tax_amount', expect.any(Number));
170
- expect(order).toHaveProperty('total', expect.any(Number));
171
- expect(order).toHaveProperty('refunded_amount', expect.any(Number));
172
- expect(order).toHaveProperty('currency');
173
- expect(order).toHaveProperty('note');
174
- expect(order).toHaveProperty('lines', expect.any(Array));
175
- expect(order).toHaveProperty('other_fees');
176
- });
177
-
178
- test('getPaymentMethods', async () => {
179
- const paymentMethods = await consumer.ecommerce.getPaymentMethods();
180
- expect(paymentMethods).toBeInstanceOf(Array);
181
- expect(paymentMethods.length).toBeGreaterThan(0);
182
- expect(paymentMethods[0]).toHaveProperty('id', expect.any(String));
183
- expect(paymentMethods[0]).toHaveProperty('name', expect.any(String));
184
- });
185
-
186
- test('getProductCategories', async () => {
187
- const productCategories = await consumer.ecommerce.getProductCategories();
188
- expect(productCategories).toBeInstanceOf(Array);
189
- expect(productCategories.length).toBeGreaterThan(0);
190
- expect(productCategories[0]).toHaveProperty('id', expect.any(String));
191
- expect(productCategories[0]).toHaveProperty('name', expect.any(String));
192
- });
193
-
194
- test('getCountries', async () => {
195
- const countries = await consumer.ecommerce.getCountries();
196
- expect(countries).toBeInstanceOf(Array);
197
- expect(countries.length).toBeGreaterThan(0);
198
- expect(countries[0]).toHaveProperty('code', expect.any(String));
199
- expect(countries[0]).toHaveProperty('name', expect.any(String));
200
- });
201
-
202
- test('getTaxes', async () => {
203
- const taxes = await consumer.ecommerce.getTaxes();
204
- expect(taxes).toBeInstanceOf(Array);
205
- expect(taxes.length).toBeGreaterThan(0);
206
- expect(taxes[0]).toHaveProperty('id', expect.any(String));
207
- expect(taxes[0]).toHaveProperty('rate', expect.any(Number));
208
- });
@@ -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_BASE_URL,
8
- clientId: process.env.CHIFT_CLIENT_ID as string,
9
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
10
- accountId: process.env.CHIFT_ACCOUNT_ID 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,88 +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_BASE_URL,
9
- clientId: process.env.CHIFT_CLIENT_ID as string,
10
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
11
- accountId: process.env.CHIFT_ACCOUNT_ID as string,
12
- });
13
-
14
- const consumerId = process.env.CHIFT_AXONAUT_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
- date_from: '2023-01-01',
26
- date_to: '2023-01-31',
27
- });
28
- expect(invoices).toBeInstanceOf(Array);
29
- expect(invoices.length).toBeGreaterThan(0);
30
- expect(invoices[0]).toHaveProperty('id', expect.any(String));
31
- });
32
-
33
- test('getInvoiceById', async () => {
34
- const invoice = await consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
35
- expect(invoice).toHaveProperty('id', expect.any(String));
36
- });
37
-
38
- let products: components['schemas']['ProductItemOut'][];
39
- test('getProducts', async () => {
40
- products = await consumer.invoicing.getProducts();
41
- expect(products).toBeInstanceOf(Array);
42
- expect(products.length).toBeGreaterThan(0);
43
- expect(products[0]).toHaveProperty('id', expect.any(String));
44
- });
45
-
46
- test('getProductById', async () => {
47
- const product = await consumer.invoicing.getProductById(products[0].id);
48
- expect(product).toHaveProperty('id', expect.any(String));
49
- });
50
-
51
- let vatCodes: components['schemas']['models__invoicing__VatCode'][];
52
- test('getTaxes', async () => {
53
- vatCodes = await consumer.invoicing.getTaxes();
54
- expect(vatCodes).toBeInstanceOf(Array);
55
- expect(vatCodes.length).toBeGreaterThan(0);
56
- expect(vatCodes[0]).toHaveProperty('id', expect.any(String));
57
- });
58
-
59
- test('getTaxById', async () => {
60
- const tax = await consumer.invoicing.getTaxById(vatCodes[0].id);
61
- expect(tax).toHaveProperty('id', expect.any(String));
62
- });
63
-
64
- let opportunities: components['schemas']['OpportunityItem'][];
65
- test('getOpportunities', async () => {
66
- opportunities = await consumer.invoicing.getOpportunities();
67
- expect(opportunities).toBeInstanceOf(Array);
68
- expect(opportunities.length).toBeGreaterThan(0);
69
- expect(opportunities[0]).toHaveProperty('id', expect.any(String));
70
- });
71
-
72
- test('getOpportunitiesById', async () => {
73
- const opportunity = await consumer.invoicing.getOpportunitiesById(opportunities[0].id);
74
- expect(opportunity).toHaveProperty('id', expect.any(String));
75
- });
76
-
77
- let contacts: components['schemas']['ContactItemOut'][];
78
- test('getContacts', async () => {
79
- contacts = await consumer.invoicing.getContacts();
80
- expect(contacts).toBeInstanceOf(Array);
81
- expect(contacts.length).toBeGreaterThan(0);
82
- expect(contacts[0]).toHaveProperty('id', expect.any(String));
83
- });
84
-
85
- test('getContactById', async () => {
86
- const contact = await consumer.invoicing.getContactById(contacts[0].id);
87
- expect(contact).toHaveProperty('id', expect.any(String));
88
- });
@@ -1,166 +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_BASE_URL,
9
- clientId: process.env.CHIFT_CLIENT_ID as string,
10
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
11
- accountId: process.env.CHIFT_ACCOUNT_ID as string,
12
- });
13
-
14
- // Split testing between two APIs to support all endpoints
15
- const cashpadConsumerId = process.env.CHIFT_CASHPAD_CONSUMER_ID as string;
16
- const lightspeedConsumerId = process.env.CHIFT_LIGHTSPEED_CONSUMER_ID as string;
17
- const popinaConsumerId = process.env.CHIFT_POPINA_CONSUMER_ID as string;
18
-
19
- let cashpadConsumer: any;
20
- let lightspeedConsumer: any;
21
- let popinaConsumer: any;
22
- beforeAll(async () => {
23
- cashpadConsumer = await client.Consumers.getConsumerById(cashpadConsumerId);
24
- lightspeedConsumer = await client.Consumers.getConsumerById(lightspeedConsumerId);
25
- popinaConsumer = await client.Consumers.getConsumerById(popinaConsumerId);
26
- });
27
-
28
- test('getLocations', async () => {
29
- const locations = await lightspeedConsumer.pos.getLocations();
30
- expect(locations).toBeInstanceOf(Array);
31
- expect(locations.length).toBeGreaterThan(0);
32
- expect(locations[0]).toHaveProperty('id', expect.any(String));
33
- expect(locations[0]).toHaveProperty('name', expect.any(String));
34
- });
35
-
36
- let orders: components['schemas']['POSOrderItem'][];
37
- test('getOrders', async () => {
38
- orders = await lightspeedConsumer.pos.getOrders({
39
- date_from: '2023-01-11',
40
- date_to: '2023-02-28',
41
- });
42
- expect(orders).toBeInstanceOf(Array);
43
- expect(orders.length).toBeGreaterThan(0);
44
- expect(orders[0]).toHaveProperty('id', expect.any(String));
45
- });
46
-
47
- // TODO: Fix Method Not Allowed error
48
- test.skip('createCustomer', async () => {
49
- const body = {
50
- first_name: 'John',
51
- last_name: 'Doe',
52
- email: 'test@test.com',
53
- };
54
- const customer = await cashpadConsumer.pos.createCustomer(body);
55
- expect(customer).toBeTruthy();
56
- expect(customer).toHaveProperty('id', expect.any(String));
57
- expect(customer).toHaveProperty('name');
58
- });
59
-
60
- // TODO: Fix timeout error
61
- let customers: any[] = [];
62
- test.skip('getCustomers', async () => {
63
- customers = await cashpadConsumer.pos.getCustomers();
64
- expect(customers).toBeInstanceOf(Array);
65
- expect(customers.length).toBeGreaterThan(0);
66
- expect(customers[0]).toHaveProperty('id', expect.any(String));
67
- });
68
-
69
- // TODO: Fix The day parameter is missing error
70
- test.skip('getOrder', async () => {
71
- const order = await lightspeedConsumer.pos.getOrder(orders[0].id);
72
- expect(order).toBeTruthy();
73
- expect(order).toHaveProperty('id', expect.any(String));
74
- expect(order).toHaveProperty('order_number');
75
- expect(order).toHaveProperty('creation_date', expect.any(String));
76
- expect(order).toHaveProperty('closing_date');
77
- expect(order).toHaveProperty('service_date');
78
- expect(order).toHaveProperty('total', expect.any(Number));
79
- expect(order).toHaveProperty('tax_amount', expect.any(Number));
80
- expect(order).toHaveProperty('total_discount');
81
- expect(order).toHaveProperty('total_refund');
82
- expect(order).toHaveProperty('total_tip', expect.any(Number));
83
- expect(order).toHaveProperty('items', expect.any(Array));
84
- expect(order).toHaveProperty('payments', expect.any(Array));
85
- expect(order).toHaveProperty('currency');
86
- expect(order).toHaveProperty('country');
87
- expect(order).toHaveProperty('loyalty');
88
- expect(order).toHaveProperty('customer_id');
89
- expect(order).toHaveProperty('location_id');
90
- expect(order).toHaveProperty('taxes');
91
- });
92
-
93
- // TODO: Fix getCustomers first
94
- test.skip('getCustomer', async () => {
95
- const customer = await cashpadConsumer.pos.getCustomer(customers[0].id);
96
- expect(customer).toBeTruthy();
97
- expect(customer).toHaveProperty('id', expect.any(String));
98
- expect(customer).toHaveProperty('name');
99
- });
100
-
101
- test('getPaymentMethods', async () => {
102
- const paymentMethods = await lightspeedConsumer.pos.getPaymentMethods();
103
- expect(paymentMethods).toBeInstanceOf(Array);
104
- expect(paymentMethods.length).toBeGreaterThan(0);
105
- expect(paymentMethods[0]).toHaveProperty('id', expect.any(String));
106
- expect(paymentMethods[0]).toHaveProperty('name', expect.any(String));
107
- expect(paymentMethods[0]).toHaveProperty('extra');
108
- });
109
-
110
- test('getSales', async () => {
111
- const sales = await lightspeedConsumer.pos.getSales({
112
- date_from: '2022-08-11',
113
- date_to: '2022-08-12',
114
- });
115
- expect(sales).toHaveProperty('total', expect.any(Number));
116
- expect(sales).toHaveProperty('tax_amount', expect.any(Number));
117
- expect(sales).toHaveProperty('taxes', expect.any(Array));
118
- });
119
-
120
- test('getClosure', async () => {
121
- const closure = await lightspeedConsumer.pos.getClosure('2022-08-11');
122
- expect(closure).toHaveProperty('date', expect.any(String));
123
- expect(closure).toHaveProperty('status');
124
- });
125
-
126
- test('getPayments', async () => {
127
- const payments = await lightspeedConsumer.pos.getPayments({
128
- date_from: '2023-01-11',
129
- date_to: '2023-02-28',
130
- });
131
- expect(payments).toBeInstanceOf(Array);
132
- expect(payments.length).toBeGreaterThan(0);
133
- expect(payments[0]).toHaveProperty('id');
134
- expect(payments[0]).toHaveProperty('payment_method_id');
135
- expect(payments[0]).toHaveProperty('payment_method_name');
136
- expect(payments[0]).toHaveProperty('total', expect.any(Number));
137
- expect(payments[0]).toHaveProperty('tip', expect.any(Number));
138
- expect(payments[0]).toHaveProperty('status');
139
- expect(payments[0]).toHaveProperty('currency');
140
- expect(payments[0]).toHaveProperty('date');
141
- });
142
-
143
- // TODO: Fix API Resource does not exist
144
- test.skip('updateOrder', async () => {
145
- const order = await lightspeedConsumer.pos.updateOrder(orders[0].id, {});
146
- expect(order).toBeTruthy();
147
- expect(order).toHaveProperty('id', expect.any(String));
148
- });
149
-
150
- test('getProducts', async () => {
151
- const products = await popinaConsumer.pos.getProducts();
152
- expect(products).toBeInstanceOf(Array);
153
- expect(products.length).toBeGreaterThan(0);
154
- });
155
-
156
- test('getProductCategories', async () => {
157
- const productCategories = await popinaConsumer.pos.getProductCategories();
158
- expect(productCategories).toBeInstanceOf(Array);
159
- expect(productCategories.length).toBeGreaterThan(0);
160
- });
161
-
162
- test('getAccountingCategories', async () => {
163
- const accountingCategories = await popinaConsumer.pos.getAccountingCategories();
164
- expect(accountingCategories).toBeInstanceOf(Array);
165
- expect(accountingCategories.length).toBeGreaterThan(0);
166
- });
@@ -1,60 +0,0 @@
1
- import { beforeAll, expect, test } from '@jest/globals';
2
- import * as chift from '../../src/index';
3
- import * as dotenv from 'dotenv';
4
-
5
- dotenv.config();
6
-
7
- const client = new chift.API({
8
- baseUrl: process.env.CHIFT_BASE_URL,
9
- clientId: process.env.CHIFT_CLIENT_ID as string,
10
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
11
- accountId: process.env.CHIFT_ACCOUNT_ID as string,
12
- });
13
-
14
- const flowName = 'Je suis un flux de test';
15
-
16
- let sync: any;
17
- let flow: any;
18
-
19
- beforeAll(async () => {
20
- const syncId = process.env.CHIFT_TEST_SYNC_ID as string;
21
- sync = await client.Syncs.getSyncById(syncId);
22
- });
23
-
24
- test('createFlow', async () => {
25
- flow = await sync.createFlow(
26
- {
27
- name: flowName,
28
- description: 'Flux de test',
29
- execution: {
30
- type: 'code',
31
- },
32
- trigger: {
33
- type: 'event',
34
- },
35
- config: {},
36
- },
37
- async (consumer: any, flowContext: any) => {
38
- console.log(`Mon flow_id : ${flowContext.flow_id}`);
39
- console.log(`Bonjour, ceci est un test, on exécute le flux pour consumer: ${consumer}`);
40
- }
41
- );
42
-
43
- expect(flow).toHaveProperty('flowId');
44
- expect(flow).toHaveProperty('name', flowName);
45
- });
46
-
47
- test('getFlows', async () => {
48
- const flows = await sync.getFlows();
49
- expect(flows).toBeInstanceOf(Array);
50
- });
51
-
52
- test('getFlowByName', async () => {
53
- const flowWithName = await sync.getFlowByName(flow.name);
54
- expect(flowWithName).toHaveProperty('name', flow.name);
55
- });
56
-
57
- test('getFlowById', async () => {
58
- const flowWithId = await sync.getFlowById(flow.flowId);
59
- expect(flowWithId).toHaveProperty('flowId', flow.flowId);
60
- });
@@ -1,23 +0,0 @@
1
- import { expect, test } from '@jest/globals';
2
- import * as chift from '../../src/index';
3
- import * as dotenv from 'dotenv';
4
-
5
- dotenv.config();
6
-
7
- const client = new chift.API({
8
- baseUrl: process.env.CHIFT_BASE_URL,
9
- clientId: process.env.CHIFT_CLIENT_ID as string,
10
- clientSecret: process.env.CHIFT_CLIENT_SECRET as string,
11
- accountId: process.env.CHIFT_ACCOUNT_ID as string,
12
- });
13
-
14
- test('getSyncs', async () => {
15
- const syncs = await client.Syncs.getSyncs();
16
- expect(syncs).toBeInstanceOf(Array);
17
- });
18
-
19
- test('getSyncById', async () => {
20
- const syncId = process.env.CHIFT_TEST_SYNC_ID as string;
21
- const sync = await client.Syncs.getSyncById(syncId);
22
- expect(sync).toHaveProperty('syncid', syncId);
23
- });