from customer_services.model import Customer, InvalidRequestException, CustomerNonExistsException
from customer_services.model.repository import CustomerRepository


class GetCustomerService(object):
    def __init__(self, customer_repository):
        # type: (CustomerRepository) -> None
        
        self.customer_repository = customer_repository
    
    def get_customer(self, phone):
        # type: (str) -> Customer

        if not phone:
            raise InvalidRequestException()

        customer = self.customer_repository.get_customer(phone)
        if not customer:
            raise CustomerNonExistsException()

        return customer
