@@ -567,17 +567,27 @@ def _response_handler_get_transactions_xml(responses):
567567 return booked_streams , pending_streams
568568
569569 def get_transactions_xml (self , account : SEPAAccount , start_date : datetime .date = None ,
570- end_date : datetime .date = None ) -> list :
570+ end_date : datetime .date = None , supported_camt_messages = None ) -> list :
571571 """
572- Fetches the list of transactions of a bank account in a certain timeframe as camt.052.001.02 XML files.
572+ Fetches the list of transactions of a bank account in a certain timeframe as camt XML files.
573573 Returns both booked and pending transactions.
574574
575575 :param account: SEPA
576576 :param start_date: First day to fetch
577577 :param end_date: Last day to fetch
578+ :param supported_camt_messages: Names of accepted camt formats. If `None`, we'll accept whatever the bank offers.
578579 :return: Two lists of bytestrings containing XML documents, possibly empty: first one for booked transactions,
579580 second for pending transactions
580581 """
582+ hicazs = self .bpd .find_segment_first ('HICAZS' )
583+ if hicazs :
584+ bank_supported_camt_messages = list (hicazs .parameter .supported_camt_formats )
585+ else :
586+ bank_supported_camt_messages = []
587+ if supported_camt_messages is None :
588+ supported_camt_messages = bank_supported_camt_messages
589+ else :
590+ supported_camt_messages = [m for m in supported_camt_messages if m in bank_supported_camt_messages ]
581591
582592 with self ._get_dialog () as dialog :
583593 hkcaz = self ._find_highest_supported_command (HKCAZ1 )
@@ -591,7 +601,7 @@ def get_transactions_xml(self, account: SEPAAccount, start_date: datetime.date =
591601 date_start = start_date ,
592602 date_end = end_date ,
593603 touchdown_point = touchdown ,
594- supported_camt_messages = SupportedMessageTypes ([ 'urn:iso:std:iso:20022:tech:xsd:camt.052.001.02' ] ),
604+ supported_camt_messages = SupportedMessageTypes (supported_camt_messages ),
595605 ),
596606 FinTS3Client ._response_handler_get_transactions_xml ,
597607 'HICAZ'
0 commit comments