Ejemplo n.º 1
0
 def register_anchor_adapter(class_to_register: Type[T]) -> None:
     if issubclass(class_to_register, AnchorObjectInterface):
         converter.register_adapter(class_to_register, AnchorObjectAdapter)
Ejemplo n.º 2
0
 def register_anchor_adapter(class_to_regsiter):
     if issubclass(class_to_regsiter, core.AnchoredObjectInterface):
         converter.register_adapter(class_to_regsiter,
                                    adapters.AnchoredObjectModelAdapter)
Ejemplo n.º 3
0
def initialize_converter() -> None:
    import datetime
    import inspect

    from bunq.sdk.http import api_client
    from bunq.sdk.context import api_context
    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
    from bunq.sdk.json.anchor_object_adapter import AnchorObjectAdapter

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

    def register_anchor_adapter(class_to_register: Type[T]) -> None:
        if issubclass(class_to_register, AnchorObjectInterface):
            converter.register_adapter(class_to_register, AnchorObjectAdapter)

    def get_class(class_string_to_get: str) -> Type[T]:
        if hasattr(object_, class_string_to_get):
            return getattr(object_, class_string_to_get)

        if hasattr(endpoint, class_string_to_get):
            return getattr(endpoint, class_string_to_get)

    for class_string in list(dir(object_) + dir(endpoint)):
        class_ = get_class(class_string)

        if not inspect.isclass(class_):
            continue

        register_anchor_adapter(class_)
Ejemplo n.º 4
0
def initialize_converter():
    """
    :rtype: None
    """

    import datetime
    import inspect

    from bunq.sdk import client
    from bunq.sdk import context
    from bunq.sdk.model import core
    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

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

    def register_anchor_adapter(class_to_regsiter):
        if issubclass(class_to_regsiter, core.AnchoredObjectInterface):
            converter.register_adapter(class_to_regsiter,
                                       adapters.AnchoredObjectModelAdapter)

    def get_class(class_string_to_get):
        if hasattr(object_, class_string_to_get):
            return getattr(object_, class_string_to_get)

        if hasattr(endpoint, class_string_to_get):
            return getattr(endpoint, class_string_to_get)

    for class_string in list(dir(object_) + dir(endpoint)):
        class_ = get_class(class_string)

        if not inspect.isclass(class_):
            continue

        register_anchor_adapter(class_)