from dihttpmessageprocessor import RouteDefinition
from dihttpmessageprocessor._BaseRouteDefinition import BaseRouteDefinition
from simplehttprouter import Route

from edpopenapibuilder.builder.dto import build_params


def get_definition_params(route: Route, definition: BaseRouteDefinition):
    interactor_type = None
    if isinstance(definition, RouteDefinition):
        interactor_type = definition.interactor_type

    request_type = definition.params.get("request_type")
    response_content_type = definition.params.get("response_content_type")
    success_status = definition.params.get("success_status")
    exception_map = definition.params.get("exception_map")
    extra_mapping = definition.params.get("extra_mapping")

    return build_params(
        route=route,
        processor_type=definition.processor_type,
        interactor_type=interactor_type,
        request_type=request_type,
        response_content_type=response_content_type,
        success_status=success_status,
        exception_map=exception_map,
        extra_mapping=extra_mapping,
    )
