from interactor import BaseInteractor
from interactor.message.get_operators_logout_sessions.dto import GetOperatorsLogoutSessionsResponse
from model.repository import LogRepositoryModel
from services import EventDispatcher


class GetOperatorsLogoutSessionsInteractor(BaseInteractor):

    def __init__(
        self,               # type: GetOperatorsLogoutSessionsInteractor
        log_repository,     # type: LogRepositoryModel
        event_dispatcher,   # type: EventDispatcher
    ):
        # type: (...) -> None
        super(GetOperatorsLogoutSessionsInteractor, self).__init__(log_repository, event_dispatcher)

        self.log_repository = log_repository

    def execute(
        self,               # type: GetOperatorsLogoutSessionsInteractor
        business_period,    # type: str
    ):
        # type: (...) -> GetOperatorsLogoutSessionsResponse

        operators_logout_sessions = self.log_repository.get_operators_logout_sessions(business_period=business_period)

        response = GetOperatorsLogoutSessionsResponse(
            business_period=business_period,
            operators_logout_sessions=operators_logout_sessions,
        )

        return response
