import logging

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

logger = logging.getLogger(__name__)


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

        self.api_repository = api_repository

    def get_loyalty_customer_info(
        self,                 # type: GetLoyaltyCustomerInfoInteractor
        loyalty_customer_id,  # type: str
    ):
        # type: (...) -> Optional[str]

        logger.info("Requesting customer loyaltySystemId")
        loyalty_id = self.api_repository.retrieve_loyalty_customer_info(loyalty_customer_id=loyalty_customer_id)
        logger.info("Retrieved customer loyalty data: {}".format(loyalty_id))
        return loyalty_id
