n8n-nodes-qonto-api 1.0.6 → 1.0.7

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.
@@ -145,7 +145,7 @@ class Qonto {
145
145
  reference: this.getNodeParameter('reference', i),
146
146
  note: this.getNodeParameter('note', i),
147
147
  currency: this.getNodeParameter('currency', i),
148
- scheduled_date: (0, helpers_1.formatDateTime)(this.getNodeParameter('scheduled_date', i)),
148
+ scheduled_date: (0, helpers_1.formatDate)(this.getNodeParameter('scheduled_date', i)),
149
149
  amount: this.getNodeParameter('amount', i),
150
150
  attachment_ids: this.getNodeParameter('attachment_ids', i),
151
151
  };
@@ -169,7 +169,7 @@ class Qonto {
169
169
  reference: this.getNodeParameter('reference', i),
170
170
  note: this.getNodeParameter('note', i),
171
171
  currency: this.getNodeParameter('currency', i),
172
- scheduled_date: (0, helpers_1.formatDateTime)(this.getNodeParameter('scheduled_date', i)),
172
+ scheduled_date: (0, helpers_1.formatDate)(this.getNodeParameter('scheduled_date', i)),
173
173
  amount: this.getNodeParameter('amount', i),
174
174
  attachment_ids: this.getNodeParameter('attachment_ids', i),
175
175
  };
@@ -184,10 +184,10 @@ class Qonto {
184
184
  const filters = this.getNodeParameter('filters', i);
185
185
  if (!isEmpty(filters)) {
186
186
  if (filters.scheduled_date_from) {
187
- query.scheduled_date_from = (0, helpers_1.formatDateTime)(filters.scheduled_date_from);
187
+ query.scheduled_date_from = (0, helpers_1.formatDate)(filters.scheduled_date_from);
188
188
  }
189
189
  if (filters.scheduled_date_to) {
190
- query.scheduled_date_to = (0, helpers_1.formatDateTime)(filters.scheduled_date_to);
190
+ query.scheduled_date_to = (0, helpers_1.formatDate)(filters.scheduled_date_to);
191
191
  }
192
192
  if (filters.status && filters.status.length > 0) {
193
193
  query['status[]'] = filters.status;
@@ -248,13 +248,71 @@ class Qonto {
248
248
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
249
249
  }
250
250
  if (operation === 'untrustBeneficiaries') {
251
- const endpoint = 'beneficiaries/untrust';
252
- const ids = this.getNodeParameter('ids', i);
251
+ const endpoint = 'sepa/beneficiaries/untrust';
252
+ const idsRaw = this.getNodeParameter('ids', i);
253
+ const ids = idsRaw.split(',').map((id) => id.trim());
253
254
  const body = {
254
255
  ids,
255
256
  };
256
257
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
257
258
  }
259
+ if (operation === 'trustBeneficiaries') {
260
+ const endpoint = 'sepa/beneficiaries/trust';
261
+ const idsRaw = this.getNodeParameter('ids', i);
262
+ const ids = idsRaw.split(',').map((id) => id.trim());
263
+ const body = {
264
+ ids,
265
+ };
266
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
267
+ }
268
+ if (operation === 'createBeneficiary') {
269
+ const endpoint = 'sepa/beneficiaries';
270
+ const beneficiaryData = {
271
+ name: this.getNodeParameter('beneficiaryName', i),
272
+ iban: this.getNodeParameter('iban', i),
273
+ };
274
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
275
+ if (additionalOptions.bic) {
276
+ beneficiaryData.bic = additionalOptions.bic;
277
+ }
278
+ if (additionalOptions.email) {
279
+ beneficiaryData.email = additionalOptions.email;
280
+ }
281
+ if (additionalOptions.activityTag) {
282
+ beneficiaryData.activity_tag = additionalOptions.activityTag;
283
+ }
284
+ const body = {
285
+ beneficiary: beneficiaryData,
286
+ };
287
+ headers = {
288
+ ...headers,
289
+ 'Content-Type': 'application/json',
290
+ };
291
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
292
+ }
293
+ if (operation === 'updateBeneficiary') {
294
+ const id = this.getNodeParameter('id', i);
295
+ const endpoint = `sepa/beneficiaries/${id}`;
296
+ const updateFields = this.getNodeParameter('updateFields', i, {});
297
+ const beneficiaryData = {};
298
+ if (updateFields.name) {
299
+ beneficiaryData.name = updateFields.name;
300
+ }
301
+ if (updateFields.email) {
302
+ beneficiaryData.email = updateFields.email;
303
+ }
304
+ if (updateFields.activityTag) {
305
+ beneficiaryData.activity_tag = updateFields.activityTag;
306
+ }
307
+ const body = {
308
+ beneficiary: beneficiaryData,
309
+ };
310
+ headers = {
311
+ ...headers,
312
+ 'Content-Type': 'application/json',
313
+ };
314
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
315
+ }
258
316
  }
259
317
  if (resource === 'attachment') {
260
318
  if (operation === 'uploadAttachment') {
@@ -572,8 +630,8 @@ class Qonto {
572
630
  const endpoint = 'client_invoices';
573
631
  const filters = this.getNodeParameter('filters', i);
574
632
  if (!isEmpty(filters)) {
575
- if (filters.status && filters.status.length > 0) {
576
- query['filter[status]'] = filters.status.join(',');
633
+ if (filters.status) {
634
+ query['filter[status]'] = filters.status;
577
635
  }
578
636
  if (filters.created_at_from) {
579
637
  query['filter[created_at_from]'] = (0, helpers_1.formatDateTime)(filters.created_at_from);
@@ -587,15 +645,6 @@ class Qonto {
587
645
  if (filters.updated_at_to) {
588
646
  query['filter[updated_at_to]'] = (0, helpers_1.formatDateTime)(filters.updated_at_to);
589
647
  }
590
- if (filters.due_date) {
591
- query['filter[due_date]'] = (0, helpers_1.formatDateTime)(filters.due_date);
592
- }
593
- if (filters.due_date_from) {
594
- query['filter[due_date_from]'] = (0, helpers_1.formatDateTime)(filters.due_date_from);
595
- }
596
- if (filters.due_date_to) {
597
- query['filter[due_date_to]'] = (0, helpers_1.formatDateTime)(filters.due_date_to);
598
- }
599
648
  if (typeof filters.exclude_imported !== 'undefined') {
600
649
  query.exclude_imported = filters.exclude_imported;
601
650
  }
@@ -607,25 +656,117 @@ class Qonto {
607
656
  }
608
657
  if (operation === 'createClientInvoice') {
609
658
  const endpoint = 'client_invoices';
610
- const organizationId = this.getNodeParameter('organizationId', i);
611
- const clientInvoice = this.getNodeParameter('clientInvoice', i);
659
+ const clientId = this.getNodeParameter('clientId', i);
660
+ const issueDate = (0, helpers_1.formatDate)(this.getNodeParameter('issueDate', i));
661
+ const dueDate = (0, helpers_1.formatDate)(this.getNodeParameter('dueDate', i));
662
+ const currency = this.getNodeParameter('currency', i);
663
+ const paymentIban = this.getNodeParameter('paymentIban', i);
664
+ const itemsData = this.getNodeParameter('items', i);
665
+ const items = [];
666
+ if (itemsData.item && Array.isArray(itemsData.item)) {
667
+ for (const item of itemsData.item) {
668
+ const invoiceItem = {
669
+ title: item.title,
670
+ quantity: item.quantity,
671
+ unit_price: {
672
+ value: item.unitPriceValue,
673
+ currency: item.unitPriceCurrency,
674
+ },
675
+ vat_rate: item.vatRate,
676
+ };
677
+ if (item.description) {
678
+ invoiceItem.description = item.description;
679
+ }
680
+ if (item.unit) {
681
+ invoiceItem.unit = item.unit;
682
+ }
683
+ items.push(invoiceItem);
684
+ }
685
+ }
612
686
  const body = {
613
- organization_id: organizationId,
614
- client_invoice: {
615
- invoice_number: clientInvoice.invoiceNumber,
616
- invoice_date: clientInvoice.invoiceDate,
617
- due_date: clientInvoice.dueDate,
618
- amount: clientInvoice.amount,
619
- currency: clientInvoice.currency,
620
- description: clientInvoice.description,
687
+ client_id: clientId,
688
+ issue_date: issueDate,
689
+ due_date: dueDate,
690
+ currency,
691
+ payment_methods: {
692
+ iban: paymentIban,
621
693
  },
694
+ items,
622
695
  };
696
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
697
+ if (additionalOptions.status) {
698
+ body.status = additionalOptions.status;
699
+ }
700
+ if (additionalOptions.number) {
701
+ body.number = additionalOptions.number;
702
+ }
703
+ if (additionalOptions.purchaseOrder) {
704
+ body.purchase_order = additionalOptions.purchaseOrder;
705
+ }
706
+ if (additionalOptions.termsAndConditions) {
707
+ body.terms_and_conditions = additionalOptions.termsAndConditions;
708
+ }
709
+ if (additionalOptions.header) {
710
+ body.header = additionalOptions.header;
711
+ }
712
+ if (additionalOptions.footer) {
713
+ body.footer = additionalOptions.footer;
714
+ }
715
+ if (additionalOptions.performanceStartDate) {
716
+ body.performance_start_date = (0, helpers_1.formatDate)(additionalOptions.performanceStartDate);
717
+ }
718
+ if (additionalOptions.performanceEndDate) {
719
+ body.performance_end_date = (0, helpers_1.formatDate)(additionalOptions.performanceEndDate);
720
+ }
623
721
  headers = {
624
722
  ...headers,
625
723
  'Content-Type': 'application/json',
626
724
  };
627
725
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
628
726
  }
727
+ if (operation === 'updateClientInvoice') {
728
+ const invoiceId = this.getNodeParameter('invoiceId', i);
729
+ const endpoint = `client_invoices/${invoiceId}`;
730
+ const updateFields = this.getNodeParameter('updateFields', i, {});
731
+ const body = {};
732
+ if (updateFields.clientId) {
733
+ body.client_id = updateFields.clientId;
734
+ }
735
+ if (updateFields.issueDate) {
736
+ body.issue_date = (0, helpers_1.formatDate)(updateFields.issueDate);
737
+ }
738
+ if (updateFields.dueDate) {
739
+ body.due_date = (0, helpers_1.formatDate)(updateFields.dueDate);
740
+ }
741
+ if (updateFields.number) {
742
+ body.number = updateFields.number;
743
+ }
744
+ if (updateFields.purchaseOrder) {
745
+ body.purchase_order = updateFields.purchaseOrder;
746
+ }
747
+ if (updateFields.termsAndConditions) {
748
+ body.terms_and_conditions = updateFields.termsAndConditions;
749
+ }
750
+ if (updateFields.header) {
751
+ body.header = updateFields.header;
752
+ }
753
+ if (updateFields.footer) {
754
+ body.footer = updateFields.footer;
755
+ }
756
+ if (updateFields.paymentIban) {
757
+ body.payment_methods = { iban: updateFields.paymentIban };
758
+ }
759
+ headers = {
760
+ ...headers,
761
+ 'Content-Type': 'application/json',
762
+ };
763
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
764
+ }
765
+ if (operation === 'showClientInvoice') {
766
+ const invoiceId = this.getNodeParameter('invoiceId', i);
767
+ const endpoint = `client_invoices/${invoiceId}`;
768
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
769
+ }
629
770
  }
630
771
  if (resource === 'creditNotes') {
631
772
  if (operation === 'getListCreditNotes') {
@@ -677,41 +818,153 @@ class Qonto {
677
818
  }
678
819
  if (operation === 'createClient') {
679
820
  const endpoint = 'clients';
680
- const organizationId = this.getNodeParameter('organizationId', i);
681
- const clientData = {
682
- name: this.getNodeParameter('clientName', i),
683
- email: this.getNodeParameter('email', i),
684
- phone_number: this.getNodeParameter('phoneNumber', i, null),
685
- address: this.getNodeParameter('address', i, null),
686
- };
821
+ const kind = this.getNodeParameter('kind', i);
822
+ const clientName = this.getNodeParameter('clientName', i, '');
823
+ const firstName = this.getNodeParameter('firstName', i, '');
824
+ const lastName = this.getNodeParameter('lastName', i, '');
825
+ const email = this.getNodeParameter('email', i, '');
687
826
  const body = {
688
- organization_id: organizationId,
689
- client: clientData,
827
+ kind,
690
828
  };
829
+ if (clientName) {
830
+ body.name = clientName;
831
+ }
832
+ if (firstName) {
833
+ body.first_name = firstName;
834
+ }
835
+ if (lastName) {
836
+ body.last_name = lastName;
837
+ }
838
+ if (email) {
839
+ body.email = email;
840
+ }
841
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
842
+ if (additionalOptions.vatNumber) {
843
+ body.vat_number = additionalOptions.vatNumber;
844
+ }
845
+ if (additionalOptions.taxIdentificationNumber) {
846
+ body.tax_identification_number = additionalOptions.taxIdentificationNumber;
847
+ }
848
+ if (additionalOptions.currency) {
849
+ body.currency = additionalOptions.currency;
850
+ }
851
+ if (additionalOptions.locale) {
852
+ body.locale = additionalOptions.locale;
853
+ }
854
+ if (additionalOptions.recipientCode) {
855
+ body.recipient_code = additionalOptions.recipientCode;
856
+ }
857
+ if (additionalOptions.eInvoicingAddress) {
858
+ body.e_invoicing_address = additionalOptions.eInvoicingAddress;
859
+ }
860
+ if (additionalOptions.phoneCountryCode || additionalOptions.phoneNumber) {
861
+ body.phone = {
862
+ country_code: additionalOptions.phoneCountryCode || '',
863
+ number: additionalOptions.phoneNumber || '',
864
+ };
865
+ }
866
+ if (additionalOptions.extraEmails) {
867
+ body.extra_emails = additionalOptions.extraEmails.split(',').map((e) => e.trim());
868
+ }
869
+ if (additionalOptions.billingStreetAddress || additionalOptions.billingCity || additionalOptions.billingZipCode || additionalOptions.billingCountryCode) {
870
+ body.billing_address = {};
871
+ if (additionalOptions.billingStreetAddress) {
872
+ body.billing_address.street_address = additionalOptions.billingStreetAddress;
873
+ }
874
+ if (additionalOptions.billingCity) {
875
+ body.billing_address.city = additionalOptions.billingCity;
876
+ }
877
+ if (additionalOptions.billingZipCode) {
878
+ body.billing_address.zip_code = additionalOptions.billingZipCode;
879
+ }
880
+ if (additionalOptions.billingProvinceCode) {
881
+ body.billing_address.province_code = additionalOptions.billingProvinceCode;
882
+ }
883
+ if (additionalOptions.billingCountryCode) {
884
+ body.billing_address.country_code = additionalOptions.billingCountryCode;
885
+ }
886
+ }
691
887
  headers = {
692
888
  ...headers,
693
889
  'Content-Type': 'application/json',
694
890
  };
695
891
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
696
892
  }
893
+ if (operation === 'updateClient') {
894
+ const clientId = this.getNodeParameter('clientId', i);
895
+ const endpoint = `clients/${clientId}`;
896
+ const updateFields = this.getNodeParameter('updateFields', i, {});
897
+ const body = {};
898
+ if (updateFields.name) {
899
+ body.name = updateFields.name;
900
+ }
901
+ if (updateFields.firstName) {
902
+ body.first_name = updateFields.firstName;
903
+ }
904
+ if (updateFields.lastName) {
905
+ body.last_name = updateFields.lastName;
906
+ }
907
+ if (updateFields.email) {
908
+ body.email = updateFields.email;
909
+ }
910
+ if (updateFields.vatNumber) {
911
+ body.vat_number = updateFields.vatNumber;
912
+ }
913
+ if (updateFields.taxIdentificationNumber) {
914
+ body.tax_identification_number = updateFields.taxIdentificationNumber;
915
+ }
916
+ if (updateFields.currency) {
917
+ body.currency = updateFields.currency;
918
+ }
919
+ if (updateFields.locale) {
920
+ body.locale = updateFields.locale;
921
+ }
922
+ if (updateFields.recipientCode) {
923
+ body.recipient_code = updateFields.recipientCode;
924
+ }
925
+ if (updateFields.eInvoicingAddress) {
926
+ body.e_invoicing_address = updateFields.eInvoicingAddress;
927
+ }
928
+ if (updateFields.phoneCountryCode || updateFields.phoneNumber) {
929
+ body.phone = {
930
+ country_code: updateFields.phoneCountryCode || '',
931
+ number: updateFields.phoneNumber || '',
932
+ };
933
+ }
934
+ if (updateFields.billingStreetAddress || updateFields.billingCity || updateFields.billingZipCode || updateFields.billingCountryCode) {
935
+ body.billing_address = {};
936
+ if (updateFields.billingStreetAddress) {
937
+ body.billing_address.street_address = updateFields.billingStreetAddress;
938
+ }
939
+ if (updateFields.billingCity) {
940
+ body.billing_address.city = updateFields.billingCity;
941
+ }
942
+ if (updateFields.billingZipCode) {
943
+ body.billing_address.zip_code = updateFields.billingZipCode;
944
+ }
945
+ if (updateFields.billingProvinceCode) {
946
+ body.billing_address.province_code = updateFields.billingProvinceCode;
947
+ }
948
+ if (updateFields.billingCountryCode) {
949
+ body.billing_address.country_code = updateFields.billingCountryCode;
950
+ }
951
+ }
952
+ headers = {
953
+ ...headers,
954
+ 'Content-Type': 'application/json',
955
+ };
956
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
957
+ }
697
958
  }
698
959
  if (resource === 'teams') {
699
960
  if (operation === 'listTeams') {
700
961
  const endpoint = 'teams';
701
- const organizationId = this.getNodeParameter('organizationId', i);
702
- query.organization_id = organizationId;
703
962
  responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
704
963
  }
705
964
  if (operation === 'createTeam') {
706
965
  const endpoint = 'teams';
707
- const organizationId = this.getNodeParameter('organizationId', i);
708
- const teamData = {
709
- name: this.getNodeParameter('teamName', i),
710
- description: this.getNodeParameter('teamDescription', i, null),
711
- };
712
966
  const body = {
713
- organization_id: organizationId,
714
- team: teamData,
967
+ name: this.getNodeParameter('teamName', i),
715
968
  };
716
969
  headers = {
717
970
  ...headers,
@@ -754,17 +1007,41 @@ class Qonto {
754
1007
  if (resource === 'insuranceContracts') {
755
1008
  if (operation === 'createInsuranceContract') {
756
1009
  const endpoint = 'insurance_contracts';
757
- const organizationId = this.getNodeParameter('organizationId', i);
758
- const endDate = this.getNodeParameter('endDate', i, null);
759
1010
  const contractData = {
760
1011
  name: this.getNodeParameter('contractName', i),
761
- start_date: (0, helpers_1.formatDateTime)(this.getNodeParameter('startDate', i)),
762
- end_date: endDate ? (0, helpers_1.formatDateTime)(endDate) : null,
763
- coverage_details: this.getNodeParameter('coverageDetails', i, null),
1012
+ contract_id: this.getNodeParameter('contractId', i),
1013
+ origin: this.getNodeParameter('origin', i),
1014
+ provider_slug: this.getNodeParameter('providerSlug', i),
1015
+ type: this.getNodeParameter('contractType', i),
1016
+ status: this.getNodeParameter('status', i),
764
1017
  };
1018
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
1019
+ if (additionalOptions.troubleshootingUrl) {
1020
+ contractData.troubleshooting_url = additionalOptions.troubleshootingUrl;
1021
+ }
1022
+ if (additionalOptions.serviceUrl) {
1023
+ contractData.service_url = additionalOptions.serviceUrl;
1024
+ }
1025
+ if (additionalOptions.expirationDate) {
1026
+ contractData.expiration_date = (0, helpers_1.formatDate)(additionalOptions.expirationDate);
1027
+ }
1028
+ if (additionalOptions.startDate) {
1029
+ contractData.start_date = (0, helpers_1.formatDate)(additionalOptions.startDate);
1030
+ }
1031
+ if (additionalOptions.renewalDate) {
1032
+ contractData.renewal_date = (0, helpers_1.formatDate)(additionalOptions.renewalDate);
1033
+ }
1034
+ if (additionalOptions.paymentFrequency) {
1035
+ contractData.payment_frequency = additionalOptions.paymentFrequency;
1036
+ }
1037
+ if (additionalOptions.priceValue || additionalOptions.priceCurrency) {
1038
+ contractData.price = {
1039
+ value: additionalOptions.priceValue || '',
1040
+ currency: additionalOptions.priceCurrency || 'EUR',
1041
+ };
1042
+ }
765
1043
  const body = {
766
- organization_id: organizationId,
767
- contract: contractData,
1044
+ insurance_contract: contractData,
768
1045
  };
769
1046
  headers = {
770
1047
  ...headers,
@@ -778,16 +1055,54 @@ class Qonto {
778
1055
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
779
1056
  }
780
1057
  if (operation === 'updateInsuranceContract') {
781
- const contractId = this.getNodeParameter('contractId', i);
782
- const endpoint = `insurance_contracts/${contractId}`;
783
- const endDate = this.getNodeParameter('endDate', i, null);
784
- const updateData = {
785
- name: this.getNodeParameter('contractName', i, null),
786
- end_date: endDate ? (0, helpers_1.formatDateTime)(endDate) : null,
787
- coverage_details: this.getNodeParameter('coverageDetails', i, null),
788
- };
1058
+ const contractIdToUpdate = this.getNodeParameter('contractIdToUpdate', i);
1059
+ const endpoint = `insurance_contracts/${contractIdToUpdate}`;
1060
+ const updateFields = this.getNodeParameter('updateFields', i, {});
1061
+ const contractData = {};
1062
+ if (updateFields.name) {
1063
+ contractData.name = updateFields.name;
1064
+ }
1065
+ if (updateFields.contractId) {
1066
+ contractData.contract_id = updateFields.contractId;
1067
+ }
1068
+ if (updateFields.origin) {
1069
+ contractData.origin = updateFields.origin;
1070
+ }
1071
+ if (updateFields.providerSlug) {
1072
+ contractData.provider_slug = updateFields.providerSlug;
1073
+ }
1074
+ if (updateFields.type) {
1075
+ contractData.type = updateFields.type;
1076
+ }
1077
+ if (updateFields.status) {
1078
+ contractData.status = updateFields.status;
1079
+ }
1080
+ if (updateFields.troubleshootingUrl) {
1081
+ contractData.troubleshooting_url = updateFields.troubleshootingUrl;
1082
+ }
1083
+ if (updateFields.serviceUrl) {
1084
+ contractData.service_url = updateFields.serviceUrl;
1085
+ }
1086
+ if (updateFields.expirationDate) {
1087
+ contractData.expiration_date = (0, helpers_1.formatDate)(updateFields.expirationDate);
1088
+ }
1089
+ if (updateFields.startDate) {
1090
+ contractData.start_date = (0, helpers_1.formatDate)(updateFields.startDate);
1091
+ }
1092
+ if (updateFields.renewalDate) {
1093
+ contractData.renewal_date = (0, helpers_1.formatDate)(updateFields.renewalDate);
1094
+ }
1095
+ if (updateFields.paymentFrequency) {
1096
+ contractData.payment_frequency = updateFields.paymentFrequency;
1097
+ }
1098
+ if (updateFields.priceValue || updateFields.priceCurrency) {
1099
+ contractData.price = {
1100
+ value: updateFields.priceValue || '',
1101
+ currency: updateFields.priceCurrency || 'EUR',
1102
+ };
1103
+ }
789
1104
  const body = {
790
- contract: updateData,
1105
+ insurance_contract: contractData,
791
1106
  };
792
1107
  headers = {
793
1108
  ...headers,
@@ -795,18 +1110,28 @@ class Qonto {
795
1110
  };
796
1111
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
797
1112
  }
798
- if (operation === 'uploadInsuranceContractPDF') {
1113
+ if (operation === 'uploadInsuranceDocument') {
799
1114
  const contractId = this.getNodeParameter('contractId', i);
800
- const pdfFile = this.getNodeParameter('pdfFile', i);
801
- const endpoint = `insurance_contracts/${contractId}/upload`;
802
- const body = {
803
- pdf_file: pdfFile,
804
- };
805
- headers = {
806
- ...headers,
807
- 'Content-Type': 'application/json',
1115
+ const binaryProperty = this.getNodeParameter('binaryProperty', i);
1116
+ const endpoint = `insurance_contracts/${contractId}/attachments`;
1117
+ const binaryData = this.helpers.assertBinaryData(i, binaryProperty);
1118
+ const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
1119
+ const formData = {
1120
+ file: {
1121
+ value: dataBuffer,
1122
+ options: {
1123
+ filename: binaryData.fileName || 'attachment',
1124
+ contentType: binaryData.mimeType || 'application/octet-stream',
1125
+ },
1126
+ },
808
1127
  };
809
- responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
1128
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, formData, {}, true);
1129
+ }
1130
+ if (operation === 'deleteInsuranceDocument') {
1131
+ const contractId = this.getNodeParameter('contractId', i);
1132
+ const attachmentId = this.getNodeParameter('attachmentId', i);
1133
+ const endpoint = `insurance_contracts/${contractId}/attachments/${attachmentId}`;
1134
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'DELETE', endpoint, {}, {});
810
1135
  }
811
1136
  }
812
1137
  if (resource === 'cards') {
@@ -823,17 +1148,61 @@ class Qonto {
823
1148
  }
824
1149
  responseData = await helpers_1.handleListing.call(this, headers, 'GET', endpoint, {}, query, i);
825
1150
  }
826
- if (operation === 'createNew') {
1151
+ if (operation === 'createCard') {
827
1152
  const endpoint = 'cards';
828
- const organizationId = this.getNodeParameter('organizationId', i);
829
1153
  const cardData = {
830
- type: this.getNodeParameter('cardType', i),
831
- name: this.getNodeParameter('cardName', i),
832
- spending_limit: this.getNodeParameter('spendingLimit', i, null),
833
- currency: this.getNodeParameter('currency', i),
1154
+ holder_id: this.getNodeParameter('holderId', i),
1155
+ bank_account_id: this.getNodeParameter('bankAccountId', i),
1156
+ card_level: this.getNodeParameter('cardLevel', i),
1157
+ payment_monthly_limit: this.getNodeParameter('paymentMonthlyLimit', i),
834
1158
  };
1159
+ const additionalOptions = this.getNodeParameter('additionalOptions', i, {});
1160
+ if (additionalOptions.organizationId) {
1161
+ cardData.organization_id = additionalOptions.organizationId;
1162
+ }
1163
+ if (additionalOptions.initiatorId) {
1164
+ cardData.initiator_id = additionalOptions.initiatorId;
1165
+ }
1166
+ if (additionalOptions.atmOption !== undefined) {
1167
+ cardData.atm_option = additionalOptions.atmOption;
1168
+ }
1169
+ if (additionalOptions.atmMonthlyLimit) {
1170
+ cardData.atm_monthly_limit = additionalOptions.atmMonthlyLimit;
1171
+ }
1172
+ if (additionalOptions.atmDailyLimitOption !== undefined) {
1173
+ cardData.atm_daily_limit_option = additionalOptions.atmDailyLimitOption;
1174
+ }
1175
+ if (additionalOptions.atmDailyLimit) {
1176
+ cardData.atm_daily_limit = additionalOptions.atmDailyLimit;
1177
+ }
1178
+ if (additionalOptions.nfcOption !== undefined) {
1179
+ cardData.nfc_option = additionalOptions.nfcOption;
1180
+ }
1181
+ if (additionalOptions.onlineOption !== undefined) {
1182
+ cardData.online_option = additionalOptions.onlineOption;
1183
+ }
1184
+ if (additionalOptions.foreignOption !== undefined) {
1185
+ cardData.foreign_option = additionalOptions.foreignOption;
1186
+ }
1187
+ if (additionalOptions.paymentDailyLimitOption !== undefined) {
1188
+ cardData.payment_daily_limit_option = additionalOptions.paymentDailyLimitOption;
1189
+ }
1190
+ if (additionalOptions.paymentDailyLimit) {
1191
+ cardData.payment_daily_limit = additionalOptions.paymentDailyLimit;
1192
+ }
1193
+ if (additionalOptions.paymentTransactionLimitOption !== undefined) {
1194
+ cardData.payment_transaction_limit_option = additionalOptions.paymentTransactionLimitOption;
1195
+ }
1196
+ if (additionalOptions.paymentTransactionLimit) {
1197
+ cardData.payment_transaction_limit = additionalOptions.paymentTransactionLimit;
1198
+ }
1199
+ if (additionalOptions.shipToBusiness !== undefined) {
1200
+ cardData.ship_to_business = additionalOptions.shipToBusiness;
1201
+ }
1202
+ if (additionalOptions.cardDesign) {
1203
+ cardData.card_design = additionalOptions.cardDesign;
1204
+ }
835
1205
  const body = {
836
- organization_id: organizationId,
837
1206
  card: cardData,
838
1207
  };
839
1208
  headers = {
@@ -842,6 +1211,85 @@ class Qonto {
842
1211
  };
843
1212
  responseData = await helpers_1.qontoApiRequest.call(this, headers, 'POST', endpoint, body, {});
844
1213
  }
1214
+ if (operation === 'retrieveCard') {
1215
+ const cardId = this.getNodeParameter('cardId', i);
1216
+ const endpoint = `cards/${cardId}/data_view`;
1217
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'GET', endpoint, {}, {});
1218
+ }
1219
+ if (operation === 'updateCardLimits') {
1220
+ const cardId = this.getNodeParameter('cardId', i);
1221
+ const endpoint = `cards/${cardId}/limits`;
1222
+ const updateLimits = this.getNodeParameter('updateLimits', i, {});
1223
+ const cardData = {};
1224
+ if (updateLimits.paymentMonthlyLimit !== undefined) {
1225
+ cardData.payment_monthly_limit = updateLimits.paymentMonthlyLimit;
1226
+ }
1227
+ if (updateLimits.atmMonthlyLimit !== undefined) {
1228
+ cardData.atm_monthly_limit = updateLimits.atmMonthlyLimit;
1229
+ }
1230
+ if (updateLimits.atmDailyLimitOption !== undefined) {
1231
+ cardData.atm_daily_limit_option = updateLimits.atmDailyLimitOption;
1232
+ }
1233
+ if (updateLimits.atmDailyLimit !== undefined) {
1234
+ cardData.atm_daily_limit = updateLimits.atmDailyLimit;
1235
+ }
1236
+ if (updateLimits.paymentDailyLimitOption !== undefined) {
1237
+ cardData.payment_daily_limit_option = updateLimits.paymentDailyLimitOption;
1238
+ }
1239
+ if (updateLimits.paymentDailyLimit !== undefined) {
1240
+ cardData.payment_daily_limit = updateLimits.paymentDailyLimit;
1241
+ }
1242
+ if (updateLimits.paymentTransactionLimitOption !== undefined) {
1243
+ cardData.payment_transaction_limit_option = updateLimits.paymentTransactionLimitOption;
1244
+ }
1245
+ if (updateLimits.paymentTransactionLimit !== undefined) {
1246
+ cardData.payment_transaction_limit = updateLimits.paymentTransactionLimit;
1247
+ }
1248
+ const body = {
1249
+ card: cardData,
1250
+ };
1251
+ headers = {
1252
+ ...headers,
1253
+ 'Content-Type': 'application/json',
1254
+ };
1255
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
1256
+ }
1257
+ if (operation === 'updateCardOptions') {
1258
+ const cardId = this.getNodeParameter('cardId', i);
1259
+ const endpoint = `cards/${cardId}/options`;
1260
+ const updateOptions = this.getNodeParameter('updateOptions', i, {});
1261
+ const cardData = {};
1262
+ if (updateOptions.atmOption !== undefined) {
1263
+ cardData.atm_option = updateOptions.atmOption;
1264
+ }
1265
+ if (updateOptions.nfcOption !== undefined) {
1266
+ cardData.nfc_option = updateOptions.nfcOption;
1267
+ }
1268
+ if (updateOptions.onlineOption !== undefined) {
1269
+ cardData.online_option = updateOptions.onlineOption;
1270
+ }
1271
+ if (updateOptions.foreignOption !== undefined) {
1272
+ cardData.foreign_option = updateOptions.foreignOption;
1273
+ }
1274
+ const body = {
1275
+ card: cardData,
1276
+ };
1277
+ headers = {
1278
+ ...headers,
1279
+ 'Content-Type': 'application/json',
1280
+ };
1281
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PATCH', endpoint, body, {});
1282
+ }
1283
+ if (operation === 'lockCard') {
1284
+ const cardId = this.getNodeParameter('cardId', i);
1285
+ const endpoint = `cards/${cardId}/lock`;
1286
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PUT', endpoint, {}, {});
1287
+ }
1288
+ if (operation === 'unlockCard') {
1289
+ const cardId = this.getNodeParameter('cardId', i);
1290
+ const endpoint = `cards/${cardId}/unlock`;
1291
+ responseData = await helpers_1.qontoApiRequest.call(this, headers, 'PUT', endpoint, {}, {});
1292
+ }
845
1293
  }
846
1294
  }
847
1295
  catch (error) {