@chift/chift-nodejs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/.eslintcache +1 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +25 -0
  4. package/.github/workflows/ci.yml +73 -0
  5. package/.husky/pre-commit +4 -0
  6. package/.prettierignore +1 -0
  7. package/.prettierrc.json +7 -0
  8. package/CHANGELOG.md +4 -0
  9. package/LICENSE +201 -0
  10. package/README.md +48 -0
  11. package/coverage/clover.xml +1645 -0
  12. package/coverage/coverage-final.json +19 -0
  13. package/coverage/lcov-report/base.css +224 -0
  14. package/coverage/lcov-report/block-navigation.js +87 -0
  15. package/coverage/lcov-report/favicon.png +0 -0
  16. package/coverage/lcov-report/index.html +146 -0
  17. package/coverage/lcov-report/prettify.css +1 -0
  18. package/coverage/lcov-report/prettify.js +2 -0
  19. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  20. package/coverage/lcov-report/sorter.js +196 -0
  21. package/coverage/lcov-report/src/helpers/index.html +131 -0
  22. package/coverage/lcov-report/src/helpers/openapi.ts.html +151 -0
  23. package/coverage/lcov-report/src/helpers/settings.ts.html +94 -0
  24. package/coverage/lcov-report/src/index.html +116 -0
  25. package/coverage/lcov-report/src/index.ts.html +88 -0
  26. package/coverage/lcov-report/src/modules/accounting.ts.html +1156 -0
  27. package/coverage/lcov-report/src/modules/api.ts.html +190 -0
  28. package/coverage/lcov-report/src/modules/consumer.ts.html +616 -0
  29. package/coverage/lcov-report/src/modules/consumers.ts.html +331 -0
  30. package/coverage/lcov-report/src/modules/custom.ts.html +193 -0
  31. package/coverage/lcov-report/src/modules/datastores.ts.html +142 -0
  32. package/coverage/lcov-report/src/modules/ecommerce.ts.html +331 -0
  33. package/coverage/lcov-report/src/modules/flow.ts.html +589 -0
  34. package/coverage/lcov-report/src/modules/index.html +326 -0
  35. package/coverage/lcov-report/src/modules/integrations.ts.html +151 -0
  36. package/coverage/lcov-report/src/modules/internalApi.ts.html +586 -0
  37. package/coverage/lcov-report/src/modules/invoicing.ts.html +391 -0
  38. package/coverage/lcov-report/src/modules/pos.ts.html +421 -0
  39. package/coverage/lcov-report/src/modules/sync.ts.html +316 -0
  40. package/coverage/lcov-report/src/modules/syncs.ts.html +169 -0
  41. package/coverage/lcov-report/src/modules/webhooks.ts.html +343 -0
  42. package/coverage/lcov.info +1976 -0
  43. package/dist/src/helpers/openapi.d.ts +3 -0
  44. package/dist/src/helpers/openapi.js +18 -0
  45. package/dist/src/helpers/settings.d.ts +4 -0
  46. package/dist/src/helpers/settings.js +5 -0
  47. package/dist/src/index.d.ts +1 -0
  48. package/dist/src/index.js +17 -0
  49. package/dist/src/modules/accounting.d.ts +48 -0
  50. package/dist/src/modules/accounting.js +255 -0
  51. package/dist/src/modules/api.d.ts +39333 -0
  52. package/dist/src/modules/api.js +36 -0
  53. package/dist/src/modules/consumer.d.ts +2588 -0
  54. package/dist/src/modules/consumer.js +118 -0
  55. package/dist/src/modules/consumers.d.ts +13034 -0
  56. package/dist/src/modules/consumers.js +51 -0
  57. package/dist/src/modules/custom.d.ts +8 -0
  58. package/dist/src/modules/custom.js +36 -0
  59. package/dist/src/modules/datastores.d.ts +18 -0
  60. package/dist/src/modules/datastores.js +23 -0
  61. package/dist/src/modules/ecommerce.d.ts +16 -0
  62. package/dist/src/modules/ecommerce.js +69 -0
  63. package/dist/src/modules/flow.d.ts +15 -0
  64. package/dist/src/modules/flow.js +156 -0
  65. package/dist/src/modules/integrations.d.ts +14 -0
  66. package/dist/src/modules/integrations.js +23 -0
  67. package/dist/src/modules/internalApi.d.ts +22 -0
  68. package/dist/src/modules/internalApi.js +160 -0
  69. package/dist/src/modules/invoicing.d.ts +18 -0
  70. package/dist/src/modules/invoicing.js +90 -0
  71. package/dist/src/modules/pos.d.ts +20 -0
  72. package/dist/src/modules/pos.js +80 -0
  73. package/dist/src/modules/sync.d.ts +10494 -0
  74. package/dist/src/modules/sync.js +75 -0
  75. package/dist/src/modules/syncs.d.ts +26200 -0
  76. package/dist/src/modules/syncs.js +29 -0
  77. package/dist/src/modules/webhooks.d.ts +55 -0
  78. package/dist/src/modules/webhooks.js +53 -0
  79. package/dist/src/types/api.d.ts +28 -0
  80. package/dist/src/types/api.js +2 -0
  81. package/dist/src/types/consumers.d.ts +8 -0
  82. package/dist/src/types/consumers.js +2 -0
  83. package/dist/src/types/public-api/mappings.d.ts +21 -0
  84. package/dist/src/types/public-api/mappings.js +2 -0
  85. package/dist/src/types/sync.d.ts +20 -0
  86. package/dist/src/types/sync.js +2 -0
  87. package/dist/test/modules/accounting.test.d.ts +1 -0
  88. package/dist/test/modules/accounting.test.js +453 -0
  89. package/dist/test/modules/consumer.test.d.ts +1 -0
  90. package/dist/test/modules/consumer.test.js +89 -0
  91. package/dist/test/modules/consumers.test.d.ts +1 -0
  92. package/dist/test/modules/consumers.test.js +109 -0
  93. package/dist/test/modules/ecommerce.test.d.ts +1 -0
  94. package/dist/test/modules/ecommerce.test.js +193 -0
  95. package/dist/test/modules/flow.test.d.ts +1 -0
  96. package/dist/test/modules/flow.test.js +69 -0
  97. package/dist/test/modules/integrations.test.d.ts +1 -0
  98. package/dist/test/modules/integrations.test.js +54 -0
  99. package/dist/test/modules/invoicing.test.d.ts +1 -0
  100. package/dist/test/modules/invoicing.test.js +108 -0
  101. package/dist/test/modules/pos.test.d.ts +1 -0
  102. package/dist/test/modules/pos.test.js +164 -0
  103. package/dist/test/modules/sync.test.d.ts +1 -0
  104. package/dist/test/modules/sync.test.js +81 -0
  105. package/dist/test/modules/syncs.test.d.ts +1 -0
  106. package/dist/test/modules/syncs.test.js +53 -0
  107. package/dist/test/modules/webhooks.test.d.ts +1 -0
  108. package/dist/test/modules/webhooks.test.js +120 -0
  109. package/jest.config.ts +195 -0
  110. package/package.json +47 -0
  111. package/src/helpers/openapi.ts +22 -0
  112. package/src/helpers/settings.ts +3 -0
  113. package/src/index.ts +1 -0
  114. package/src/modules/accounting.ts +357 -0
  115. package/src/modules/api.ts +35 -0
  116. package/src/modules/consumer.ts +177 -0
  117. package/src/modules/consumers.ts +82 -0
  118. package/src/modules/custom.ts +36 -0
  119. package/src/modules/datastores.ts +19 -0
  120. package/src/modules/ecommerce.ts +82 -0
  121. package/src/modules/flow.ts +168 -0
  122. package/src/modules/integrations.ts +22 -0
  123. package/src/modules/internalApi.ts +162 -0
  124. package/src/modules/invoicing.ts +106 -0
  125. package/src/modules/pos.ts +112 -0
  126. package/src/modules/sync.ts +77 -0
  127. package/src/modules/syncs.ts +28 -0
  128. package/src/modules/webhooks.ts +86 -0
  129. package/src/types/api.ts +35 -0
  130. package/src/types/consumers.ts +9 -0
  131. package/src/types/public-api/mappings.ts +21 -0
  132. package/src/types/public-api/schema.d.ts +9436 -0
  133. package/src/types/sync.ts +23 -0
  134. package/test/data/accounting_invoice.pdf +0 -0
  135. package/test/modules/accounting.test.ts +483 -0
  136. package/test/modules/consumer.test.ts +68 -0
  137. package/test/modules/consumers.test.ts +83 -0
  138. package/test/modules/ecommerce.test.ts +177 -0
  139. package/test/modules/integrations.test.ts +22 -0
  140. package/test/modules/invoicing.test.ts +88 -0
  141. package/test/modules/pos.test.ts +145 -0
  142. package/test/modules/sync.test.ts +60 -0
  143. package/test/modules/syncs.test.ts +23 -0
  144. package/test/modules/webhooks.test.ts +92 -0
  145. package/test/set_envs.sh +14 -0
  146. package/tsconfig.json +107 -0
@@ -0,0 +1,453 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const globals_1 = require("@jest/globals");
39
+ const chift = __importStar(require("../../src/index"));
40
+ const dotenv = __importStar(require("dotenv"));
41
+ const fs_1 = __importDefault(require("fs"));
42
+ dotenv.config();
43
+ const client = new chift.API({
44
+ baseUrl: process.env.CHIFT_BASE_URL,
45
+ clientId: process.env.CHIFT_CLIENT_ID,
46
+ clientSecret: process.env.CHIFT_CLIENT_SECRET,
47
+ accountId: process.env.CHIFT_ACCOUNT_ID,
48
+ });
49
+ const consumerId = process.env.CHIFT_ODOO_CONSUMER_ID;
50
+ let consumer;
51
+ (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
52
+ consumer = yield client.Consumers.getConsumerById(consumerId);
53
+ }));
54
+ let analyticPlans;
55
+ (0, globals_1.test)('getAnalyticPlans', () => __awaiter(void 0, void 0, void 0, function* () {
56
+ analyticPlans = yield consumer.accounting.getAnalyticPlans();
57
+ (0, globals_1.expect)(analyticPlans).toBeInstanceOf(Array);
58
+ (0, globals_1.expect)(analyticPlans.length).toBeGreaterThan(0);
59
+ (0, globals_1.expect)(analyticPlans[0]).toHaveProperty('id', globals_1.expect.any(String));
60
+ (0, globals_1.expect)(analyticPlans[0]).toHaveProperty('name', globals_1.expect.any(String));
61
+ (0, globals_1.expect)(analyticPlans[0]).toHaveProperty('active', globals_1.expect.any(Boolean));
62
+ }));
63
+ let journals;
64
+ (0, globals_1.test)('getJournals', () => __awaiter(void 0, void 0, void 0, function* () {
65
+ journals = yield consumer.accounting.getJournals();
66
+ (0, globals_1.expect)(journals).toBeInstanceOf(Array);
67
+ (0, globals_1.expect)(journals.length).toBeGreaterThan(0);
68
+ (0, globals_1.expect)(journals[0]).toHaveProperty('id', globals_1.expect.any(String));
69
+ (0, globals_1.expect)(journals[0]).toHaveProperty('name', globals_1.expect.any(String));
70
+ (0, globals_1.expect)(journals[0]).toHaveProperty('journal_type', globals_1.expect.any(String));
71
+ }));
72
+ (0, globals_1.test)('createClient', () => __awaiter(void 0, void 0, void 0, function* () {
73
+ const body = {
74
+ external_reference: 'sdk test',
75
+ name: 'John Doe',
76
+ currency: 'EUR',
77
+ active: false,
78
+ addresses: [
79
+ {
80
+ address_type: 'main',
81
+ street: 'Main Street',
82
+ city: 'Brussels',
83
+ postal_code: '1000',
84
+ country: 'BE',
85
+ },
86
+ ],
87
+ };
88
+ const client = yield consumer.accounting.createClient(body);
89
+ (0, globals_1.expect)(client).toBeTruthy();
90
+ (0, globals_1.expect)(client).toHaveProperty('name', 'John Doe');
91
+ }));
92
+ let clients;
93
+ (0, globals_1.test)('getClients', () => __awaiter(void 0, void 0, void 0, function* () {
94
+ clients = yield consumer.accounting.getClients();
95
+ (0, globals_1.expect)(clients).toBeInstanceOf(Array);
96
+ (0, globals_1.expect)(clients.length).toBeGreaterThan(0);
97
+ (0, globals_1.expect)(clients[0]).toHaveProperty('id', globals_1.expect.any(String));
98
+ }));
99
+ (0, globals_1.test)('getClient', () => __awaiter(void 0, void 0, void 0, function* () {
100
+ const client = yield consumer.accounting.getClient(clients[0].id);
101
+ (0, globals_1.expect)(client).toBeTruthy();
102
+ (0, globals_1.expect)(client).toHaveProperty('external_reference');
103
+ (0, globals_1.expect)(client).toHaveProperty('first_name');
104
+ (0, globals_1.expect)(client).toHaveProperty('last_name');
105
+ (0, globals_1.expect)(client).toHaveProperty('name');
106
+ (0, globals_1.expect)(client).toHaveProperty('function');
107
+ (0, globals_1.expect)(client).toHaveProperty('is_company');
108
+ (0, globals_1.expect)(client).toHaveProperty('company_id');
109
+ (0, globals_1.expect)(client).toHaveProperty('phone');
110
+ (0, globals_1.expect)(client).toHaveProperty('mobile');
111
+ (0, globals_1.expect)(client).toHaveProperty('email');
112
+ (0, globals_1.expect)(client).toHaveProperty('language');
113
+ (0, globals_1.expect)(client).toHaveProperty('internal_notes');
114
+ (0, globals_1.expect)(client).toHaveProperty('website');
115
+ (0, globals_1.expect)(client).toHaveProperty('vat');
116
+ (0, globals_1.expect)(client).toHaveProperty('iban');
117
+ (0, globals_1.expect)(client).toHaveProperty('bank_account');
118
+ (0, globals_1.expect)(client).toHaveProperty('currency');
119
+ (0, globals_1.expect)(client).toHaveProperty('active', globals_1.expect.any(Boolean));
120
+ (0, globals_1.expect)(client).toHaveProperty('addresses', globals_1.expect.any(Array));
121
+ }));
122
+ (0, globals_1.test)('updateClient', () => __awaiter(void 0, void 0, void 0, function* () {
123
+ const client = clients.find((client) => client.external_reference === 'sdk test');
124
+ const updatedClient = yield consumer.accounting.updateClient(client === null || client === void 0 ? void 0 : client.id, {
125
+ name: 'John Updated Doe',
126
+ });
127
+ (0, globals_1.expect)(updatedClient).toBeTruthy();
128
+ (0, globals_1.expect)(updatedClient).toHaveProperty('name', 'John Updated Doe');
129
+ }));
130
+ (0, globals_1.test)('createSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
131
+ const body = {
132
+ external_reference: 'sdk test',
133
+ name: 'Jane Doe',
134
+ currency: 'EUR',
135
+ active: false,
136
+ addresses: [
137
+ {
138
+ address_type: 'main',
139
+ street: 'Main Street',
140
+ city: 'Brussels',
141
+ postal_code: '1000',
142
+ country: 'BE',
143
+ },
144
+ ],
145
+ };
146
+ const supplier = yield consumer.accounting.createSupplier(body);
147
+ (0, globals_1.expect)(supplier).toBeTruthy();
148
+ (0, globals_1.expect)(supplier).toHaveProperty('name', 'Jane Doe');
149
+ }));
150
+ let suppliers;
151
+ (0, globals_1.test)('getSuppliers', () => __awaiter(void 0, void 0, void 0, function* () {
152
+ suppliers = yield consumer.accounting.getSuppliers();
153
+ (0, globals_1.expect)(suppliers).toBeInstanceOf(Array);
154
+ (0, globals_1.expect)(suppliers.length).toBeGreaterThan(0);
155
+ }));
156
+ (0, globals_1.test)('getSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
157
+ const supplier = yield consumer.accounting.getSupplier(suppliers[0].id);
158
+ (0, globals_1.expect)(supplier).toBeTruthy();
159
+ (0, globals_1.expect)(supplier).toHaveProperty('external_reference');
160
+ (0, globals_1.expect)(supplier).toHaveProperty('first_name');
161
+ (0, globals_1.expect)(supplier).toHaveProperty('last_name');
162
+ (0, globals_1.expect)(supplier).toHaveProperty('name');
163
+ (0, globals_1.expect)(supplier).toHaveProperty('function');
164
+ (0, globals_1.expect)(supplier).toHaveProperty('is_company');
165
+ (0, globals_1.expect)(supplier).toHaveProperty('company_id');
166
+ (0, globals_1.expect)(supplier).toHaveProperty('phone');
167
+ (0, globals_1.expect)(supplier).toHaveProperty('mobile');
168
+ (0, globals_1.expect)(supplier).toHaveProperty('email');
169
+ (0, globals_1.expect)(supplier).toHaveProperty('language');
170
+ (0, globals_1.expect)(supplier).toHaveProperty('internal_notes');
171
+ (0, globals_1.expect)(supplier).toHaveProperty('website');
172
+ (0, globals_1.expect)(supplier).toHaveProperty('vat');
173
+ (0, globals_1.expect)(supplier).toHaveProperty('iban');
174
+ (0, globals_1.expect)(supplier).toHaveProperty('bank_account');
175
+ (0, globals_1.expect)(supplier).toHaveProperty('currency');
176
+ (0, globals_1.expect)(supplier).toHaveProperty('active', globals_1.expect.any(Boolean));
177
+ (0, globals_1.expect)(supplier).toHaveProperty('addresses', globals_1.expect.any(Array));
178
+ }));
179
+ (0, globals_1.test)('updateSupplier', () => __awaiter(void 0, void 0, void 0, function* () {
180
+ const supplier = suppliers.find((supplier) => supplier.external_reference === 'sdk test');
181
+ const updatedSupplier = yield consumer.accounting.updateSupplier(supplier === null || supplier === void 0 ? void 0 : supplier.id, {
182
+ name: 'Jane Updated Doe',
183
+ });
184
+ (0, globals_1.expect)(updatedSupplier).toBeTruthy();
185
+ (0, globals_1.expect)(updatedSupplier).toHaveProperty('name', 'Jane Updated Doe');
186
+ }));
187
+ (0, globals_1.test)('createInvoice', () => __awaiter(void 0, void 0, void 0, function* () {
188
+ var _a;
189
+ const body = {
190
+ invoice_type: 'customer_invoice',
191
+ invoice_date: '2022-12-01',
192
+ due_date: '2022-12-31',
193
+ currency: 'EUR',
194
+ untaxed_amount: 100,
195
+ tax_amount: 21,
196
+ total: 121,
197
+ partner_id: (_a = clients[0]) === null || _a === void 0 ? void 0 : _a.id,
198
+ journal_id: journals[0].id,
199
+ lines: [
200
+ {
201
+ description: 'Test',
202
+ unit_price: 100,
203
+ quantity: 1,
204
+ untaxed_amount: 100,
205
+ tax_rate: 21,
206
+ tax_amount: 21,
207
+ total: 121,
208
+ account_number: '700000',
209
+ tax_code: '1',
210
+ },
211
+ ],
212
+ };
213
+ const invoice = yield consumer.accounting.createInvoice(body);
214
+ (0, globals_1.expect)(invoice).toBeTruthy();
215
+ (0, globals_1.expect)(invoice).toHaveProperty('total', 121);
216
+ }));
217
+ let invoices;
218
+ (0, globals_1.test)('getInvoicesByType', () => __awaiter(void 0, void 0, void 0, function* () {
219
+ invoices = yield consumer.accounting.getInvoicesByType('customer_invoice', {
220
+ date_from: '2022-12-01',
221
+ date_to: '2022-12-31',
222
+ });
223
+ (0, globals_1.expect)(invoices).toBeInstanceOf(Array);
224
+ (0, globals_1.expect)(invoices.length).toBeGreaterThan(0);
225
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('id', globals_1.expect.any(String));
226
+ }));
227
+ (0, globals_1.test)('getInvoicesByTypeWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
228
+ const invoicesWithMultiplePlans = yield consumer.accounting.getInvoicesByTypeWithMultiplePlans('customer_invoice', {
229
+ date_from: '2022-12-01',
230
+ date_to: '2022-12-31',
231
+ });
232
+ (0, globals_1.expect)(invoicesWithMultiplePlans).toBeInstanceOf(Array);
233
+ (0, globals_1.expect)(invoicesWithMultiplePlans.length).toBeGreaterThan(0);
234
+ (0, globals_1.expect)(invoicesWithMultiplePlans[0]).toHaveProperty('id', globals_1.expect.any(String));
235
+ }));
236
+ (0, globals_1.test)('getInvoice', () => __awaiter(void 0, void 0, void 0, function* () {
237
+ const invoice = yield consumer.accounting.getInvoice(invoices[0].id, {
238
+ include_payments: true,
239
+ });
240
+ (0, globals_1.expect)(invoice).toBeTruthy();
241
+ (0, globals_1.expect)(invoice).toHaveProperty('id', invoices[0].id);
242
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('invoice_type', globals_1.expect.any(String));
243
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('invoice_number');
244
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('partner_id', globals_1.expect.any(String));
245
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('invoice_date', globals_1.expect.any(String));
246
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('due_date', globals_1.expect.any(String));
247
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('currency', globals_1.expect.any(String));
248
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('untaxed_amount', globals_1.expect.any(Number));
249
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('tax_amount', globals_1.expect.any(Number));
250
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('total', globals_1.expect.any(Number));
251
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('reference');
252
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('payment_communication');
253
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('customer_memo');
254
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('id');
255
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('journal_id', globals_1.expect.any(String));
256
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('payments');
257
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('status');
258
+ (0, globals_1.expect)(invoices[0]).toHaveProperty('lines', globals_1.expect.any(Array));
259
+ }));
260
+ (0, globals_1.test)('createInvoiceWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
261
+ var _b;
262
+ const body = {
263
+ invoice_type: 'customer_invoice',
264
+ invoice_date: '2022-12-01',
265
+ due_date: '2022-12-31',
266
+ currency: 'EUR',
267
+ untaxed_amount: 100,
268
+ tax_amount: 21,
269
+ total: 121,
270
+ partner_id: (_b = clients[0]) === null || _b === void 0 ? void 0 : _b.id,
271
+ journal_id: journals[0].id,
272
+ lines: [
273
+ {
274
+ description: 'Test',
275
+ unit_price: 100,
276
+ quantity: 1,
277
+ untaxed_amount: 100,
278
+ tax_rate: 21,
279
+ tax_amount: 21,
280
+ total: 121,
281
+ account_number: '700000',
282
+ tax_code: '1',
283
+ },
284
+ ],
285
+ };
286
+ const invoice = yield consumer.accounting.createInvoiceWithMultiplePlans(body);
287
+ (0, globals_1.expect)(invoice).toBeTruthy();
288
+ }));
289
+ (0, globals_1.test)('getInvoiceWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
290
+ const invoice = yield consumer.accounting.getInvoiceWithMultiplePlans(invoices[0].id, {
291
+ include_payments: true,
292
+ });
293
+ (0, globals_1.expect)(invoice).toBeTruthy();
294
+ }));
295
+ (0, globals_1.test)('createAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
296
+ const body = {
297
+ active: false,
298
+ code: '4000',
299
+ name: 'sdk test',
300
+ currency: 'EUR',
301
+ };
302
+ const analyticAccount = yield consumer.accounting.createAnalyticAccount(body);
303
+ (0, globals_1.expect)(analyticAccount).toBeTruthy();
304
+ (0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'sdk test');
305
+ }));
306
+ let analyticAccounts;
307
+ (0, globals_1.test)('getAnalyticAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
308
+ analyticAccounts = yield consumer.accounting.getAnalyticAccounts();
309
+ (0, globals_1.expect)(analyticAccounts).toBeInstanceOf(Array);
310
+ (0, globals_1.expect)(analyticAccounts.length).toBeGreaterThan(0);
311
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('active', globals_1.expect.any(Boolean));
312
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('code', globals_1.expect.any(String));
313
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('name', globals_1.expect.any(String));
314
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('currency', globals_1.expect.any(String));
315
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('id', globals_1.expect.any(String));
316
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('balance', globals_1.expect.any(Number));
317
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('debit', globals_1.expect.any(Number));
318
+ (0, globals_1.expect)(analyticAccounts[0]).toHaveProperty('credit', globals_1.expect.any(Number));
319
+ }));
320
+ (0, globals_1.test)('createAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
321
+ const analyticAccount = yield consumer.accounting.createAnalyticAccountWithMultiplePlans(analyticPlans[0].id, {
322
+ code: '4000',
323
+ name: 'sdk test',
324
+ currency: 'EUR',
325
+ });
326
+ (0, globals_1.expect)(analyticAccount).toBeTruthy();
327
+ }));
328
+ (0, globals_1.test)('getAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
329
+ const analyticAccount = yield consumer.accounting.getAnalyticAccount(analyticAccounts[0].id);
330
+ (0, globals_1.expect)(analyticAccount).toBeTruthy();
331
+ }));
332
+ (0, globals_1.test)('updateAnalyticAccount', () => __awaiter(void 0, void 0, void 0, function* () {
333
+ const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'sdk test');
334
+ const analyticAccount = yield consumer.accounting.updateAnalyticAccount(testAnalyticAccount === null || testAnalyticAccount === void 0 ? void 0 : testAnalyticAccount.id, { name: 'test sdk update' });
335
+ (0, globals_1.expect)(analyticAccount).toBeTruthy();
336
+ (0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'test sdk update');
337
+ }));
338
+ (0, globals_1.test)('getAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
339
+ const analyticAccount = yield consumer.accounting.getAnalyticAccountWithMultiplePlans(analyticAccounts[0].id, analyticPlans[0].id);
340
+ (0, globals_1.expect)(analyticAccount).toBeTruthy();
341
+ }));
342
+ (0, globals_1.test)('updateAnalyticAccountWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
343
+ const testAnalyticAccount = analyticAccounts.find((account) => account.name === 'test sdk update');
344
+ const analyticAccount = yield consumer.accounting.updateAnalyticAccountWithMultiplePlans(testAnalyticAccount === null || testAnalyticAccount === void 0 ? void 0 : testAnalyticAccount.id, '1', { name: 'test sdk update 2' });
345
+ (0, globals_1.expect)(analyticAccount).toBeTruthy();
346
+ (0, globals_1.expect)(analyticAccount).toHaveProperty('name', 'test sdk update 2');
347
+ }));
348
+ (0, globals_1.test)('getAnalyticAccountsWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
349
+ const analyticAccountsWithMultiplePlans = yield consumer.accounting.getAnalyticAccountsWithMultiplePlans();
350
+ (0, globals_1.expect)(analyticAccountsWithMultiplePlans).toBeInstanceOf(Array);
351
+ }));
352
+ (0, globals_1.test)('getAnalyticLinesOfAccount', () => __awaiter(void 0, void 0, void 0, function* () {
353
+ const analyticLinesOfAccount = yield consumer.accounting.getAnalyticLinesOfAccount(analyticAccounts[0].id);
354
+ (0, globals_1.expect)(analyticLinesOfAccount).toBeInstanceOf(Array);
355
+ if (analyticLinesOfAccount.length > 0) {
356
+ (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('account_id', analyticAccounts[0].id);
357
+ (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('description', globals_1.expect.any(String));
358
+ (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('amount', globals_1.expect.any(Number));
359
+ (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('date', globals_1.expect.any(String));
360
+ (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('id', globals_1.expect.any(String));
361
+ }
362
+ }));
363
+ (0, globals_1.test)('getJournalEntries', () => __awaiter(void 0, void 0, void 0, function* () {
364
+ const journalEntries = yield consumer.accounting.getJournalEntries({
365
+ unposted_allowed: true,
366
+ date_from: '2022-01-01',
367
+ date_to: '2022-01-31',
368
+ journal_id: journals[0].id,
369
+ });
370
+ (0, globals_1.expect)(journalEntries).toBeInstanceOf(Array);
371
+ }));
372
+ (0, globals_1.test)('getJournalEntriesWithMultiplePlans', () => __awaiter(void 0, void 0, void 0, function* () {
373
+ const journalEntries = yield consumer.accounting.getJournalEntriesWithMultiplePlans({
374
+ unposted_allowed: true,
375
+ date_from: '2022-01-01',
376
+ date_to: '2022-01-31',
377
+ journal_id: journals[0].id,
378
+ });
379
+ (0, globals_1.expect)(journalEntries).toBeInstanceOf(Array);
380
+ }));
381
+ (0, globals_1.test)('getPaymentsByInvoiceId', () => __awaiter(void 0, void 0, void 0, function* () {
382
+ const payments = yield consumer.accounting.getPaymentsByInvoiceId(invoices[0].id);
383
+ (0, globals_1.expect)(payments).toBeInstanceOf(Array);
384
+ }));
385
+ (0, globals_1.test)('getVatCodes', () => __awaiter(void 0, void 0, void 0, function* () {
386
+ const vatCodes = yield consumer.accounting.getVatCodes();
387
+ (0, globals_1.expect)(vatCodes).toBeInstanceOf(Array);
388
+ (0, globals_1.expect)(vatCodes.length).toBeGreaterThan(0);
389
+ (0, globals_1.expect)(vatCodes[0]).toHaveProperty('id', globals_1.expect.any(String));
390
+ (0, globals_1.expect)(vatCodes[0]).toHaveProperty('code');
391
+ (0, globals_1.expect)(vatCodes[0]).toHaveProperty('label', globals_1.expect.any(String));
392
+ (0, globals_1.expect)(vatCodes[0]).toHaveProperty('scope', globals_1.expect.any(String));
393
+ (0, globals_1.expect)(vatCodes[0]).toHaveProperty('rate', globals_1.expect.any(Number));
394
+ (0, globals_1.expect)(vatCodes[0]).toHaveProperty('type', globals_1.expect.any(String));
395
+ }));
396
+ let miscOperations;
397
+ (0, globals_1.test)('getMiscOperations', () => __awaiter(void 0, void 0, void 0, function* () {
398
+ miscOperations = yield consumer.accounting.getMiscOperations();
399
+ (0, globals_1.expect)(miscOperations).toBeInstanceOf(Array);
400
+ (0, globals_1.expect)(miscOperations.length).toBeGreaterThan(0);
401
+ (0, globals_1.expect)(miscOperations[0]).toHaveProperty('id', globals_1.expect.any(String));
402
+ }));
403
+ (0, globals_1.test)('createMiscOperation', () => __awaiter(void 0, void 0, void 0, function* () {
404
+ var _c;
405
+ const data = {
406
+ operation_date: '2023-04-29',
407
+ currency: 'EUR',
408
+ lines: [
409
+ {
410
+ line_number: 1,
411
+ description: 'test line',
412
+ amount: 0,
413
+ type: 'general_account',
414
+ account_number: '400000',
415
+ },
416
+ ],
417
+ journal_id: (_c = journals === null || journals === void 0 ? void 0 : journals.find((journal) => journal.journal_type === 'miscellaneous_operation')) === null || _c === void 0 ? void 0 : _c.id,
418
+ status: 'draft',
419
+ };
420
+ const miscOperation = yield consumer.accounting.createMiscOperation(data);
421
+ (0, globals_1.expect)(miscOperation).toBeTruthy();
422
+ }));
423
+ (0, globals_1.test)('getMiscOperation', () => __awaiter(void 0, void 0, void 0, function* () {
424
+ const miscOperation = yield consumer.accounting.getMiscOperation(miscOperations[0].id);
425
+ (0, globals_1.expect)(miscOperation).toBeTruthy();
426
+ (0, globals_1.expect)(miscOperation).toHaveProperty('operation_number');
427
+ (0, globals_1.expect)(miscOperation).toHaveProperty('operation_date', globals_1.expect.any(String));
428
+ (0, globals_1.expect)(miscOperation).toHaveProperty('currency', globals_1.expect.any(String));
429
+ (0, globals_1.expect)(miscOperation).toHaveProperty('lines', globals_1.expect.any(Array));
430
+ (0, globals_1.expect)(miscOperation).toHaveProperty('journal_id', globals_1.expect.any(String));
431
+ (0, globals_1.expect)(miscOperation).toHaveProperty('status', globals_1.expect.any(String));
432
+ (0, globals_1.expect)(miscOperation).toHaveProperty('id', globals_1.expect.any(String));
433
+ }));
434
+ (0, globals_1.test)('attachPDF', () => __awaiter(void 0, void 0, void 0, function* () {
435
+ const pdfData = fs_1.default.readFileSync('test/data/accounting_invoice.pdf');
436
+ yield consumer.accounting.attachPDF(invoices[0].id, { base64_string: pdfData.toString('base64') }, { overwrite_existing: true });
437
+ }));
438
+ (0, globals_1.test)('getChartOfAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
439
+ const chartOfAccounts = yield consumer.accounting.getChartOfAccounts({
440
+ classes: '6,7',
441
+ });
442
+ (0, globals_1.expect)(chartOfAccounts).toBeTruthy();
443
+ }));
444
+ (0, globals_1.test)('getBalanceOfAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
445
+ const balanceOfAccounts = yield consumer.accounting.getBalanceOfAccounts({
446
+ accounts: ['7'],
447
+ start: '2022-01-01',
448
+ end: '2022-12-31',
449
+ });
450
+ (0, globals_1.expect)(balanceOfAccounts).toBeTruthy();
451
+ (0, globals_1.expect)(balanceOfAccounts).toHaveProperty('items');
452
+ (0, globals_1.expect)(balanceOfAccounts.items).toBeInstanceOf(Array);
453
+ }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ const globals_1 = require("@jest/globals");
36
+ const chift = __importStar(require("../../src/index"));
37
+ const dotenv = __importStar(require("dotenv"));
38
+ dotenv.config();
39
+ const client = new chift.API({
40
+ baseUrl: process.env.CHIFT_BASE_URL,
41
+ clientId: process.env.CHIFT_CLIENT_ID,
42
+ clientSecret: process.env.CHIFT_CLIENT_SECRET,
43
+ accountId: process.env.CHIFT_ACCOUNT_ID,
44
+ });
45
+ const consumerName = 'test consumer 2';
46
+ const email = 'support@chift.eu';
47
+ const redirect_url = 'https://chift.eu';
48
+ let syncConsumer;
49
+ let consumer;
50
+ let connection;
51
+ (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
52
+ consumer = yield client.Consumers.createConsumer({
53
+ email,
54
+ redirect_url,
55
+ name: consumerName,
56
+ });
57
+ syncConsumer = yield client.Consumers.getConsumerById(process.env.CHIFT_SYNC_CONSUMER_ID);
58
+ }));
59
+ (0, globals_1.test)('createConnection', () => __awaiter(void 0, void 0, void 0, function* () {
60
+ const body = { integrationid: 1000, name: 'odoo test sdk' };
61
+ const result = yield consumer.createConnection(body);
62
+ (0, globals_1.expect)(result).toHaveProperty('url', globals_1.expect.any(String));
63
+ }));
64
+ let connections;
65
+ (0, globals_1.test)('getConnections', () => __awaiter(void 0, void 0, void 0, function* () {
66
+ connections = yield syncConsumer.getConnections();
67
+ (0, globals_1.expect)(connections).toBeInstanceOf(Array);
68
+ }));
69
+ globals_1.test.skip('updateConnection', () => __awaiter(void 0, void 0, void 0, function* () {
70
+ var _a;
71
+ const updatedConnection = yield syncConsumer.updateConnection((_a = connections[0]) === null || _a === void 0 ? void 0 : _a.connectionid, {
72
+ name: 'updated connection name',
73
+ });
74
+ (0, globals_1.expect)(updatedConnection).toHaveProperty('name', 'updated connection name');
75
+ }));
76
+ globals_1.test.skip('deleteConnection', () => __awaiter(void 0, void 0, void 0, function* () {
77
+ yield consumer.deleteConnection(connection.connectionId);
78
+ }));
79
+ (0, globals_1.test)('getSyncUrl', () => __awaiter(void 0, void 0, void 0, function* () {
80
+ const result = yield syncConsumer.getSyncUrl({
81
+ syncid: process.env.CHIFT_TEST_SYNC_ID,
82
+ integrationids: [],
83
+ });
84
+ (0, globals_1.expect)(result).toHaveProperty('url', globals_1.expect.any(String));
85
+ }));
86
+ (0, globals_1.test)('getSyncData', () => __awaiter(void 0, void 0, void 0, function* () {
87
+ const syncData = yield syncConsumer.getSyncData(process.env.CHIFT_TEST_SYNC_ID);
88
+ (0, globals_1.expect)(syncData).toBeTruthy();
89
+ }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const globals_1 = require("@jest/globals");
39
+ const chift = __importStar(require("../../src/index"));
40
+ const axios_1 = __importDefault(require("axios"));
41
+ const dotenv = __importStar(require("dotenv"));
42
+ dotenv.config();
43
+ const client = new chift.API({
44
+ baseUrl: process.env.CHIFT_BASE_URL,
45
+ clientId: process.env.CHIFT_CLIENT_ID,
46
+ clientSecret: process.env.CHIFT_CLIENT_SECRET,
47
+ accountId: process.env.CHIFT_ACCOUNT_ID,
48
+ });
49
+ const consumerName = 'test consumer';
50
+ const email = 'support@chift.eu';
51
+ const redirect_url = 'https://chift.eu';
52
+ let consumer;
53
+ (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
54
+ consumer = yield client.Consumers.createConsumer({
55
+ email,
56
+ redirect_url,
57
+ name: consumerName,
58
+ });
59
+ }));
60
+ (0, globals_1.test)('createConsumer', () => __awaiter(void 0, void 0, void 0, function* () {
61
+ (0, globals_1.expect)(consumer).toHaveProperty('consumerId');
62
+ (0, globals_1.expect)(consumer).toHaveProperty('getConnections');
63
+ (0, globals_1.expect)(consumer).toHaveProperty('createConnection');
64
+ (0, globals_1.expect)(consumer).toHaveProperty('updateConnection');
65
+ (0, globals_1.expect)(consumer).toHaveProperty('deleteConnection');
66
+ (0, globals_1.expect)(consumer).toHaveProperty('getSyncUrl');
67
+ (0, globals_1.expect)(consumer).toHaveProperty('name', consumerName);
68
+ (0, globals_1.expect)(consumer).toHaveProperty('redirect_url', redirect_url);
69
+ (0, globals_1.expect)(consumer).toHaveProperty('email', email);
70
+ (0, globals_1.expect)(consumer).toHaveProperty('pos');
71
+ (0, globals_1.expect)(consumer).toHaveProperty('accounting');
72
+ (0, globals_1.expect)(consumer).toHaveProperty('invoicing');
73
+ (0, globals_1.expect)(consumer).toHaveProperty('ecommerce');
74
+ (0, globals_1.expect)(consumer).toHaveProperty('custom');
75
+ }));
76
+ (0, globals_1.test)('getConsumers', () => __awaiter(void 0, void 0, void 0, function* () {
77
+ const consumers = yield client.Consumers.getConsumers();
78
+ (0, globals_1.expect)(consumers).toBeInstanceOf(Array);
79
+ }));
80
+ (0, globals_1.test)('getConsumersByName', () => __awaiter(void 0, void 0, void 0, function* () {
81
+ const consumersWithName = yield client.Consumers.getConsumersByName(consumerName);
82
+ (0, globals_1.expect)(consumersWithName).toBeInstanceOf(Array);
83
+ (0, globals_1.expect)(consumersWithName[0]).toHaveProperty('name', consumerName);
84
+ }));
85
+ (0, globals_1.test)('getConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
86
+ const consumerWithId = yield client.Consumers.getConsumerById(consumer.consumerId);
87
+ (0, globals_1.expect)(consumerWithId).toHaveProperty('consumerId', consumer.consumerId);
88
+ }));
89
+ (0, globals_1.test)('updateConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
90
+ const updatedName = 'updated test consumer';
91
+ const updatedConsumer = yield client.Consumers.updateConsumerById(consumer.consumerId, {
92
+ name: updatedName,
93
+ });
94
+ (0, globals_1.expect)(updatedConsumer).toHaveProperty('name', updatedName);
95
+ }));
96
+ (0, globals_1.test)('deleteConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
97
+ globals_1.expect.assertions(1);
98
+ try {
99
+ yield client.Consumers.deleteConsumerById(consumer.consumerId);
100
+ yield client.Consumers.getConsumerById(consumer.consumerId);
101
+ }
102
+ catch (e) {
103
+ if (axios_1.default.isAxiosError(e)) {
104
+ (0, globals_1.expect)(e.message).toMatch('Request failed with status code 404');
105
+ return;
106
+ }
107
+ throw e;
108
+ }
109
+ }));
@@ -0,0 +1 @@
1
+ export {};