def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()

        score_lookup = scorelookup.ScoreLookup()
        score_lookup.customer_identifier = none_check.verify_not_none(xml_response.find('CustomerIdentifier'))
        score_lookup.request_timestamp = none_check.verify_not_none(xml_response.find('RequestTimestamp'))

        xml_transaction_detail = xml_response.find('TransactionDetail')
        transaction_detail = transactiondetail.TransactionDetail()
        transaction_detail.customer_identifier = none_check.verify_not_none(xml_transaction_detail.find('CustomerIdentifier'))
        transaction_detail.merchant_identifier = none_check.verify_not_none(xml_transaction_detail.find('MerchantIdentifier'))
        transaction_detail.account_number = none_check.verify_not_none(xml_transaction_detail.find('AccountNumber'))
        transaction_detail.account_prefix = none_check.verify_not_none(xml_transaction_detail.find('AccountPrefix'))
        transaction_detail.account_suffix = none_check.verify_not_none(xml_transaction_detail.find('AccountSuffix'))
        transaction_detail.transaction_amount = none_check.verify_not_none(xml_transaction_detail.find('TransactionAmount'))
        transaction_detail.transaction_date = none_check.verify_not_none(xml_transaction_detail.find('TransactionDate'))
        transaction_detail.transaction_time = none_check.verify_not_none(xml_transaction_detail.find('TransactionTime'))
        transaction_detail.bank_net_reference_number = none_check.verify_not_none(xml_transaction_detail.find('BankNetReferenceNumber'))
        transaction_detail.stan = none_check.verify_not_none(xml_transaction_detail.find('Stan'))

        xml_score_response = xml_response.find('ScoreResponse')
        score_response = scoreresponse.ScoreResponse()
        score_response.match_indicator = none_check.verify_not_none(xml_score_response.find('MatchIndicator'))
        # If statement used for NO_MATCH_FOUND response. MatchIndicator will equal 4 and other values will be none
        if xml_score_response.find('FraudScore') is not None:
            score_response.fraud_score = none_check.verify_not_none(xml_score_response.find('FraudScore'))
            score_response.reason_code = none_check.verify_not_none(xml_score_response.find('ReasonCode'))
            score_response.rules_adjusted_score = none_check.verify_not_none(xml_score_response.find('RulesAdjustedScore'))
            score_response.rules_adjusted_reason_code = none_check.verify_not_none(xml_score_response.find('RulesAdjustedReasonCode'))
            score_response.rules_adjusted_reason_code_secondary = none_check.verify_not_none(xml_score_response.find('RulesAdjustedReasonCodeSecondary'))
        score_lookup.transaction_detail = transaction_detail
        score_lookup.score_response = score_response
        return score_lookup
Example #2
0
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()
        re_power_reversal = repowerreversal.RepowerReversal()
        re_power_reversal.request_id = none_check.verify_not_none(xml_response.find('RequestId'))
        re_power_reversal.original_request_id = none_check.verify_not_none(xml_response.find('OriginalRequestId'))
        re_power_reversal.transaction_reference = none_check.verify_not_none(xml_response.find('TransactionReference'))

        transaction_history = transactionhistory.TransactionHistory()
        xml_transaction_history = xml_response.find('TransactionHistory')

        transaction_ = transaction.Transaction()
        xml_transaction = xml_transaction_history.find('Transaction')
        transaction_.type = none_check.verify_not_none(xml_transaction.find('Type'))
        transaction_.system_trace_audit_number = none_check.verify_not_none(xml_transaction.find('SystemTraceAuditNumber'))
        transaction_.network_reference_number = none_check.verify_not_none(xml_transaction.find('NetworkReferenceNumber'))
        transaction_.settlement_date = none_check.verify_not_none(xml_transaction.find('SettlementDate'))

        response_ = response.Response()
        xml_response = xml_transaction.find('Response')
        response_.code = none_check.verify_not_none(xml_response.find('Code'))
        response_.description = none_check.verify_not_none(xml_response.find('Description'))

        transaction_.submit_date_time = none_check.verify_not_none(xml_transaction.find('SubmitDateTime'))

        transaction_.response = response_
        transaction_history.transaction = transaction_

        re_power_reversal.transaction_history = transaction_history
        return re_power_reversal
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()
        re_power = repower.Repower()
        re_power.request_id = none_check.verify_not_none(xml_response.find('RequestId'))
        re_power.transaction_reference = none_check.verify_not_none(xml_response.find('TransactionReference'))

        transaction_history = transactionhistory.TransactionHistory()
        xml_transaction_history = xml_response.find('TransactionHistory')

        transaction_ = transaction.Transaction()
        xml_transaction = xml_transaction_history.find('Transaction')
        transaction_.type = none_check.verify_not_none(xml_transaction.find('Type'))
        transaction_.system_trace_audit_number = none_check.verify_not_none(xml_transaction.find('SystemTraceAuditNumber'))
        transaction_.network_reference_number = none_check.verify_not_none(xml_transaction.find('NetworkReferenceNumber'))
        transaction_.settlement_date = none_check.verify_not_none(xml_transaction.find('SettlementDate'))

        response_ = response.Response()
        xml_response = xml_transaction.find('Response')
        response_.code = none_check.verify_not_none(xml_response.find('Code'))
        response_.description = none_check.verify_not_none(xml_response.find('Description'))

        transaction_.submit_date_time = none_check.verify_not_none(xml_transaction.find('SubmitDateTime'))

        transaction_.response = response_
        transaction_history.transaction = transaction_

        account_balance = accountbalance.AccountBalance()
        account_balance.value = none_check.verify_not_none(xml_response.find('AccountBalance/Value'))
        account_balance.currency = none_check.verify_not_none(xml_response.find('AccountBalance/Currency'))

        re_power.transaction_history = transaction_history
        re_power.account_balance = account_balance
        return re_power
Example #4
0
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()
        transfer_ = transfer.Transfer()
        transfer_.request_id = none_check.verify_not_none(
            xml_response.find('RequestId'))
        transfer_.transaction_reference = none_check.verify_not_none(
            xml_response.find('TransactionReference'))

        transaction_history = transactionhistory.TransactionHistory()
        transaction_list = list()

        for xml_transaction in xml_response.findall('.//Transaction'):
            transaction_ = transaction.Transaction()
            transaction_.type = none_check.verify_not_none(
                xml_transaction.find('Type'))
            transaction_.system_trace_audit_number = none_check.verify_not_none(
                xml_transaction.find('SystemTraceAuditNumber'))
            transaction_.network_reference_number = none_check.verify_not_none(
                xml_transaction.find('NetworkReferenceNumber'))
            transaction_.settlement_date = none_check.verify_not_none(
                xml_transaction.find('SettlementDate'))

            response_ = response.Response()
            response_.code = none_check.verify_not_none(
                xml_transaction.find('Response/Code'))
            response_.description = none_check.verify_not_none(
                xml_transaction.find('Response/Description'))
            transaction_.response = response_

            transaction_.submit_date_time = none_check.verify_not_none(
                xml_transaction.find('SubmitDateTime'))
            transaction_list.append(transaction_)
        transaction_history.transaction = transaction_list
        transfer_.transaction_history = transaction_history
        return transfer_
 def generate_return_object(self, xml_response):
     none_check = xmlutil.XMLUtil()
     country_list = list()
     for xml_country in xml_response.findall('Country'):
         tmp_country = country.Country(
             none_check.verify_not_none(xml_country.find('Name')),
             none_check.verify_not_none(xml_country.find('Code')))
         tmp_country.geo_coding = none_check.verify_not_none(
             xml_country.find('Geocoded'))
         country_list.append(tmp_country)
     countries_ = countries.Countries(country_list)
     return countries_
Example #6
0
 def generate_return_object(self, xml_response):
     none_check = xmlutil.XMLUtil()
     country_subdivision_list = list()
     for xml_country_subdivision in xml_response.findall(
             'CountrySubdivision'):
         tmp_country_subdivision = countrysubdivision.CountrySubdivision(
             none_check.verify_not_none(
                 xml_country_subdivision.find('Name')),
             none_check.verify_not_none(
                 xml_country_subdivision.find('Code')))
         country_subdivision_list.append(tmp_country_subdivision)
     country_subdivisions = countrysubdivisions.CountrySubdivisions(
         country_subdivision_list)
     return country_subdivisions
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()

        page_offset = xml_response.find('PageOffset').text
        total_count = xml_response.find('TotalCount').text

        merchant_list = list()
        for xml_merchant in xml_response.findall('.//Merchant'):
            tmp_merchant = merchant.Merchant()
            tmp_merchant.id = none_check.verify_not_none(xml_merchant.find('Id'))
            tmp_merchant.name = none_check.verify_not_none(xml_merchant.find('Name'))
            tmp_merchant.website_url = none_check.verify_not_none(xml_merchant.find('WebsiteUrl'))
            tmp_merchant.phone_number = none_check.verify_not_none(xml_merchant.find('PhoneNumber'))
            tmp_merchant.category = none_check.verify_not_none(xml_merchant.find('Category'))

            xml_location = xml_merchant.find('Location')
            tmp_location = location.Location()
            tmp_location.name = none_check.verify_not_none(xml_location.find('Name'))
            tmp_location.distance = none_check.verify_not_none(xml_location.find('Distance'))
            tmp_location.distance_unit = none_check.verify_not_none(xml_location.find('DistanceUnit'))

            xml_address = xml_location.find('Address')
            tmp_address = address.Address()
            tmp_address.line1 = none_check.verify_not_none(xml_address.find('Line1'))
            tmp_address.line2 = none_check.verify_not_none(xml_address.find('Line2'))
            tmp_address.city = none_check.verify_not_none(xml_address.find('City'))
            tmp_address.postal_code = none_check.verify_not_none(xml_address.find('PostalCode'))

            xml_country_subdivision = xml_address.find('CountrySubdivision')
            tmp_country_subdivision = countrysubdivision.CountrySubdivision(
                none_check.verify_not_none(xml_country_subdivision.find('Name')),
                none_check.verify_not_none(xml_country_subdivision.find('Code'))
            )
            tmp_address.country_subdivision = tmp_country_subdivision

            xml_country = xml_address.find('Country')
            tmp_country = country.Country(
                none_check.verify_not_none(xml_country.find('Name')),
                none_check.verify_not_none(xml_country.find('Code')))
            tmp_address.country = tmp_country

            xml_point = xml_location.find('Point')
            tmp_point = point.Point(
                none_check.verify_not_none(xml_point.find('Latitude')),
                none_check.verify_not_none(xml_point.find('Longitude')))
            tmp_location.point = tmp_point

            if xml_merchant.find('Topup') is not None:
                tmp_repower = repower.RePower(
                    none_check.verify_not_none(xml_merchant.find('Topup/RePower/CardSwipe')),
                    none_check.verify_not_none(xml_merchant.find('Topup/RePower/MoneyPak'))
                )
                tmp_topup = topup.Topup(tmp_repower)
                tmp_merchant.topup = tmp_topup

            if xml_merchant.find('Products') is not None:
                xml_products = xml_merchant.find('Products')
                tmp_products = products.Products(none_check.verify_not_none(xml_products.find('PrepaidTravelCard')))
                tmp_merchant.products = tmp_products

            if xml_merchant.find('Features') is not None:
                xml_features = xml_merchant.find('Features')
                tmp_cash_back = cashback.CashBack(none_check.verify_not_none(xml_features.find('CashBack/MaximumAmount')))
                tmp_features = features.Features(tmp_cash_back)
                tmp_merchant.features = tmp_features

            # At time of testing, Acceptance data was not returning as described in the documentation.
            # Uncomment when data is corrected.

            # xml_acceptance = xml_merchant.find('Acceptance')
            # xml_pay_pass = xml_acceptance.find('PayPass')
            # tmp_pay_pass = paypass.PayPass()
            # tmp_pay_pass.concession = none_check.verify_not_none(xml_pay_pass.find('Concession'))
            # tmp_pay_pass.pharmacy = none_check.verify_not_none(xml_pay_pass.find('Pharmacy'))
            # tmp_pay_pass.fuel_pump = none_check.verify_not_none(xml_pay_pass.find('FuelPump'))
            # tmp_pay_pass.toll_booth = none_check.verify_not_none(xml_pay_pass.find('TollBooth'))
            # tmp_pay_pass.drive_thru = none_check.verify_not_none(xml_pay_pass.find('DriveThru'))
            # tmp_pay_pass.register = none_check.verify_not_none(xml_pay_pass.find('Register'))
            # tmp_pay_pass.ticketing = none_check.verify_not_none(xml_pay_pass.find('Ticketing'))
            # tmp_pay_pass.vending_machine = none_check.verify_not_none(xml_pay_pass.find('VendingMachine'))
            # tmp_acceptance = acceptance.Acceptance(tmp_pay_pass)
            # tmp_merchant.acceptance = tmp_acceptance

            merchant_list.append(tmp_merchant)
        merchants_ = merchants.Merchants(merchant_list, page_offset, total_count)
        return merchants_
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()

        page_offset = none_check.verify_not_none(
            xml_response.find('PageOffset'))
        total_length = none_check.verify_not_none(
            xml_response.find('TotalLength'))
        ref = none_check.verify_not_none(xml_response.find('Ref'))
        transaction_reference_number = none_check.verify_not_none(
            xml_response.find('TransactionReferenceNumber'))

        terminated_merchant_list = list()
        for xml_terminated_merchant in xml_response.findall(
                'TerminatedMerchant'):
            terminated_merchant = terminatedmerchanttype.TerminatedMerchantType(
            )
            terminated_merchant.termination_reason_code = none_check.verify_not_none(
                xml_terminated_merchant.find('TerminationReasonCode'))

            xml_merchant = xml_terminated_merchant.find('Merchant')
            merchant_type = merchanttype.MerchantType()
            merchant_type.name = none_check.verify_not_none(
                xml_merchant.find('Name'))
            merchant_type.doing_business_as_name = none_check.verify_not_none(
                xml_merchant.find('DoingBusinessAsName'))
            merchant_type.phone_number = none_check.verify_not_none(
                xml_merchant.find('PhoneNumber'))

            xml_merchant_address = xml_merchant.find('Address')
            merchant_address = addresstype.AddressType()
            merchant_address.line1 = none_check.verify_not_none(
                xml_merchant_address.find('Line1'))
            merchant_address.line2 = none_check.verify_not_none(
                xml_merchant_address.find('Line2'))
            merchant_address.city = none_check.verify_not_none(
                xml_merchant_address.find('City'))
            merchant_address.country_subdivision = none_check.verify_not_none(
                xml_merchant_address.find('CountrySubdivision'))
            merchant_address.postal_code = none_check.verify_not_none(
                xml_merchant_address.find('PostalCode'))
            merchant_address.country = none_check.verify_not_none(
                xml_merchant_address.find('Country'))
            merchant_type.address = merchant_address

            principal_list = list()
            for xml_principal in xml_merchant.findall('Principal'):
                principal_type = principaltype.PrincipalType()
                principal_type.first_name = none_check.verify_not_none(
                    xml_principal.find('FirstName'))
                principal_type.last_name = none_check.verify_not_none(
                    xml_principal.find('LastName'))
                principal_type.national_id = none_check.verify_not_none(
                    xml_principal.find('NationalId'))
                principal_type.phone_number = none_check.verify_not_none(
                    xml_principal.find('PhoneNumber'))

                xml_principal_address = xml_principal.find('Address')
                principal_address = addresstype.AddressType()
                principal_address.line1 = none_check.verify_not_none(
                    xml_principal_address.find('Line1'))
                principal_address.line2 = none_check.verify_not_none(
                    xml_principal_address.find('Line2'))
                principal_address.city = none_check.verify_not_none(
                    xml_principal_address.find('City'))
                principal_address.country_subdivision = none_check.verify_not_none(
                    xml_principal_address.find('CountrySubdivision'))
                principal_address.postal_code = none_check.verify_not_none(
                    xml_principal_address.find('PostalCode'))
                principal_address.country = none_check.verify_not_none(
                    xml_principal_address.find('Country'))

                xml_drivers_license = xml_principal.find('DriversLicense')
                drivers_license = driverslicensetype.DriversLicenseType()
                drivers_license.number = none_check.verify_not_none(
                    xml_drivers_license.find('Number'))
                drivers_license.country_subdivision = none_check.verify_not_none(
                    xml_drivers_license.find('CountrySubdivision'))
                drivers_license.country = none_check.verify_not_none(
                    xml_drivers_license.find('Country'))
                principal_type.drivers_license = drivers_license
                principal_type.address = principal_address
                principal_list.append(principal_type)
            merchant_type.principal = principal_list
            terminated_merchant.merchant = merchant_type

            xml_merchant_match = xml_terminated_merchant.find('MerchantMatch')
            merchant_match = merchantmatchtype.MerchantMatchType()
            merchant_match.name = none_check.verify_not_none(
                xml_merchant_match.find('Name'))
            merchant_match.doing_business_as_name = none_check.verify_not_none(
                xml_merchant_match.find('DoingBusinessAsName'))
            merchant_match.phone_number = none_check.verify_not_none(
                xml_merchant_match.find('PhoneNumber'))
            merchant_match.address = none_check.verify_not_none(
                xml_merchant_match.find('Address'))
            merchant_match.country_subdivision_tax_id = none_check.verify_not_none(
                xml_merchant_match.find('CountrySubdivisionTaxId'))
            merchant_match.national_tax_id = none_check.verify_not_none(
                xml_merchant_match.find('NationalTaxId'))

            principal_match_list = list()
            for xml_principal_match in xml_merchant_match.findall(
                    'PrincipalMatch'):
                principal_match_type = principalmatchtype.PrincipalMatchType()
                principal_match_type.name = none_check.verify_not_none(
                    xml_principal_match.find('Name'))
                principal_match_type.national_id = none_check.verify_not_none(
                    xml_principal_match.find('NationalId'))
                principal_match_type.phone_number = none_check.verify_not_none(
                    xml_principal_match.find('PhoneNumber'))
                principal_match_type.address = none_check.verify_not_none(
                    xml_principal_match.find('Address'))
                principal_match_type.drivers_license = none_check.verify_not_none(
                    xml_principal_match.find('DriversLicense'))
                principal_match_list.append(principal_match_type)

            merchant_match.principal_match = principal_match_list
            terminated_merchant.merchant_match = merchant_match
            terminated_merchant_list.append(terminated_merchant)

        termination_inquiry = terminationinquiry.TerminationInquiry(
            page_offset, total_length, ref, terminated_merchant_list)
        termination_inquiry.transaction_reference_number = transaction_reference_number
        return termination_inquiry
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()

        page_offset = xml_response.find('PageOffset').text
        total_count = xml_response.find('TotalCount').text

        atm_list = list()
        for xml_atm in xml_response.findall('.//Atm'):
            tmp_atm = atm.Atm()
            tmp_atm.handicap_accessible = none_check.verify_not_none(
                xml_atm.find('HandicapAccessable'))
            tmp_atm.camera = none_check.verify_not_none(xml_atm.find('Camera'))
            tmp_atm.availability = none_check.verify_not_none(
                xml_atm.find('Availability'))
            tmp_atm.access_fees = none_check.verify_not_none(
                xml_atm.find('AccessFees'))
            tmp_atm.owner = none_check.verify_not_none(xml_atm.find('Owner'))
            tmp_atm.shared_deposit = none_check.verify_not_none(
                xml_atm.find('SharedDeposit'))
            tmp_atm.surcharge_free_alliance = none_check.verify_not_none(
                xml_atm.find('SurchargeFreeAlliance'))
            tmp_atm.sponsor = none_check.verify_not_none(
                xml_atm.find('Sponsor'))
            tmp_atm.support_emv = none_check.verify_not_none(
                xml_atm.find('SupportEMV'))
            tmp_atm.surcharge_free_alliance_network = none_check.verify_not_none(
                xml_atm.find('SurchargeFreeAllianceNetwork'))

            xml_location = xml_atm.find('Location')
            tmp_location = location.Location()
            tmp_location.name = none_check.verify_not_none(
                xml_location.find('Name'))
            tmp_location.distance = none_check.verify_not_none(
                xml_location.find('Distance'))
            tmp_location.distance_unit = none_check.verify_not_none(
                xml_location.find('DistanceUnit'))

            xml_address = xml_location.find('Address')
            tmp_address = address.Address()
            tmp_address.line1 = none_check.verify_not_none(
                xml_address.find('Line1'))
            tmp_address.line2 = none_check.verify_not_none(
                xml_address.find('Line2'))
            tmp_address.city = none_check.verify_not_none(
                xml_address.find('City'))
            tmp_address.postal_code = none_check.verify_not_none(
                xml_address.find('PostalCode'))

            tmp_country = country.Country(
                none_check.verify_not_none(xml_address.find('Country/Name')),
                none_check.verify_not_none(xml_address.find('Country/Code')))

            tmp_country_subdivision = countrysubdivision.CountrySubdivision(
                none_check.verify_not_none(
                    xml_address.find('CountrySubdivision/Name')),
                none_check.verify_not_none(
                    xml_address.find('CountrySubdivision/Code')))

            tmp_address.country = tmp_country
            tmp_address.country_subdivision = tmp_country_subdivision

            xml_point = xml_location.find('Point')
            tmp_point = point.Point(
                none_check.verify_not_none(xml_point.find('Latitude')),
                none_check.verify_not_none(xml_point.find('Longitude')))

            tmp_location.point = tmp_point
            tmp_location.address = tmp_address
            tmp_atm.location = tmp_location

            atm_list.append(tmp_atm)
        atms_ = atms.Atms(page_offset, total_count, atm_list)
        return atms_
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()
        pan_eligibility = paneligibility.PanEligibility()
        pan_eligibility.request_id = none_check.verify_not_none(
            xml_response.find('RequestId'))
        if xml_response.find('SendingEligibility') is not None:
            tmp_sending_eligibility = sendingeligibility.SendingEligibility()
            xml_sending_eligibility = xml_response.find('SendingEligibility')
            tmp_sending_eligibility.eligible = none_check.verify_not_none(
                xml_sending_eligibility.find('Eligible'))
            tmp_sending_eligibility.reason_code = none_check.verify_not_none(
                xml_sending_eligibility.find('ReasonCode'))
            tmp_sending_eligibility.account_number = none_check.verify_not_none(
                xml_sending_eligibility.find('AccountNumber'))
            tmp_sending_eligibility.ica = none_check.verify_not_none(
                xml_sending_eligibility.find('ICA'))

            if xml_sending_eligibility.find('Currency') is not None:
                tmp_currency = currency.Currency()
                xml_currency = xml_sending_eligibility.find('Currency')
                tmp_currency.alpha_currency_code = none_check.verify_not_none(
                    xml_currency.find('AlphaCurrencyCode'))
                tmp_currency.numeric_currency_code = none_check.verify_not_none(
                    xml_currency.find('NumericCurrencyCode'))
                tmp_sending_eligibility.currency = tmp_currency

            if xml_sending_eligibility.find('Country') is not None:
                tmp_country = country.Country()
                xml_country = xml_sending_eligibility.find('Country')
                tmp_country.alpha_country_code = none_check.verify_not_none(
                    xml_country.find('AlphaCountryCode'))
                tmp_country.numeric_country_code = none_check.verify_not_none(
                    xml_country.find('NumericCountryCode'))
                tmp_sending_eligibility.country = tmp_country

            if xml_sending_eligibility.find('Brand') is not None:
                tmp_brand = brand.Brand()
                xml_brand = xml_sending_eligibility.find('Brand')
                tmp_brand.acceptance_brand_code_code = none_check.verify_not_none(
                    xml_brand.find('AcceptanceBrandCode'))
                tmp_brand.numeric_country_code = none_check.verify_not_none(
                    xml_brand.find('ProductBrandCode'))
                tmp_sending_eligibility.brand = tmp_brand

            pan_eligibility.sending_eligibility = tmp_sending_eligibility

        if xml_response.find('ReceivingEligibility') is not None:
            tmp_receiving_eligibility = receivingeligibility.ReceivingEligibility(
            )
            xml_receiving_eligibility = xml_response.find(
                'ReceivingEligibility')
            tmp_receiving_eligibility.eligible = none_check.verify_not_none(
                xml_receiving_eligibility.find('Eligible'))
            tmp_receiving_eligibility.reason_code = none_check.verify_not_none(
                xml_receiving_eligibility.find('ReasonCode'))
            tmp_receiving_eligibility.account_number = none_check.verify_not_none(
                xml_receiving_eligibility.find('AccountNumber'))
            tmp_receiving_eligibility.ica = none_check.verify_not_none(
                xml_receiving_eligibility.find('ICA'))

            if xml_receiving_eligibility.find('Currency') is not None:
                tmp_currency = currency.Currency()
                xml_currency = xml_receiving_eligibility.find('Currency')
                tmp_currency.alpha_currency_code = none_check.verify_not_none(
                    xml_currency.find('AlphaCurrencyCode'))
                tmp_currency.numeric_currency_code = none_check.verify_not_none(
                    xml_currency.find('NumericCurrencyCode'))
                tmp_receiving_eligibility.currency = tmp_currency

            if xml_receiving_eligibility.find('Country') is not None:
                tmp_country = country.Country()
                xml_country = xml_receiving_eligibility.find('Country')
                tmp_country.alpha_country_code = none_check.verify_not_none(
                    xml_country.find('AlphaCountryCode'))
                tmp_country.numeric_country_code = none_check.verify_not_none(
                    xml_country.find('NumericCountryCode'))
                tmp_receiving_eligibility.country = tmp_country

            if xml_receiving_eligibility.find('Brand') is not None:
                tmp_brand = brand.Brand()
                xml_brand = xml_receiving_eligibility.find('Brand')
                tmp_brand.acceptance_brand_code_code = none_check.verify_not_none(
                    xml_brand.find('AcceptanceBrandCode'))
                tmp_brand.numeric_country_code = none_check.verify_not_none(
                    xml_brand.find('ProductBrandCode'))
                tmp_receiving_eligibility.brand = tmp_brand

            pan_eligibility.receiving_eligibility = tmp_receiving_eligibility

        return pan_eligibility
Example #11
0
    def generate_return_object(self, xml_response):
        none_check = xmlutil.XMLUtil()

        page_offset = xml_response.find('PageOffset').text
        total_count = xml_response.find('TotalCount').text

        restaurant_list = list()
        for xml_restaurant in xml_response.findall('.//Restaurant'):
            tmp_restaurant = restaurant.Restaurant()
            tmp_restaurant.id = none_check.verify_not_none(
                xml_restaurant.find('Id'))
            tmp_restaurant.name = none_check.verify_not_none(
                xml_restaurant.find('Name'))
            tmp_restaurant.website_url = none_check.verify_not_none(
                xml_restaurant.find('WebsiteUrl'))
            tmp_restaurant.phone_number = none_check.verify_not_none(
                xml_restaurant.find('PhoneNumber'))
            tmp_restaurant.category = none_check.verify_not_none(
                xml_restaurant.find('Category'))
            tmp_restaurant.local_favorite_ind = none_check.verify_not_none(
                xml_restaurant.find('LocalFavoriteInd'))
            tmp_restaurant.hidden_gem_ind = none_check.verify_not_none(
                xml_restaurant.find('HiddenGemInd'))

            xml_location = xml_restaurant.find('Location')
            tmp_location = location.Location()
            tmp_location.name = none_check.verify_not_none(
                xml_location.find('Name'))
            tmp_location.distance = none_check.verify_not_none(
                xml_location.find('Distance'))
            tmp_location.distance_unit = none_check.verify_not_none(
                xml_location.find('DistanceUnit'))

            xml_address = xml_location.find('Address')
            tmp_address = address.Address()
            tmp_address.line1 = none_check.verify_not_none(
                xml_address.find('Line1'))
            tmp_address.line2 = none_check.verify_not_none(
                xml_address.find('Line2'))
            tmp_address.city = none_check.verify_not_none(
                xml_address.find('City'))
            tmp_address.postal_code = none_check.verify_not_none(
                xml_address.find('PostalCode'))

            tmp_country = country.Country(
                none_check.verify_not_none(xml_address.find('Country/Name')),
                none_check.verify_not_none(xml_address.find('Country/Code')))

            tmp_country_subdivision = countrysubdivision.CountrySubdivision(
                none_check.verify_not_none(
                    xml_address.find('CountrySubdivision/Name')),
                none_check.verify_not_none(
                    xml_address.find('CountrySubdivision/Code')))

            tmp_address.country = tmp_country
            tmp_address.country_subdivision = tmp_country_subdivision

            xml_point = xml_location.find('Point')
            tmp_point = point.Point(
                none_check.verify_not_none(xml_point.find('Latitude')),
                none_check.verify_not_none(xml_point.find('Longitude')))

            tmp_location.point = tmp_point
            tmp_location.address = tmp_address
            tmp_restaurant.location = tmp_location

            restaurant_list.append(tmp_restaurant)
        restaurants_ = restaurants.Restaurants(page_offset, total_count,
                                               restaurant_list)
        return restaurants_