Skip to content

Commit 4b20005

Browse files
committed
Rename get_data/set_data to deconstruct/from_data
1 parent f14d937 commit 4b20005

4 files changed

Lines changed: 25 additions & 24 deletions

File tree

docs/client.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ across invocations. This includes
1414
* The User Parameter Data (UPD) with information about the user account and allowed actions
1515

1616
.. autoclass:: fints.client.FinTS3Client
17-
:members: __init__, get_data, set_data
17+
:members: __init__, deconstruct, set_data
1818
:noindex:
1919
:undoc-members:
2020

21-
Using the :func:`~fints.client.FinTS3Client.get_data`/:func:`~fints.client.FinTS3Client.set_data`
21+
Using the :func:`~fints.client.FinTS3Client.deconstruct`/:func:`~fints.client.FinTS3Client.set_data`
2222
facility is purely optional for reading operations, but may speed up the process because the BPD/UPD
2323
can be cached and need not be transmitted again.
2424

2525
It may be required to use the facility for transaction operations if both parts of a two-step transaction
2626
cannot be completed with the same :class:`~fints.client.FinTS3Client` object.
2727

28-
The :func:`~fints.client.FinTS3Client.get_data` parameter `include_private` (defaults to `False`) enables
28+
The :func:`~fints.client.FinTS3Client.deconstruct` parameter `include_private` (defaults to `False`) enables
2929
including the User Parameter Data in the datablob. Set this to `True` if you can sufficiently ensure the
3030
privacy of the returned datablob (mostly: user name and account numbers).
3131

3232
If your system manages multiple users/identity contexts, you SHOULD keep distinct datablobs per
3333
user or context.
3434

3535
You SHOULD NOT call any other methods on the :class:`~fints.client.FinTS3Client` object
36-
after calling :func:`~fints.client.FinTS3Client.get_data`.
36+
after calling :func:`~fints.client.FinTS3Client.deconstruct`.
3737

3838

3939
Keeping the dialog open
@@ -52,14 +52,14 @@ This can, and should be, complemented with the client state facility as follows:
5252
.. code-block:: python
5353
5454
datablob = ... # get from backend storage, or set to None
55-
client = FinTS3PinTanClient(..., set_data=datablob)
55+
client = FinTS3PinTanClient(..., from_data=datablob)
5656
5757
with client:
5858
accounts = client.get_sepa_accounts()
5959
balance = client.get_balance(accounts[0])
6060
transactions = client.get_transactions(accounts[0])
6161
62-
datablob = client.get_data()
62+
datablob = client.deconstruct()
6363
# Store datablob to backend storage
6464
6565
For transactions involving TANs it may be required by the bank to issue both steps for one transaction

docs/tans.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ You SHOULD use this facility together with the client and dialog state restorati
135135
response = client.sepa_transfer(...)
136136
137137
dialog_data = client.pause_dialog()
138-
client_data = client.get_data()
138+
client_data = client.deconstruct()
139139
tan_data = response.get_data()
140140
141141
.. code-block:: python
@@ -149,7 +149,7 @@ You SHOULD use this facility together with the client and dialog state restorati
149149
:caption: Third step
150150
151151
tan_request = NeedRetryResponse.from_data(tan_data)
152-
client = FinTS3PinTanClient(..., set_data=client_data)
152+
client = FinTS3PinTanClient(..., from_data=client_data)
153153
with client.resume_dialog(dialog_data):
154154
response = client.send_tan(tan_request, tan)
155155

fints/client.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __repr__(self):
150150

151151

152152
class FinTS3Client:
153-
def __init__(self, bank_identifier, user_id, customer_id=None, set_data: bytes=None):
153+
def __init__(self, bank_identifier, user_id, customer_id=None, from_data: bytes=None):
154154
self.accounts = []
155155
if isinstance(bank_identifier, BankIdentifier):
156156
self.bank_identifier = bank_identifier
@@ -172,8 +172,8 @@ def __init__(self, bank_identifier, user_id, customer_id=None, set_data: bytes=N
172172
self.response_callbacks = []
173173
self._standing_dialog = None
174174

175-
if set_data:
176-
self.set_data(bytes(set_data))
175+
if from_data:
176+
self.set_data(bytes(from_data))
177177

178178
def _new_dialog(self, lazy_init=False):
179179
raise NotImplemented()
@@ -268,7 +268,7 @@ def _set_data_v1(self, data):
268268
self.upa = SegmentSequence(data['upa_bin']).segments[0]
269269
self.upd_version = data['upd_version']
270270

271-
def _get_data_v1(self, including_private=False):
271+
def _deconstruct_v1(self, including_private=False):
272272
data = {
273273
"system_id": self.system_id,
274274
"bpd_bin": self.bpd.render_bytes(),
@@ -285,8 +285,9 @@ def _get_data_v1(self, including_private=False):
285285

286286
return data
287287

288-
def get_data(self, including_private: bool=False) -> bytes:
289-
"""Return state of this FinTSClient instance as an opaque datablob.
288+
def deconstruct(self, including_private: bool=False) -> bytes:
289+
"""Return state of this FinTSClient instance as an opaque datablob. You should not
290+
use this object after calling this method.
290291
291292
Information about the connection is implicitly retrieved from the bank and
292293
cached in the FinTSClient. This includes: system identifier, bank parameter
@@ -301,11 +302,11 @@ def get_data(self, including_private: bool=False) -> bytes:
301302
302303
Note: No connection information is stored in the datablob, neither is the PIN.
303304
"""
304-
data = self._get_data_v1(including_private=including_private)
305+
data = self._deconstruct_v1(including_private=including_private)
305306
return compress_datablob(DATA_BLOB_MAGIC, 1, data)
306307

307308
def set_data(self, blob: bytes):
308-
"""Restore a datablob created with get_data().
309+
"""Restore a datablob created with deconstruct().
309310
310311
You should only call this method once, and only immediately after constructing
311312
the object and before calling any other method or functionality (e.g. __enter__()).
@@ -825,15 +826,15 @@ def pause_dialog(self):
825826
826827
Commands MUST NOT be issued in the dialog after calling this method.
827828
828-
MUST be used in conjunction with get_data()/set_data().
829+
MUST be used in conjunction with deconstruct()/set_data().
829830
830831
Caller SHOULD ensure that the dialog is resumed (and properly ended) within a reasonable amount of time.
831832
832833
:Example:
833834
834835
::
835836
836-
client = FinTS3PinTanClient(..., set_data=None)
837+
client = FinTS3PinTanClient(..., from_data=None)
837838
with client:
838839
challenge = client.sepa_transfer(...)
839840
@@ -842,13 +843,13 @@ def pause_dialog(self):
842843
# dialog is now frozen, no new commands may be issued
843844
# exiting the context does not end the dialog
844845
845-
client_data = client.get_data()
846+
client_data = client.deconstruct()
846847
847848
# Store dialog_data and client_data out-of-band somewhere
848849
# ... Some time passes ...
849850
# Later, possibly in a different process, restore the state
850851
851-
client = FinTS3PinTanClient(..., set_data=client_data)
852+
client = FinTS3PinTanClient(..., from_data=client_data)
852853
with client.resume_dialog(dialog_data):
853854
client.send_tan(...)
854855
@@ -1017,8 +1018,8 @@ def _set_data_v1(self, data):
10171018
self.selected_security_function = data.get('selected_security_function', self.selected_security_function)
10181019
self.allowed_security_functions = data.get('allowed_security_functions', self.allowed_security_functions)
10191020

1020-
def _get_data_v1(self, including_private=False):
1021-
data = super()._get_data_v1(including_private=including_private)
1021+
def _deconstruct_v1(self, including_private=False):
1022+
data = super()._deconstruct_v1(including_private=including_private)
10221023
data.update({
10231024
"selected_security_function": self.selected_security_function,
10241025
"selected_tan_medium": self.selected_tan_medium,

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ def test_resume(fints_client, fints_server):
5757

5858
d_data = fints_client.pause_dialog()
5959

60-
c_data = fints_client.get_data(including_private=True)
60+
c_data = fints_client.deconstruct(including_private=True)
6161

6262
FinTS3PinTanClient(
6363
'12345678',
6464
'test1',
6565
'1234',
6666
fints_server,
67-
set_data=c_data
67+
from_data=c_data
6868
)
6969
assert system_id == fints_client.system_id
7070

0 commit comments

Comments
 (0)