Skip to content

Commit

Permalink
Refactored the json/adapters.
Browse files Browse the repository at this point in the history
  • Loading branch information
angelomelonas committed Sep 18, 2019
1 parent 9131d9e commit 2fb8645
Show file tree
Hide file tree
Showing 14 changed files with 696 additions and 662 deletions.
34 changes: 22 additions & 12 deletions bunq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,51 @@ def initialize_converter():

from bunq.sdk.http import api_client
from bunq.sdk.context import api_context
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
from bunq.sdk.model.core.installation import Installation
from bunq.sdk.model.core.session_server import SessionServer
from bunq.sdk.json.installation_adapter import InstallationAdapter
from bunq.sdk.json.session_server_adapter import SessionServerAdapter
from bunq.sdk.json.installation_context_adapter import InstallationContextAdapter
from bunq.sdk.json.api_environment_type_adapter import ApiEnvironmentTypeAdapter
from bunq.sdk.json.float_adapter import FloatAdapter
from bunq.sdk.json.geolocation_adapter import GeolocationAdapter
from bunq.sdk.json.monetary_account_reference_adapter import MonetaryAccountReferenceAdapter
from bunq.sdk.json.share_detail_adapter import ShareDetailAdapter
from bunq.sdk.json.date_time_adapter import DateTimeAdapter
from bunq.sdk.json.pagination_adapter import PaginationAdapter

converter.register_adapter(Installation, adapters.InstallationAdapter)
converter.register_adapter(Installation, InstallationAdapter)
converter.register_adapter(
SessionServer,
adapters.SessionServerAdapter
SessionServerAdapter
)
converter.register_adapter(
api_context.InstallationContext,
adapters.InstallationContextAdapter
InstallationContextAdapter
)
converter.register_adapter(
api_context.ApiEnvironmentType,
adapters.ApiEnvironmentTypeAdapter
ApiEnvironmentTypeAdapter
)
converter.register_adapter(float, adapters.FloatAdapter)
converter.register_adapter(object_.Geolocation, adapters.GeolocationAdapter)
converter.register_adapter(float, FloatAdapter)
converter.register_adapter(object_.Geolocation, GeolocationAdapter)
converter.register_adapter(
object_.MonetaryAccountReference,
adapters.MonetaryAccountReferenceAdapter
MonetaryAccountReferenceAdapter
)
converter.register_adapter(object_.ShareDetail, adapters.ShareDetailAdapter)
converter.register_adapter(datetime.datetime, adapters.DateTimeAdapter)
converter.register_adapter(Pagination, adapters.PaginationAdapter)
converter.register_adapter(object_.ShareDetail, ShareDetailAdapter)
converter.register_adapter(datetime.datetime, DateTimeAdapter)
converter.register_adapter(Pagination, PaginationAdapter)

def register_anchor_adapter(class_to_register):
if issubclass(class_to_register, AnchoredObjectInterface):
from bunq.sdk.json.anchored_object_model_adapter import AnchoredObjectModelAdapter
converter.register_adapter(
class_to_register,
adapters.AnchoredObjectModelAdapter
AnchoredObjectModelAdapter
)

def get_class(class_string_to_get):
Expand Down
4 changes: 2 additions & 2 deletions bunq/sdk/http/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _fetch_response_id(self, response):
if self.HEADER_RESPONSE_ID_LOWER_CASED in headers:
return headers[self.HEADER_RESPONSE_ID_LOWER_CASED]

return self._ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER;
return self._ERROR_COULD_NOT_DETERMINE_RESPONSE_ID_HEADER

def put(self, uri_relative, request_bytes, custom_headers):
"""
Expand Down Expand Up @@ -335,4 +335,4 @@ def delete(self, uri_relative, custom_headers):
self._BYTES_EMPTY,
{},
custom_headers
)
)
Loading

0 comments on commit 2fb8645

Please sign in to comment.