Skip to content

Commit 9412b8d

Browse files
authored
Merge pull request #43 from bunq/feature/callback_models_bunq/sdk_python#40
Feature/callback models bunq/sdk python#40
2 parents 72bdfe3 + bf58b20 commit 9412b8d

23 files changed

+4574
-1944
lines changed

bunq/sdk/json/adapters.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
from bunq.sdk import client
55
from bunq.sdk import context
6-
from bunq.sdk.model import core
76
from bunq.sdk import security
87
from bunq.sdk.json import converter
8+
from bunq.sdk.model import core
99
from bunq.sdk.model.generated import endpoint
1010
from bunq.sdk.model.generated import object_
1111

@@ -387,20 +387,31 @@ def deserialize(cls, target_class, obj):
387387
share_detail.__dict__ = {
388388
cls._ATTRIBUTE_PAYMENT: converter.deserialize(
389389
object_.ShareDetailPayment,
390-
obj[cls._FIELD_PAYMENT]
390+
cls._get_field_or_none(cls._FIELD_DRAFT_PAYMENT, obj)
391391
),
392392
cls._ATTRIBUTE_READ_ONLY: converter.deserialize(
393393
object_.ShareDetailReadOnly,
394-
obj[cls._FIELD_READ_ONLY]
394+
cls._get_field_or_none(cls._FIELD_READ_ONLY, obj)
395395
),
396396
cls._ATTRIBUTE_DRAFT_PAYMENT: converter.deserialize(
397397
object_.ShareDetailDraftPayment,
398-
obj[cls._FIELD_DRAFT_PAYMENT]
398+
cls._get_field_or_none(cls._FIELD_DRAFT_PAYMENT, obj)
399399
),
400400
}
401401

402402
return share_detail
403403

404+
@staticmethod
405+
def _get_field_or_none(field, obj):
406+
"""
407+
:type field: str
408+
:type obj: dict
409+
410+
:return: dict|None
411+
"""
412+
413+
return obj[field] if field in obj else None
414+
404415
@classmethod
405416
def serialize(cls, share_detail):
406417
"""

bunq/sdk/json/converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class JsonAdapter(object):
2525
_WARNING_KEY_UNKNOWN = '[bunq SDK beta] Key "{}" in "{}" is unknown.'
2626

2727
# Overlapping key names to be suffixed by and underscore
28-
_KEYS_OVERLAPPING = {'id', 'type'}
28+
_KEYS_OVERLAPPING = {'id', 'type', 'object'}
2929

3030
# Suffix to strip from the keys during serialization
3131
_SUFFIX_KEY_OVERLAPPING = '_'

bunq/sdk/model/core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from bunq.sdk import client
2-
from bunq.sdk import context
32
from bunq.sdk.json import converter
43

54

@@ -269,7 +268,7 @@ def server_public_key(self):
269268
@classmethod
270269
def create(cls, api_context, public_key_string):
271270
"""
272-
:type api_context: context.ApiContext
271+
:type api_context: bunq.sdk.context.ApiContext
273272
:type public_key_string: str
274273
275274
:rtype: client.BunqResponse[Installation]
@@ -353,7 +352,7 @@ def user_company(self):
353352
@classmethod
354353
def create(cls, api_context):
355354
"""
356-
:type api_context: context.ApiContext
355+
:type api_context: bunq.sdk.context.ApiContext
357356
358357
:rtype: client.BunqResponse[SessionServer]
359358
"""

0 commit comments

Comments
 (0)