예제 #1
0
def make_reservation_result(root):
    fail_code = root.findtext('fail_code')

    if fail_code == '903':
        raise aex.TrolleyPurchased(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '904':
        raise aex.TrolleyReserved(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code:
        raise aex.APIException(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )

    objs = {}

    trolley = root.find('trolley')

    if trolley is not None:
        objs['trolley'] = _parse_trolley(trolley)
        root.remove(trolley)

    failed_orders = root.find('failed_orders')

    if failed_orders is not None:
        failed_list = []
        for order in failed_orders.findall('order'):
            failed_list.append(_parse_order(order))
            failed_orders.remove(order)

        objs['failed_orders'] = failed_list
        root.remove(failed_orders)

    ret_dict = create_dict_from_xml_element(root)
    ret_dict.update(objs)

    avail_test = [
        x for x in ret_dict.keys() if x not in (
            'subdomain_user_is_bad', 'currency'
        )
    ]

    if not avail_test:
        raise aex.NoAvailability(
            call=root.tag
        )

    return ret_dict
예제 #2
0
def availability_options_result(root):
    root = error_check(root)

    backend_call_failed = root.find('backend_call_failed')

    if backend_call_failed:
        raise aex.BackendCallFailure(call=root.tag)

    ret_dict = {
        'crypto_block': root.findtext('crypto_block')
    }

    quantity_options = root.find('quantity_options')

    if quantity_options is not None:
        ret_dict['quantity_options'] = create_dict_from_xml_element(
            quantity_options
        )

    availability = root.find('availability')

    if availability is not None:

        ticket_types = []
        for t in availability.findall('ticket_type'):

            ticket_types.append(_parse_ticket_type(t))

        ret_dict['ticket_type'] = ticket_types

    despatch_options = root.find('despatch_options')

    if despatch_options is not None:
        despatch_method = []
        for d in despatch_options.findall('despatch_method'):

            despatch_method.append(_parse_despatch_method(d))

        ret_dict['despatch_options'] = {'despatch_method': despatch_method}

    currency = root.find('currency')

    if currency is not None:
        ret_dict['currency'] = _parse_currency(currency)

    event = root.find('event')

    if event is not None:
        ret_dict['event'] = _parse_event(event)

    performance = root.find('performance')

    if performance is not None:
        ret_dict['performance'] = _parse_performance(performance)

    return ret_dict
예제 #3
0
def _parse_avail_detail(avail_detail_elem):

    ad_args = {}

    currency = avail_detail_elem.find('avail_currency')

    if currency is not None:
        ad_args['avail_currency'] = _parse_currency(currency)
        avail_detail_elem.remove(currency)

    ad_args.update(create_dict_from_xml_element(avail_detail_elem))
    return objects.AvailDetail(**ad_args)
예제 #4
0
def _parse_performance(perf_elem):

    objs = {}

    cost_range = perf_elem.find('cost_range')

    if cost_range is not None:
        objs['cost_range'] = _parse_cost_range(cost_range)
        perf_elem.remove(cost_range)

    p_arg = create_dict_from_xml_element(perf_elem)
    p_arg.update(objs)

    return objects.Performance(**p_arg)
예제 #5
0
def _parse_cost_range(cost_range_elem):
    add_arg = {}

    currency = cost_range_elem.find('range_currency')

    if currency is not None:
        add_arg['currency'] = _parse_currency(currency)
        cost_range_elem.remove(currency)

    no_singles = cost_range_elem.find('no_singles_cost_range')

    if no_singles is not None:
        add_arg['no_singles_cost_range'] = _parse_cost_range(no_singles)
        cost_range_elem.remove(no_singles)

    cr_arg = create_dict_from_xml_element(cost_range_elem)
    cr_arg.update(add_arg)

    return objects.CostRange(**cr_arg)
예제 #6
0
def date_time_options_result(root):
    fail_code = root.findtext('fail_code')

    if fail_code in (
        '202', '203'
    ):
        raise aex.InvalidToken(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code:
        raise aex.APIException(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )

    ret_dict = {
        'crypto_block': root.findtext('crypto_block'),
        'need_departure_date': root.findtext('need_departure_date'),
        'has_perf_names': root.findtext('has_perf_names'),
    }

    using_perf_list = root.find('using_perf_list')
    using_usage_date = root.find('using_usage_date')

    if using_perf_list is not None:
        perf_list = []
        for p in using_perf_list.findall('performance'):
            perf_list.append(_parse_performance(p))

        ret_dict['using_perf_list'] = {'performances': perf_list}

    elif using_usage_date is not None:
        ret_dict['using_usage_date'] = create_dict_from_xml_element(
            using_usage_date
        )

    return ret_dict
예제 #7
0
def get_reservation_link_result(root):
    root = error_check(root)

    return create_dict_from_xml_element(root)
예제 #8
0
def _parse_event(event_elem):

    objs = {}

    classes = []
    for c in event_elem.findall('class'):

        classes.append(_parse_class(c))
        event_elem.remove(c)

    objs['classes'] = classes

    event_medias = []
    for event_media in event_elem.findall('event_media'):
        event_medias.append(_parse_event_media(event_media))
        event_elem.remove(event_media)

    objs['event_medias'] = event_medias

    reviews = event_elem.find('reviews')

    if reviews is not None:
        review_list = []

        for review in reviews.findall('review'):
            review_list.append(_parse_review(review))

        event_elem.remove(reviews)
        objs['reviews'] = review_list

    geo_elem = event_elem.find('geo_data')

    if geo_elem is not None:
        objs['geo_data'] = _parse_geo_data(geo_elem)
        event_elem.remove(geo_elem)

    cost_range = event_elem.find('cost_range')

    if cost_range is not None:
        objs['cost_range'] = _parse_cost_range(cost_range)
        event_elem.remove(cost_range)

    custom_fields = []

    for custom_field in event_elem.findall('custom_field'):
        custom_fields.append(_parse_custom_field(custom_field))
        event_elem.remove(custom_field)

    objs['custom_fields'] = custom_fields

    custom_filters = []

    for custom_filter in event_elem.findall('custom_filter'):
        custom_filters.append(_parse_custom_filter(custom_filter))
        event_elem.remove(custom_filter)

    objs['custom_filters'] = custom_filters

    video_iframe = event_elem.find('video_iframe')

    if video_iframe is not None:
        objs['video_iframe'] = _parse_video_iframe(video_iframe)
        event_elem.remove(video_iframe)

    structured_info = event_elem.find('structured_info')

    if structured_info is not None:
        objs['structured_info'] = _parse_structured_info(structured_info)
        event_elem.remove(structured_info)

    avail_details = event_elem.find('avail_details')

    if avail_details is not None:
        objs['avail_details'] = _parse_avail_details(avail_details)
        event_elem.remove(avail_details)

    e_arg = create_dict_from_xml_element(event_elem)
    e_arg.update(objs)

    return objects.Event(**e_arg)
예제 #9
0
def save_external_sale_page_result(root):
    root = error_check(root)

    return create_dict_from_xml_element(root)
예제 #10
0
def purchase_reservation(root):
    fail_code = root.findtext('fail_code')

    if fail_code == '1101':
        raise aex.ReservationExpired(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1106':
        raise aex.InvalidCountryForDespatch(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1107':
        raise aex.InvalidEmailAddress(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1108':
        raise aex.IncompleteCustomerDetails(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1109':
        raise aex.NoCardNumberProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1110':
        raise aex.UnknownCardType(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1111':
        raise aex.InvalidCardType(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1112':
        raise aex.InvalidCardNumber(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1113':
        raise aex.NoExpiryDateProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1114':
        raise aex.InvalidExpiryDate(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1115':
        raise aex.NoCV2Provided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1116':
        raise aex.InvalidCV2(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1117':
        raise aex.NoIssueNumberProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1119':
        raise aex.InvalidIssueNumber(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1121':
        raise aex.IncompleteAltBillingAddress(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1122':
        raise aex.NoStartDateProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1123':
        raise aex.InvalidStartDate(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code:
        raise aex.APIException(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )

    failed_cv_two = root.findtext('failed_cv_two')
    failed_avs = root.findtext('failed_avs')
    failed_3d_secure = root.findtext('failed_3d_secure')
    purchase_fail_code = root.findtext('purchase_fail_code')

    if purchase_fail_code == '1':
        raise aex.FraudTriggered(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code in ('2', '3'):
        raise aex.CardAuthorisationFailed(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '4':
        raise aex.ReservationAlreadyPurchased(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '5':
        raise aex.PurchasePreviouslyAttempted(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '6':
        raise aex.PurchaseRefused(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '7':
        raise aex.PurchaseFailed(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code:
        raise aex.PurchaseException(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )

    objs = {}

    self_print_html_pages = []

    for self_print_html_page in root.findall('self_print_html_page'):

        self_print_html_pages.append(
            _parse_self_print_html_page(self_print_html_page)
        )
        root.remove(self_print_html_page)

    objs['self_print_html_pages'] = self_print_html_pages

    trolley = root.find('trolley')

    if trolley is not None:
        objs['trolley'] = _parse_trolley(trolley)
        root.remove(trolley)

    customer = root.find('customer')

    if customer is not None:
        objs['customer'] = _parse_customer(customer)
        root.remove(customer)

    ret_dict = create_dict_from_xml_element(root)
    ret_dict.update(objs)

    return ret_dict
예제 #11
0
def purchase_reservation_part_two_result(root):
    fail_code = root.findtext('fail_code')

    if fail_code == '1404':
        raise aex.ReservationExpired(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code:
        raise aex.APIException(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )

    failed_cv_two = root.findtext('failed_cv_two')
    failed_avs = root.findtext('failed_avs')
    failed_3d_secure = root.findtext('failed_3d_secure')
    purchase_fail_code = root.findtext('purchase_fail_code')

    if purchase_fail_code == '1':
        raise aex.FraudTriggered(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code in ('2', '3'):
        raise aex.CardAuthorisationFailed(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '4':
        raise aex.ReservationAlreadyPurchased(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '5':
        raise aex.PurchasePreviouslyAttempted(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '6':
        raise aex.PurchaseRefused(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code == '7':
        raise aex.PurchaseFailed(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )
    elif purchase_fail_code:
        raise aex.PurchaseException(
            call=root.tag,
            code=purchase_fail_code,
            description=root.findtext('purchase_fail_desc'),
            failed_cv_two=failed_cv_two,
            failed_avs=failed_avs,
            failed_3d_secure=failed_3d_secure,
        )

    objs = {}

    self_print_html_pages = []

    for self_print_html_page in root.findall('self_print_html_page'):

        self_print_html_pages.append(
            _parse_self_print_html_page(self_print_html_page)
        )
        root.remove(self_print_html_page)

    objs['self_print_html_pages'] = self_print_html_pages

    trolley = root.find('trolley')

    if trolley is not None:
        objs['trolley'] = _parse_trolley(trolley)
        root.remove(trolley)

    customer = root.find('customer')

    if customer is not None:
        objs['customer'] = _parse_customer(customer)
        root.remove(customer)

    ret_dict = create_dict_from_xml_element(root)
    ret_dict.update(objs)

    return ret_dict
예제 #12
0
def purchase_reservation_part_one_result(root):
    fail_code = root.findtext('fail_code')

    if fail_code == '1301':
        raise aex.ReservationExpired(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1306':
        raise aex.InvalidCountryForDespatch(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1307':
        raise aex.InvalidEmailAddress(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1308':
        raise aex.IncompleteCustomerDetails(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1309':
        raise aex.NoCardNumberProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1310':
        raise aex.UnknownCardType(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1311':
        raise aex.InvalidCardType(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1312':
        raise aex.InvalidCardNumber(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1313':
        raise aex.NoExpiryDateProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1314':
        raise aex.InvalidExpiryDate(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1315':
        raise aex.NoCV2Provided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1316':
        raise aex.InvalidCV2(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1317':
        raise aex.NoIssueNumberProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1319':
        raise aex.InvalidIssueNumber(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1321':
        raise aex.IncompleteAltBillingAddress(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1322':
        raise aex.NoStartDateProvided(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code == '1323':
        raise aex.InvalidStartDate(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )
    elif fail_code:
        raise aex.APIException(
            call=root.tag,
            code=fail_code,
            description=root.findtext('fail_desc')
        )

    return create_dict_from_xml_element(root)
예제 #13
0
def release_reservation_result(root):
    root = error_check(root)

    return create_dict_from_xml_element(root)