from application.service import BenefitService
from application.model import Configurations
from typing import List


class RemoveBenefitInteractor(object):

    def __init__(self, configs, benefit_service):
        # type: (Configurations, BenefitService) -> None

        self.configs = configs
        self.benefit_service = benefit_service

    def remove(self, pos_id, benefit_keys):
        # type: (int, List) -> None

        static_uow = self.benefit_service.get_static_unit_of_work(pos_id=pos_id)
        static_uow.pos_ot.blkopnotify = True

        self.benefit_service.remove_benefits(
            pos_id=pos_id,
            benefit_keys=benefit_keys,
            static_uow=static_uow,
        )

        self.benefit_service.apply_pending_benefits(
            pos_id=pos_id,
            static_uow=static_uow,
        )

        self.benefit_service.send_order_update_event(static_uow=static_uow)
