import logging

from application.repository.api import APIRepository
from typing import Optional

logger = logging.getLogger(__name__)


class LockBenefitInteractor(object):
    def __init__(
        self,            # type: LockBenefitInteractor
        api_repository,  # type: APIRepository
    ):
        # type: (...) -> None

        self.api_repository = api_repository

    def lock_benefit(
        self,        # type: LockBenefitInteractor
        benefit_id,  # type: str
        pos_id,      # type: int
    ):
        # type: (...) -> None

        logger.info("Locking benefit: {}; PosId: {}".format(benefit_id, pos_id))
        self.api_repository.lock_benefit(
            benefit_id=benefit_id,
            pos_id=pos_id,
        )
        logger.info("Benefit locked")
