From: Raphael Michel Date: Sun, 22 Dec 2019 17:55:57 +0000 (+0100) Subject: Implement PSD2 for get_sepa_accounts X-Git-Tag: v3.0.0~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e9cbd9687c734f874be78e8a82d9a68f6835769;p=thirdparty%2Fpython-fints.git Implement PSD2 for get_sepa_accounts --- diff --git a/fints/client.py b/fints/client.py index a12968c..1d7554f 100644 --- a/fints/client.py +++ b/fints/client.py @@ -434,6 +434,13 @@ class FinTS3Client: retval['accounts'].append(acc) return retval + def _get_sepa_accounts(self, command_seg, response): + self.accounts = [] + for seg in response.find_segments(HISPA1, throw=True): + self.accounts.extend(seg.accounts) + + return [a for a in [acc.as_sepa_account() for acc in self.accounts] if a] + def get_sepa_accounts(self): """ Returns a list of SEPA accounts @@ -441,14 +448,9 @@ class FinTS3Client: :return: List of SEPAAccount objects. """ + seg = HKSPA1() with self._get_dialog() as dialog: - response = dialog.send(HKSPA1()) - - self.accounts = [] - for seg in response.find_segments(HISPA1, throw=True): - self.accounts.extend(seg.accounts) - - return [a for a in [acc.as_sepa_account() for acc in self.accounts] if a] + return self._send_with_possible_retry(dialog, seg, self._get_sepa_accounts) def _continue_fetch_with_touchdowns(self, command_seg, response): for resp in response.response_segments(command_seg, *self._touchdown_args, **self._touchdown_kwargs):