from typing import Type, Optional

from edpdependencyinjection import AnyType
from httpmessageprocessorutil.automapped import AutoMappedMessageProcessor

from ._BaseRouteDefinition import BaseRouteDefinition


class RouteDefinition(BaseRouteDefinition):
    def __init__(
        self,
        interactor_type: Type[AnyType],
        request_type: Optional[Type] = None,
        processor_type: Optional[Type[AutoMappedMessageProcessor]] = AutoMappedMessageProcessor,
        success_status: int = 200,
        exception_map: Optional[dict] = None,
        extra_mapping: Optional[dict] = None,
        event_name: Optional[str] = None,
        response_content_type: Optional[str] = None,
        **kwargs,
    ):
        self.interactor_type = interactor_type
        self.request_type = request_type
        super().__init__(
            processor_type=processor_type,
            params={
                "request_type": request_type,
                "exception_map": exception_map,
                "success_status": success_status,
                "extra_mapping": extra_mapping,
                "event_name": event_name,
                "response_content_type": response_content_type,
                **kwargs,
            }
        )

    def __str__(self):
        values = [
            f"Processor: {self.processor_type}",
            f"Interactor: {self.interactor_type}",
            f"Request: {self.request_type}",
        ]
        return " - ".join(values)
