import logging

from actions.models import Navigation, NavigationProduct
from application.repository import NavigationRepository
from actions import mb_context
from typing import List


class NavigationInteractor(object):
    def __init__(self):
        # type: (int) -> None

        self.logger = logging.getLogger("PosActions")
        self.navigation = NavigationRepository(mb_context)

    def get_navigation_list(self):
        # type: () -> List[Navigation]

        try:
            return self.navigation.get_navigation_list()
        except Exception as _:
            self.logger.exception("Error getting navigation list")
            return []

    def get_navigation_products(self):
        # type: () -> List[NavigationProduct]

        try:
            return self.navigation.get_navigation_products()
        except Exception as _:
            self.logger.exception("Error getting navigation products")
            return []

    def get_navigations_restricted_to_service_period(self, service_period_id):
        # type: (str) -> List[str]

        try:
            return self.navigation.get_navigations_restricted_to_service_period(service_period_id)
        except Exception as _:
            self.logger.exception("Error getting navigation restricted to service period")
            return []
