n8n-nodes-qonto-api 1.0.0

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 (76) hide show
  1. package/README.md +75 -0
  2. package/dist/credentials/QontoApi.credentials.d.ts +10 -0
  3. package/dist/credentials/QontoApi.credentials.js +78 -0
  4. package/dist/credentials/QontoApi.credentials.js.map +1 -0
  5. package/dist/credentials/QontoOAuth2Api.credentials.d.ts +9 -0
  6. package/dist/credentials/QontoOAuth2Api.credentials.js +87 -0
  7. package/dist/credentials/QontoOAuth2Api.credentials.js.map +1 -0
  8. package/dist/icons/qonto.svg +52 -0
  9. package/dist/nodes/Qonto/Qonto.node.d.ts +5 -0
  10. package/dist/nodes/Qonto/Qonto.node.js +806 -0
  11. package/dist/nodes/Qonto/Qonto.node.js.map +1 -0
  12. package/dist/nodes/Qonto/Qonto.node.json +20 -0
  13. package/dist/nodes/Qonto/Qonto.svg +52 -0
  14. package/dist/nodes/Qonto/descriptions/AttachmentDescriptions.d.ts +2 -0
  15. package/dist/nodes/Qonto/descriptions/AttachmentDescriptions.js +69 -0
  16. package/dist/nodes/Qonto/descriptions/AttachmentDescriptions.js.map +1 -0
  17. package/dist/nodes/Qonto/descriptions/AttachmentsInATransactionDescriptions.d.ts +2 -0
  18. package/dist/nodes/Qonto/descriptions/AttachmentsInATransactionDescriptions.js +136 -0
  19. package/dist/nodes/Qonto/descriptions/AttachmentsInATransactionDescriptions.js.map +1 -0
  20. package/dist/nodes/Qonto/descriptions/BeneficiariesDescriptions.d.ts +2 -0
  21. package/dist/nodes/Qonto/descriptions/BeneficiariesDescriptions.js +174 -0
  22. package/dist/nodes/Qonto/descriptions/BeneficiariesDescriptions.js.map +1 -0
  23. package/dist/nodes/Qonto/descriptions/CardsDescriptions.d.ts +2 -0
  24. package/dist/nodes/Qonto/descriptions/CardsDescriptions.js +171 -0
  25. package/dist/nodes/Qonto/descriptions/CardsDescriptions.js.map +1 -0
  26. package/dist/nodes/Qonto/descriptions/ClientsDescriptions.d.ts +2 -0
  27. package/dist/nodes/Qonto/descriptions/ClientsDescriptions.js +218 -0
  28. package/dist/nodes/Qonto/descriptions/ClientsDescriptions.js.map +1 -0
  29. package/dist/nodes/Qonto/descriptions/ClientsInvoicesDescriptions.d.ts +2 -0
  30. package/dist/nodes/Qonto/descriptions/ClientsInvoicesDescriptions.js +205 -0
  31. package/dist/nodes/Qonto/descriptions/ClientsInvoicesDescriptions.js.map +1 -0
  32. package/dist/nodes/Qonto/descriptions/CreditNotesDescriptions.d.ts +2 -0
  33. package/dist/nodes/Qonto/descriptions/CreditNotesDescriptions.js +142 -0
  34. package/dist/nodes/Qonto/descriptions/CreditNotesDescriptions.js.map +1 -0
  35. package/dist/nodes/Qonto/descriptions/ExternalTransfersDescriptions.d.ts +2 -0
  36. package/dist/nodes/Qonto/descriptions/ExternalTransfersDescriptions.js +553 -0
  37. package/dist/nodes/Qonto/descriptions/ExternalTransfersDescriptions.js.map +1 -0
  38. package/dist/nodes/Qonto/descriptions/InsuranceContractsDescriptions.d.ts +2 -0
  39. package/dist/nodes/Qonto/descriptions/InsuranceContractsDescriptions.js +253 -0
  40. package/dist/nodes/Qonto/descriptions/InsuranceContractsDescriptions.js.map +1 -0
  41. package/dist/nodes/Qonto/descriptions/InternalTransactionsDescriptions.d.ts +2 -0
  42. package/dist/nodes/Qonto/descriptions/InternalTransactionsDescriptions.js +133 -0
  43. package/dist/nodes/Qonto/descriptions/InternalTransactionsDescriptions.js.map +1 -0
  44. package/dist/nodes/Qonto/descriptions/LabelsDescriptions.d.ts +2 -0
  45. package/dist/nodes/Qonto/descriptions/LabelsDescriptions.js +91 -0
  46. package/dist/nodes/Qonto/descriptions/LabelsDescriptions.js.map +1 -0
  47. package/dist/nodes/Qonto/descriptions/MembershipsDescriptions.d.ts +2 -0
  48. package/dist/nodes/Qonto/descriptions/MembershipsDescriptions.js +180 -0
  49. package/dist/nodes/Qonto/descriptions/MembershipsDescriptions.js.map +1 -0
  50. package/dist/nodes/Qonto/descriptions/OrganizationsDescriptions.d.ts +2 -0
  51. package/dist/nodes/Qonto/descriptions/OrganizationsDescriptions.js +45 -0
  52. package/dist/nodes/Qonto/descriptions/OrganizationsDescriptions.js.map +1 -0
  53. package/dist/nodes/Qonto/descriptions/RequestsDescriptions.d.ts +2 -0
  54. package/dist/nodes/Qonto/descriptions/RequestsDescriptions.js +278 -0
  55. package/dist/nodes/Qonto/descriptions/RequestsDescriptions.js.map +1 -0
  56. package/dist/nodes/Qonto/descriptions/StatementsDescriptions.d.ts +2 -0
  57. package/dist/nodes/Qonto/descriptions/StatementsDescriptions.js +102 -0
  58. package/dist/nodes/Qonto/descriptions/StatementsDescriptions.js.map +1 -0
  59. package/dist/nodes/Qonto/descriptions/SupplierInvoicesDescriptions.d.ts +2 -0
  60. package/dist/nodes/Qonto/descriptions/SupplierInvoicesDescriptions.js +193 -0
  61. package/dist/nodes/Qonto/descriptions/SupplierInvoicesDescriptions.js.map +1 -0
  62. package/dist/nodes/Qonto/descriptions/TeamsDescriptions.d.ts +2 -0
  63. package/dist/nodes/Qonto/descriptions/TeamsDescriptions.js +103 -0
  64. package/dist/nodes/Qonto/descriptions/TeamsDescriptions.js.map +1 -0
  65. package/dist/nodes/Qonto/descriptions/TransactionsDescriptions.d.ts +2 -0
  66. package/dist/nodes/Qonto/descriptions/TransactionsDescriptions.js +263 -0
  67. package/dist/nodes/Qonto/descriptions/TransactionsDescriptions.js.map +1 -0
  68. package/dist/nodes/Qonto/descriptions/index.d.ts +18 -0
  69. package/dist/nodes/Qonto/descriptions/index.js +35 -0
  70. package/dist/nodes/Qonto/descriptions/index.js.map +1 -0
  71. package/dist/nodes/Qonto/helpers.d.ts +3 -0
  72. package/dist/nodes/Qonto/helpers.js +75 -0
  73. package/dist/nodes/Qonto/helpers.js.map +1 -0
  74. package/dist/package.json +56 -0
  75. package/dist/tsconfig.tsbuildinfo +1 -0
  76. package/package.json +56 -0
@@ -0,0 +1,806 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Qonto = void 0;
4
+ const helpers_1 = require("./helpers");
5
+ const descriptions_1 = require("./descriptions");
6
+ function isEmpty(value) {
7
+ return value === null || value === undefined ||
8
+ (typeof value === 'object' && Object.keys(value).length === 0);
9
+ }
10
+ function uuid() {
11
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
12
+ const r = Math.random() * 16 | 0;
13
+ const v = c === 'x' ? r : (r & 0x3 | 0x8);
14
+ return v.toString(16);
15
+ });
16
+ }
17
+ class Qonto {
18
+ constructor() {
19
+ this.description = {
20
+ displayName: 'Qonto',
21
+ name: 'qonto',
22
+ icon: 'file:Qonto.svg',
23
+ group: ['output'],
24
+ version: 2,
25
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
26
+ description: 'Consume Qonto API',
27
+ defaults: {
28
+ name: 'Qonto',
29
+ },
30
+ usableAsTool: true,
31
+ inputs: ['main'],
32
+ outputs: ['main'],
33
+ credentials: [
34
+ {
35
+ name: 'qontoApi',
36
+ required: true,
37
+ displayOptions: {
38
+ show: {
39
+ authentication: ['logKey'],
40
+ },
41
+ },
42
+ },
43
+ {
44
+ name: 'qontoOAuth2Api',
45
+ required: true,
46
+ displayOptions: {
47
+ show: {
48
+ authentication: ['oAuth2'],
49
+ },
50
+ },
51
+ },
52
+ ],
53
+ properties: [
54
+ {
55
+ displayName: 'Authentication',
56
+ name: 'authentication',
57
+ type: 'options',
58
+ options: [
59
+ {
60
+ name: 'Login and Secret-Key',
61
+ value: 'logKey',
62
+ },
63
+ {
64
+ name: 'OAuth2',
65
+ value: 'oAuth2',
66
+ },
67
+ ],
68
+ default: 'oAuth2',
69
+ },
70
+ {
71
+ displayName: 'Resource',
72
+ name: 'resource',
73
+ type: 'options',
74
+ noDataExpression: true,
75
+ options: [
76
+ { name: 'Attachment', value: 'attachment' },
77
+ { name: 'Attachments in a Transaction', value: 'attachmentsInATransaction' },
78
+ { name: 'Beneficiary', value: 'beneficiaries' },
79
+ { name: 'Card', value: 'cards' },
80
+ { name: 'Client', value: 'clients' },
81
+ { name: 'Client Invoice', value: 'clientsInvoices' },
82
+ { name: 'Credit Note', value: 'creditNotes' },
83
+ { name: 'External Transfer', value: 'externalTransfers' },
84
+ { name: 'Insurance Contract', value: 'insuranceContracts' },
85
+ { name: 'Internal Transaction', value: 'internalTransactions' },
86
+ { name: 'Label', value: 'labels' },
87
+ { name: 'Membership', value: 'memberships' },
88
+ { name: 'Organization', value: 'organizations' },
89
+ { name: 'Request', value: 'requests' },
90
+ { name: 'Statement', value: 'statements' },
91
+ { name: 'Supplier Invoice', value: 'supplierInvoices' },
92
+ { name: 'Team', value: 'teams' },
93
+ { name: 'Transaction', value: 'transactions' },
94
+ ],
95
+ default: 'organizations',
96
+ required: true,
97
+ },
98
+ ...descriptions_1.externalTransfersOperations,
99
+ ...descriptions_1.beneficiariesOperations,
100
+ ...descriptions_1.attachmentOperations,
101
+ ...descriptions_1.labelsOperations,
102
+ ...descriptions_1.membershipsOperations,
103
+ ...descriptions_1.organizationsOperations,
104
+ ...descriptions_1.attachmentsInATransactionOperations,
105
+ ...descriptions_1.transactionsOperations,
106
+ ...descriptions_1.internalTransactionsOperations,
107
+ ...descriptions_1.requestsOperations,
108
+ ...descriptions_1.supplierInvoicesOperations,
109
+ ...descriptions_1.clientsInvoicesOperations,
110
+ ...descriptions_1.creditNotesOperations,
111
+ ...descriptions_1.clientsOperations,
112
+ ...descriptions_1.teamsOperations,
113
+ ...descriptions_1.statementsOperations,
114
+ ...descriptions_1.insuranceContractsOperations,
115
+ ...descriptions_1.cardsOperations,
116
+ ],
117
+ };
118
+ }
119
+ async execute() {
120
+ const items = this.getInputData();
121
+ const resource = this.getNodeParameter('resource', 0);
122
+ const operation = this.getNodeParameter('operation', 0);
123
+ let headers = {};
124
+ const query = {};
125
+ let responseData;
126
+ const returnData = [];
127
+ for (let i = 0; i < items.length; i++) {
128
+ try {
129
+ if (resource === 'externalTransfers') {
130
+ if (operation === 'showAnExternalTransfer') {
131
+ const id = this.getNodeParameter('id', i);
132
+ const endpoint = `external_transfers/${id}`;
133
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
134
+ }
135
+ if (operation === 'createAnExternalTransfer') {
136
+ const endpoint = 'external_transfers';
137
+ const idempotencyKey = uuid();
138
+ headers = {
139
+ ...headers,
140
+ 'X-Qonto-Idempotency-Key': idempotencyKey,
141
+ };
142
+ const externalTransfer = {
143
+ beneficiary_id: this.getNodeParameter('beneficiary_id', i),
144
+ debit_iban: this.getNodeParameter('debit_iban', i),
145
+ reference: this.getNodeParameter('reference', i),
146
+ note: this.getNodeParameter('note', i),
147
+ currency: this.getNodeParameter('currency', i),
148
+ scheduled_date: this.getNodeParameter('scheduled_date', i),
149
+ amount: this.getNodeParameter('amount', i),
150
+ attachment_ids: this.getNodeParameter('attachment_ids', i),
151
+ };
152
+ const body = {
153
+ external_transfer: externalTransfer,
154
+ };
155
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
156
+ }
157
+ if (operation === 'createExternalTransfersWithCreditorData') {
158
+ const endpoint = 'external_transfers/checkout';
159
+ const idempotencyKey = this.getNodeParameter('idempotency_key', i, null);
160
+ headers = {
161
+ ...headers,
162
+ 'X-Qonto-Idempotency-Key': idempotencyKey || uuid(),
163
+ };
164
+ const debit_iban = this.getNodeParameter('debit_iban', i);
165
+ const externalTransfer = {
166
+ credit_iban: this.getNodeParameter('credit_iban', i),
167
+ credit_account_name: this.getNodeParameter('credit_account_name', i),
168
+ credit_account_currency: this.getNodeParameter('credit_account_currency', i),
169
+ reference: this.getNodeParameter('reference', i),
170
+ note: this.getNodeParameter('note', i),
171
+ currency: this.getNodeParameter('currency', i),
172
+ scheduled_date: this.getNodeParameter('scheduled_date', i),
173
+ amount: this.getNodeParameter('amount', i),
174
+ attachment_ids: this.getNodeParameter('attachment_ids', i),
175
+ };
176
+ const body = {
177
+ debit_iban,
178
+ external_transfer: externalTransfer,
179
+ };
180
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
181
+ }
182
+ if (operation === 'listExternalTransfers') {
183
+ const endpoint = 'external_transfers';
184
+ const filters = this.getNodeParameter('filters', i);
185
+ if (!isEmpty(filters)) {
186
+ if (filters.scheduled_date_from) {
187
+ query.scheduled_date_from = filters.scheduled_date_from;
188
+ }
189
+ if (filters.scheduled_date_to) {
190
+ query.scheduled_date_to = filters.scheduled_date_to;
191
+ }
192
+ if (filters.status) {
193
+ query['status[]'] = filters.status;
194
+ }
195
+ if (filters.updated_at_from) {
196
+ query.updated_at_from = filters.updated_at_from;
197
+ }
198
+ if (filters.updated_at_to) {
199
+ query.updated_at_to = filters.updated_at_to;
200
+ }
201
+ if (filters.beneficiary_ids) {
202
+ query['beneficiary_ids[]'] = filters.beneficiary_ids;
203
+ }
204
+ }
205
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
206
+ }
207
+ }
208
+ if (resource === 'beneficiaries') {
209
+ if (operation === 'listBeneficiaries') {
210
+ const endpoint = 'beneficiaries';
211
+ const filters = this.getNodeParameter('filters', i);
212
+ if (!isEmpty(filters)) {
213
+ if (filters.iban) {
214
+ query.iban = filters.iban;
215
+ }
216
+ if (typeof filters.trusted !== 'undefined') {
217
+ query.trusted = filters.trusted;
218
+ }
219
+ if (filters.status) {
220
+ query['status[]'] = filters.status;
221
+ }
222
+ if (filters.updated_at_from) {
223
+ query.updated_at_from = filters.updated_at_from;
224
+ }
225
+ if (filters.updated_at_to) {
226
+ query.updated_at_to = filters.updated_at_to;
227
+ }
228
+ }
229
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
230
+ }
231
+ if (operation === 'showBeneficiary') {
232
+ const id = this.getNodeParameter('id', i);
233
+ const endpoint = `beneficiaries/${id}`;
234
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
235
+ }
236
+ if (operation === 'untrustBeneficiaries') {
237
+ const endpoint = 'beneficiaries/untrust';
238
+ const ids = this.getNodeParameter('ids', i);
239
+ const body = {
240
+ ids,
241
+ };
242
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
243
+ }
244
+ }
245
+ if (resource === 'attachments') {
246
+ if (operation === 'uploadAttachment') {
247
+ const endpoint = 'attachments';
248
+ const idempotencyKey = uuid();
249
+ headers = {
250
+ ...headers,
251
+ 'X-Qonto-Idempotency-Key': idempotencyKey,
252
+ 'Content-Type': 'application/json',
253
+ };
254
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
255
+ const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
256
+ const base64File = fileBuffer.toString('base64');
257
+ const fileName = this.getNodeParameter('fileName', i, 'upload.bin');
258
+ const body = {
259
+ attachments: [
260
+ {
261
+ file: base64File,
262
+ filename: fileName,
263
+ },
264
+ ],
265
+ };
266
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
267
+ }
268
+ if (operation === 'showAttachment') {
269
+ const attachmentId = this.getNodeParameter('id', i);
270
+ const endpoint = `attachments/${attachmentId}`;
271
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
272
+ }
273
+ }
274
+ if (resource === 'labels') {
275
+ if (operation === 'listLabels') {
276
+ const endpoint = 'labels';
277
+ const organizationId = this.getNodeParameter('organizationId', i);
278
+ query.organization_id = organizationId;
279
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
280
+ }
281
+ if (operation === 'showLabel') {
282
+ const labelId = this.getNodeParameter('id', i);
283
+ const endpoint = `labels/${labelId}`;
284
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
285
+ }
286
+ }
287
+ if (resource === 'memberships') {
288
+ if (operation === 'listMemberships') {
289
+ const endpoint = 'memberships';
290
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, {}, i);
291
+ }
292
+ if (operation === 'getMembership') {
293
+ const membershipId = this.getNodeParameter('membership_id', i);
294
+ const endpoint = `memberships/${membershipId}`;
295
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, {}, i);
296
+ }
297
+ if (operation === 'createMembership') {
298
+ const endpoint = 'memberships/invite_employee_or_accountant';
299
+ const email = this.getNodeParameter('email', i);
300
+ const firstName = this.getNodeParameter('first_name', i);
301
+ const lastName = this.getNodeParameter('last_name', i);
302
+ const role = this.getNodeParameter('role', i);
303
+ const teamId = this.getNodeParameter('team_id', i, '');
304
+ const body = {
305
+ membership: {
306
+ email,
307
+ first_name: firstName,
308
+ last_name: lastName,
309
+ role,
310
+ },
311
+ };
312
+ if (teamId) {
313
+ body.membership.team_id = teamId;
314
+ }
315
+ responseData = await helpers_1.handleListing.call(this, headers, 'POST', endpoint, body, {}, i);
316
+ }
317
+ }
318
+ if (resource === 'organizations') {
319
+ if (operation === 'getOrganizationAndItsBank_accounts') {
320
+ const endpoint = 'organization';
321
+ const includeExternalAccounts = this.getNodeParameter('include_external_accounts', i);
322
+ const query = {};
323
+ if (includeExternalAccounts) {
324
+ query.include_external_accounts = 'true';
325
+ }
326
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, query);
327
+ }
328
+ }
329
+ if (resource === 'attachmentsInATransaction') {
330
+ if (operation === 'uploadAttachmentToATransaction') {
331
+ const transactionId = this.getNodeParameter('transaction_id', i);
332
+ const endpoint = `transactions/${transactionId}/attachments`;
333
+ const idempotencyKey = uuid();
334
+ headers = {
335
+ ...headers,
336
+ 'X-Qonto-Idempotency-Key': idempotencyKey,
337
+ };
338
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
339
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
340
+ const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
341
+ const formData = {
342
+ file: {
343
+ value: fileBuffer,
344
+ options: {
345
+ filename: binaryData.fileName || 'attachment',
346
+ contentType: binaryData.mimeType || 'application/octet-stream',
347
+ },
348
+ },
349
+ };
350
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, formData, {}, true);
351
+ if (!responseData || (typeof responseData === 'object' && Object.keys(responseData).length === 0)) {
352
+ responseData = {
353
+ success: true,
354
+ message: 'Attachment uploaded successfully to transaction',
355
+ transaction_id: transactionId,
356
+ uploaded_at: new Date().toISOString()
357
+ };
358
+ }
359
+ }
360
+ if (operation === 'listAttachmentsInATransaction') {
361
+ const transactionId = this.getNodeParameter('id', i);
362
+ const endpoint = `transactions/${transactionId}/attachments`;
363
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
364
+ }
365
+ if (operation === 'removeAllAttachmentsFromATransaction') {
366
+ const transactionId = this.getNodeParameter('id', i);
367
+ const endpoint = `transactions/${transactionId}/attachments`;
368
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'DELETE', endpoint, {}, {});
369
+ }
370
+ if (operation === 'removeAnAttachmentFromATransaction') {
371
+ const transactionId = this.getNodeParameter('transaction_id', i);
372
+ const attachmentId = this.getNodeParameter('attachment_id', i);
373
+ const endpoint = `transactions/${transactionId}/attachments/${attachmentId}`;
374
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'DELETE', endpoint, {}, {});
375
+ }
376
+ }
377
+ if (resource === 'transactions') {
378
+ if (operation === 'listTransactions') {
379
+ const endpoint = 'transactions';
380
+ const identifierType = this.getNodeParameter('identifierType', i);
381
+ if (identifierType === 'bankAccountId') {
382
+ const bankAccountId = this.getNodeParameter('bankAccountId', i);
383
+ query.bank_account_id = bankAccountId;
384
+ }
385
+ else {
386
+ const iban = this.getNodeParameter('iban', i);
387
+ query.iban = iban;
388
+ }
389
+ const filters = this.getNodeParameter('filters', i);
390
+ if (!isEmpty(filters)) {
391
+ if (filters.status) {
392
+ query['status[]'] = filters.status;
393
+ }
394
+ if (filters.updated_at_from) {
395
+ query.updated_at_from = filters.updated_at_from;
396
+ }
397
+ if (filters.updated_at_to) {
398
+ query.updated_at_to = filters.updated_at_to;
399
+ }
400
+ if (filters.emitted_at_from) {
401
+ query.emitted_at_from = filters.emitted_at_from;
402
+ }
403
+ if (filters.emitted_at_to) {
404
+ query.emitted_at_to = filters.emitted_at_to;
405
+ }
406
+ if (filters.settled_at_from) {
407
+ query.settled_at_from = filters.settled_at_from;
408
+ }
409
+ if (filters.settled_at_to) {
410
+ query.settled_at_to = filters.settled_at_to;
411
+ }
412
+ if (filters.side) {
413
+ query.side = filters.side;
414
+ }
415
+ if (filters.operation_type) {
416
+ query['operation_type[]'] = filters.operation_type;
417
+ }
418
+ if (typeof filters.with_attachments !== 'undefined') {
419
+ query.with_attachments = filters.with_attachments;
420
+ }
421
+ if (filters.labels) {
422
+ query.labels = filters.labels;
423
+ }
424
+ if (filters.attachments) {
425
+ query.attachments = filters.attachments;
426
+ }
427
+ }
428
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
429
+ }
430
+ if (operation === 'showTransaction') {
431
+ const id = this.getNodeParameter('id', i);
432
+ const endpoint = `transactions/${id}`;
433
+ responseData = await helpers_1.qontoApiRequest.call(this, {}, 'GET', endpoint, {}, {});
434
+ }
435
+ }
436
+ if (resource === 'internalTransactions') {
437
+ if (operation === 'createInternalTransfer') {
438
+ const endpoint = 'internal_transfers';
439
+ const idempotencyKey = uuid();
440
+ headers = { 'X-Qonto-Idempotency-Key': idempotencyKey };
441
+ const internalTransfer = {
442
+ debit_iban: this.getNodeParameter('debit_iban', i),
443
+ credit_iban: this.getNodeParameter('credit_iban', i),
444
+ reference: this.getNodeParameter('reference', i),
445
+ currency: this.getNodeParameter('currency', i),
446
+ amount: this.getNodeParameter('amount', i),
447
+ };
448
+ const body = {
449
+ internal_transfer: internalTransfer,
450
+ };
451
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
452
+ }
453
+ }
454
+ if (resource === 'requests') {
455
+ if (operation === 'listRequests') {
456
+ const endpoint = 'requests';
457
+ const filters = this.getNodeParameter('filters', i);
458
+ if (!isEmpty(filters)) {
459
+ if (filters.status) {
460
+ query['status[]'] = filters.status;
461
+ }
462
+ if (filters.request_type) {
463
+ query['request_type[]'] = filters.request_type;
464
+ }
465
+ if (filters.created_at_from) {
466
+ query.created_at_from = filters.created_at_from;
467
+ }
468
+ if (filters.processed_at_from) {
469
+ query.processed_at_from = filters.processed_at_from;
470
+ }
471
+ }
472
+ responseData = await helpers_1.qontoApiRequest.call(this, {}, 'GET', endpoint, {}, query);
473
+ }
474
+ if (operation === 'approveARequest') {
475
+ const requestId = this.getNodeParameter('id', i);
476
+ const requestType = this.getNodeParameter('request_type', i);
477
+ const endpoint = `requests/${requestType}/${requestId}/approve`;
478
+ const idempotencyKey = uuid();
479
+ headers = {
480
+ ...headers,
481
+ 'X-Qonto-Idempotency-Key': idempotencyKey,
482
+ };
483
+ const body = {};
484
+ const debitIban = this.getNodeParameter('debit_iban', i);
485
+ if (debitIban) {
486
+ body.debit_iban = debitIban;
487
+ }
488
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
489
+ }
490
+ if (operation === 'declineARequest') {
491
+ const requestId = this.getNodeParameter('id', i);
492
+ const requestType = this.getNodeParameter('request_type', i);
493
+ const endpoint = `requests/${requestType}/${requestId}/decline`;
494
+ const idempotencyKey = uuid();
495
+ headers = {
496
+ ...headers,
497
+ 'X-Qonto-Idempotency-Key': idempotencyKey,
498
+ };
499
+ const body = {};
500
+ const declinedNote = this.getNodeParameter('declined_note', i);
501
+ if (declinedNote) {
502
+ body.declined_note = declinedNote;
503
+ }
504
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
505
+ }
506
+ }
507
+ if (resource === 'supplierInvoices') {
508
+ if (operation === 'listSupplierInvoices') {
509
+ const endpoint = 'supplier_invoices';
510
+ const filters = this.getNodeParameter('filters', i);
511
+ if (!isEmpty(filters)) {
512
+ if (filters.status) {
513
+ query.status = filters.status;
514
+ }
515
+ if (filters.start_date) {
516
+ query.start_date = filters.start_date;
517
+ }
518
+ if (filters.end_date) {
519
+ query.end_date = filters.end_date;
520
+ }
521
+ }
522
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
523
+ }
524
+ if (operation === 'createSupplierInvoices') {
525
+ const endpoint = 'supplier_invoices/bulk';
526
+ const invoices = this.getNodeParameter('supplierInvoices', i);
527
+ const organizationId = this.getNodeParameter('organizationId', i);
528
+ const body = {
529
+ organization_id: organizationId,
530
+ supplier_invoices: invoices.map((invoice) => ({
531
+ invoice_number: invoice.invoiceNumber,
532
+ invoice_date: invoice.invoiceDate,
533
+ amount: invoice.amount,
534
+ currency: invoice.currency,
535
+ attachment_ids: invoice.attachmentIds,
536
+ })),
537
+ };
538
+ headers = {
539
+ ...headers,
540
+ 'Content-Type': 'application/json',
541
+ };
542
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
543
+ }
544
+ }
545
+ if (resource === 'clientInvoices') {
546
+ if (operation === 'listClientInvoices') {
547
+ const endpoint = 'client_invoices';
548
+ const filters = this.getNodeParameter('filters', i);
549
+ if (!isEmpty(filters)) {
550
+ if (filters.status) {
551
+ query.status = filters.status;
552
+ }
553
+ if (filters.start_date) {
554
+ query.start_date = filters.start_date;
555
+ }
556
+ if (filters.end_date) {
557
+ query.end_date = filters.end_date;
558
+ }
559
+ }
560
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
561
+ }
562
+ if (operation === 'createClientInvoice') {
563
+ const endpoint = 'client_invoices';
564
+ const organizationId = this.getNodeParameter('organizationId', i);
565
+ const clientInvoice = this.getNodeParameter('clientInvoice', i);
566
+ const body = {
567
+ organization_id: organizationId,
568
+ client_invoice: {
569
+ invoice_number: clientInvoice.invoiceNumber,
570
+ invoice_date: clientInvoice.invoiceDate,
571
+ due_date: clientInvoice.dueDate,
572
+ amount: clientInvoice.amount,
573
+ currency: clientInvoice.currency,
574
+ description: clientInvoice.description,
575
+ },
576
+ };
577
+ headers = {
578
+ ...headers,
579
+ 'Content-Type': 'application/json',
580
+ };
581
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
582
+ }
583
+ }
584
+ if (resource === 'creditNotes') {
585
+ if (operation === 'listCreditNotes') {
586
+ const endpoint = 'credit_notes';
587
+ const filters = this.getNodeParameter('filters', i);
588
+ if (!isEmpty(filters)) {
589
+ if (filters.status) {
590
+ query.status = filters.status;
591
+ }
592
+ if (filters.start_date) {
593
+ query.start_date = filters.start_date;
594
+ }
595
+ if (filters.end_date) {
596
+ query.end_date = filters.end_date;
597
+ }
598
+ }
599
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
600
+ }
601
+ if (operation === 'getCreditNoteDetails') {
602
+ const creditNoteId = this.getNodeParameter('creditNoteId', i);
603
+ const endpoint = `credit_notes/${creditNoteId}`;
604
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
605
+ }
606
+ }
607
+ if (resource === 'clients') {
608
+ if (operation === 'listClients') {
609
+ const endpoint = 'clients';
610
+ const filters = this.getNodeParameter('filters', i);
611
+ if (!isEmpty(filters)) {
612
+ if (filters.status) {
613
+ query.status = filters.status;
614
+ }
615
+ if (filters.start_date) {
616
+ query.start_date = filters.start_date;
617
+ }
618
+ if (filters.end_date) {
619
+ query.end_date = filters.end_date;
620
+ }
621
+ }
622
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
623
+ }
624
+ if (operation === 'getClientDetails') {
625
+ const clientId = this.getNodeParameter('clientId', i);
626
+ const endpoint = `clients/${clientId}`;
627
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
628
+ }
629
+ if (operation === 'createClient') {
630
+ const endpoint = 'clients';
631
+ const organizationId = this.getNodeParameter('organizationId', i);
632
+ const clientData = {
633
+ name: this.getNodeParameter('clientName', i),
634
+ email: this.getNodeParameter('email', i),
635
+ phone_number: this.getNodeParameter('phoneNumber', i, null),
636
+ address: this.getNodeParameter('address', i, null),
637
+ };
638
+ const body = {
639
+ organization_id: organizationId,
640
+ client: clientData,
641
+ };
642
+ headers = {
643
+ ...headers,
644
+ 'Content-Type': 'application/json',
645
+ };
646
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
647
+ }
648
+ }
649
+ if (resource === 'teams') {
650
+ if (operation === 'listTeams') {
651
+ const endpoint = 'teams';
652
+ const organizationId = this.getNodeParameter('organizationId', i);
653
+ query.organization_id = organizationId;
654
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
655
+ }
656
+ if (operation === 'createTeam') {
657
+ const endpoint = 'teams';
658
+ const organizationId = this.getNodeParameter('organizationId', i);
659
+ const teamData = {
660
+ name: this.getNodeParameter('teamName', i),
661
+ description: this.getNodeParameter('teamDescription', i, null),
662
+ };
663
+ const body = {
664
+ organization_id: organizationId,
665
+ team: teamData,
666
+ };
667
+ headers = {
668
+ ...headers,
669
+ 'Content-Type': 'application/json',
670
+ };
671
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
672
+ }
673
+ }
674
+ if (resource === 'statements') {
675
+ if (operation === 'listStatements') {
676
+ const endpoint = 'statements';
677
+ const organizationId = this.getNodeParameter('organizationId', i);
678
+ query.organization_id = organizationId;
679
+ const filters = this.getNodeParameter('filters', i);
680
+ if (!isEmpty(filters)) {
681
+ if (filters.start_date) {
682
+ query.start_date = filters.start_date;
683
+ }
684
+ if (filters.end_date) {
685
+ query.end_date = filters.end_date;
686
+ }
687
+ }
688
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
689
+ }
690
+ if (operation === 'showStatement') {
691
+ const statementId = this.getNodeParameter('statementId', i);
692
+ const endpoint = `statements/${statementId}`;
693
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
694
+ }
695
+ }
696
+ if (resource === 'insuranceContracts') {
697
+ if (operation === 'createInsuranceContract') {
698
+ const endpoint = 'insurance_contracts';
699
+ const organizationId = this.getNodeParameter('organizationId', i);
700
+ const contractData = {
701
+ name: this.getNodeParameter('contractName', i),
702
+ start_date: this.getNodeParameter('startDate', i),
703
+ end_date: this.getNodeParameter('endDate', i, null),
704
+ coverage_details: this.getNodeParameter('coverageDetails', i, null),
705
+ };
706
+ const body = {
707
+ organization_id: organizationId,
708
+ contract: contractData,
709
+ };
710
+ headers = {
711
+ ...headers,
712
+ 'Content-Type': 'application/json',
713
+ };
714
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
715
+ }
716
+ if (operation === 'getInsuranceContract') {
717
+ const contractId = this.getNodeParameter('contractId', i);
718
+ const endpoint = `insurance_contracts/${contractId}`;
719
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
720
+ }
721
+ if (operation === 'updateInsuranceContract') {
722
+ const contractId = this.getNodeParameter('contractId', i);
723
+ const endpoint = `insurance_contracts/${contractId}`;
724
+ const updateData = {
725
+ name: this.getNodeParameter('contractName', i, null),
726
+ end_date: this.getNodeParameter('endDate', i, null),
727
+ coverage_details: this.getNodeParameter('coverageDetails', i, null),
728
+ };
729
+ const body = {
730
+ contract: updateData,
731
+ };
732
+ headers = {
733
+ ...headers,
734
+ 'Content-Type': 'application/json',
735
+ };
736
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
737
+ }
738
+ if (operation === 'uploadInsuranceContractPDF') {
739
+ const contractId = this.getNodeParameter('contractId', i);
740
+ const pdfFile = this.getNodeParameter('pdfFile', i);
741
+ const endpoint = `insurance_contracts/${contractId}/upload`;
742
+ const body = {
743
+ pdf_file: pdfFile,
744
+ };
745
+ headers = {
746
+ ...headers,
747
+ 'Content-Type': 'application/json',
748
+ };
749
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
750
+ }
751
+ }
752
+ if (resource === 'cards') {
753
+ if (operation === 'listCards') {
754
+ const endpoint = 'cards';
755
+ const organizationId = this.getNodeParameter('organizationId', i);
756
+ query.organization_id = organizationId;
757
+ const filters = this.getNodeParameter('filters', i);
758
+ if (!isEmpty(filters)) {
759
+ if (filters.status) {
760
+ query.status = filters.status;
761
+ }
762
+ }
763
+ responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
764
+ }
765
+ if (operation === 'createVirtualCard') {
766
+ const endpoint = 'cards';
767
+ const organizationId = this.getNodeParameter('organizationId', i);
768
+ const cardData = {
769
+ type: this.getNodeParameter('cardType', i),
770
+ name: this.getNodeParameter('cardName', i),
771
+ spending_limit: this.getNodeParameter('spendingLimit', i, null),
772
+ currency: this.getNodeParameter('currency', i),
773
+ };
774
+ const body = {
775
+ organization_id: organizationId,
776
+ card: cardData,
777
+ };
778
+ headers = {
779
+ ...headers,
780
+ 'Content-Type': 'application/json',
781
+ };
782
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
783
+ }
784
+ }
785
+ }
786
+ catch (error) {
787
+ if (this.continueOnFail()) {
788
+ returnData.push({ error: error.message });
789
+ continue;
790
+ }
791
+ throw error;
792
+ }
793
+ if (responseData) {
794
+ if (Array.isArray(responseData)) {
795
+ returnData.push(...responseData);
796
+ }
797
+ else {
798
+ returnData.push(responseData);
799
+ }
800
+ }
801
+ }
802
+ return [this.helpers.returnJsonArray(returnData)];
803
+ }
804
+ }
805
+ exports.Qonto = Qonto;
806
+ //# sourceMappingURL=Qonto.node.js.map