]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Implement a pure offline mode
authorHenryk Plötz <henryk@ploetzli.ch>
Tue, 10 Sep 2019 00:35:24 +0000 (02:35 +0200)
committerHenryk Plötz <henryk@ploetzli.ch>
Tue, 10 Sep 2019 00:36:19 +0000 (02:36 +0200)
The idea is that in the future get_information, get_tan_*, and, for convenience, get_sepa_accounts will be answered from data cached in the FinTSClient object if possible. This information in stored and retrieved with deconstruct()/from_data=
The stay_offline mode allows to inspect this cached data without risking opening a dialogue (and maybe triggering Strong Customer Authentication)

fints/client.py
fints/dialog.py
fints/exceptions.py

index 2183025901d94ea1256bac7aa2704ad30c32e814..712e52ac806df08aa419fa85be9d6b0317fffc37 100644 (file)
@@ -155,7 +155,8 @@ class FinTS3Client:
     def __init__(self,
                  bank_identifier, user_id, customer_id=None,
                  from_data: bytes=None,
-                 product_id=None, product_version=version[:5]):
+                 product_id=None, product_version=version[:5],
+                 stay_offline=False):
         self.accounts = []
         if isinstance(bank_identifier, BankIdentifier):
             self.bank_identifier = bank_identifier
@@ -179,6 +180,7 @@ class FinTS3Client:
         self.product_name = product_id
         self.product_version = product_version
         self.response_callbacks = []
+        self.stay_offline = stay_offline
         self._standing_dialog = None
 
         if from_data:
index 7b221eec19caa2f38c91384a956b82e1acbb50c3..46d060bedaad14989a70a88b910d4cc6db224fe4 100644 (file)
@@ -48,6 +48,11 @@ class FinTSDialog:
         if self.paused:
             raise FinTSDialogStateError("Cannot init() a paused dialog")
 
+        if self.client.stay_offline:
+            raise FinTSDialogOfflineError("Cannot open a dialog with stay_offline=True. "
+                                          "This is a control flow error, no online functionality "
+                                          "should have been attempted with this FinTSClient object.")
+
         if self.need_init and not self.open:
             segments = [
                 HKIDN2(
index 4d6919e0e08920621378fa62a70bf9b1b8677b0a..37bf98cee203c165ddb0bc4d14bd47b136a7a7c4 100644 (file)
@@ -22,6 +22,10 @@ class FinTSDialogStateError(FinTSDialogError):
     pass
 
 
+class FinTSDialogOfflineError(FinTSDialogError):
+    pass
+
+
 class FinTSDialogInitError(FinTSDialogError):
     pass