Skip to content

BunqModel updates for NotificationFilterUrl #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bunq/sdk/model/core/bunq_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def _unwrap_response_single(cls,
obj: Dict,
wrapper: str = None) -> Dict:
if wrapper is not None:
return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST][wrapper]
from bunq.sdk.model.generated.endpoint import NotificationFilterUrlUser, NotificationFilterUrlMonetaryAccount
if cls == NotificationFilterUrlUser or cls == NotificationFilterUrlMonetaryAccount:
return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST]['NotificationFilterUrl']
else:
return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST][wrapper]

return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST]

Expand Down Expand Up @@ -101,6 +105,16 @@ def _from_json_list(cls,

for item in array:
item_unwrapped = item if wrapper is None else item[wrapper]
# item_unwrapped needs to be deserialized to NotificationFilterUrl (wrapper)
# when cls is NotificationFilterUrlUser or NotificationFilterUrlMonetaryAccount
if wrapper=='NotificationFilterUrl':
from bunq.sdk.model.generated.endpoint import NotificationFilterUrlUser, NotificationFilterUrlMonetaryAccount
from bunq.sdk.model.generated.object_ import NotificationFilterUrl
if cls == NotificationFilterUrlUser or cls == NotificationFilterUrlMonetaryAccount:
cls_orig = cls
cls = NotificationFilterUrl
#print(f'NotificationFilterUrlUser deserialization, changing cls from: {cls_orig} to: {cls}')
#TODO: Test deserialize for NotificationFilterUrlUser and NotificationFilterUrlMonetaryAccount
item_deserialized = converter.deserialize(cls, item_unwrapped)
array_deserialized.append(item_deserialized)

Expand Down