Skip to content

Commit

Permalink
Register adapters for all anchored objects. (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
OGKevin committed Nov 21, 2017
1 parent c29ac84 commit 7db4557
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bunq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def initialize_converter():
from bunq.sdk.json import adapters
from bunq.sdk.json import converter
from bunq.sdk.model.generated import object_
from bunq.sdk.model.generated import endpoint
import inspect

converter.register_adapter(core.Installation, adapters.InstallationAdapter)
converter.register_adapter(
Expand All @@ -37,6 +39,32 @@ def initialize_converter():
converter.register_adapter(object_.ShareDetail, adapters.ShareDetailAdapter)
converter.register_adapter(datetime.datetime, adapters.DateTimeAdapter)
converter.register_adapter(client.Pagination, adapters.PaginationAdapter)
# converter.register_adapter(core.AnchoredObjectInterface,
# adapters.AnchoredObjectModelAdapter)

for class_string in dir(object_):
class_ = getattr(object_, class_string)

if not inspect.isclass(class_):
continue

if issubclass(class_, core.AnchoredObjectInterface):
converter.register_adapter(
class_,
adapters.AnchoredObjectModelAdapter
)

for class_string in dir(endpoint):
class_ = getattr(endpoint, class_string)

if not inspect.isclass(class_):
continue

if issubclass(class_, core.AnchoredObjectInterface):
converter.register_adapter(
class_,
adapters.AnchoredObjectModelAdapter
)


converter.set_initializer_function(initialize_converter)

0 comments on commit 7db4557

Please sign in to comment.