From e4fecd8454f235ad8530d2c97d132a28dc873772 Mon Sep 17 00:00:00 2001 From: rikvermeer Date: Sun, 25 Apr 2021 22:28:00 +0200 Subject: [PATCH 1/2] Update bunq_model.py @classmethod BunqModel._from_json_list assumes that the endpoint name is the same as the model name. This does not work for the abstract type NotificationFilterUrl which can be loaded from multiple endpoints (NotificationFilterUrlUser, NotificationFilterUrlMonetaryAccount) item_unwrapped in "BunqModel._from_json_list" needs to be deserialized to NotificationFilterUrl (wrapper) when cls is NotificationFilterUrlUser or NotificationFilterUrlMonetaryAccount --- bunq/sdk/model/core/bunq_model.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bunq/sdk/model/core/bunq_model.py b/bunq/sdk/model/core/bunq_model.py index d19dffe..855b0f3 100644 --- a/bunq/sdk/model/core/bunq_model.py +++ b/bunq/sdk/model/core/bunq_model.py @@ -101,6 +101,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) From 6bf9d67a241a1a00606d49916365aac78003930e Mon Sep 17 00:00:00 2001 From: rikvermeer Date: Sun, 25 Apr 2021 23:48:24 +0200 Subject: [PATCH 2/2] Update bunq_model.py Fixes the creation of NotificationFilterUrl by NotificationFilterUrlUser and NotificationFilterUrlMonetaryAccount --- bunq/sdk/model/core/bunq_model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bunq/sdk/model/core/bunq_model.py b/bunq/sdk/model/core/bunq_model.py index 855b0f3..f080e2b 100644 --- a/bunq/sdk/model/core/bunq_model.py +++ b/bunq/sdk/model/core/bunq_model.py @@ -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]