

class PresentAPNUseCase(object):

    def __init__(self, repository):

        self.repository = repository

    def execute(self, apn_identifier, observer):

        def success(apn):
            observer.did_present_apn(apn=apn,
                                     apn_identifier=apn_identifier)

        def failure(exception, context):
            observer.did_fail_to_present_apn(exception=exception,
                                             context=context,
                                             apn_identifier=apn_identifier)

        self.repository.fetch_apn(apn_identifier=apn_identifier,
                                  success=success,
                                  failure=failure)
