Skip to content

Commit fb6018a

Browse files
author
Kevin Hellemun
committed
Modified SahreDetail adapter for missing fields. (#40)
1 parent 5aebec7 commit fb6018a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

bunq/sdk/json/adapters.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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: None|dict
411+
"""
412+
413+
return obj[field] if field in obj else None
414+
404415
@classmethod
405416
def serialize(cls, share_detail):
406417
"""

0 commit comments

Comments
 (0)