<commit_before>from beanstream import transaction, utilities
from beanstream.response_codes import response_codes


class RecurringBillingNotification(transaction.Response):

    def __init__(self, *args, **kwargs):
        super(RecurringBillingNotification, self).__init__(*args, **kwargs)

        # listify things if they aren't already listified.
        self.resp = dict((k, [v]) if type(v) != list else (k, v) for k, v in self.resp.iteritems())

    def account_id(self):
        return self.resp.get('billingId', [None])[0]

    def approved(self):
        return self.resp.get('trnApproved', ['0'])[0] == '1'

    def transaction_id(self):
        return self.resp.get('trnId', [None])[0]

    def get_cardholder_message(self):
        if 'messageId' in self.resp:
            return response_codes[self.resp['messageId'][0]]['cardholder_message']
        else:
            return None

    def get_merchant_message(self):
        if 'messageId' in self.resp:
            return response_codes[self.resp['messageId'][0]]['merchant_message']
        else:
            return None

    def auth_code(self):
        return self.resp.get('authCode', [None])[0]

    def name(self):
        return self.resp.get('accountName', [None])[0]

    def email(self):
        return self.resp.get('emailAddress', [None])[0]

    def billing_amount(self):
        return self.resp.get('billingAmount', [None])[0]

    def billing_date(self):
        return self.resp.get('billingDate', [None])[0]

    def billing_period(self):
        return self.resp.get('billingPeriod', [None])[0]

    def billing_increment(self):
        return self.resp.get('billingIncrement', [None])[0]

    def period_from(self):
        if 'periodFrom' in self.resp:
            return utilities.process_date(self.resp['periodFrom'][0])
        else:
            return None

    def period_to(self):
        if 'periodTo' in self.resp:
            return utilities.process_date(self.resp['periodTo'][0])
        else:
            return None<commit_msg>process billing date as a date object, too<commit_after>from beanstream import transaction, utilities
from beanstream.response_codes import response_codes


class RecurringBillingNotification(transaction.Response):

    def __init__(self, *args, **kwargs):
        super(RecurringBillingNotification, self).__init__(*args, **kwargs)

        # listify things if they aren't already listified.
        self.resp = dict((k, [v]) if type(v) != list else (k, v) for k, v in self.resp.iteritems())

    def account_id(self):
        return self.resp.get('billingId', [None])[0]

    def approved(self):
        return self.resp.get('trnApproved', ['0'])[0] == '1'

    def transaction_id(self):
        return self.resp.get('trnId', [None])[0]

    def get_cardholder_message(self):
        if 'messageId' in self.resp:
            return response_codes[self.resp['messageId'][0]]['cardholder_message']
        else:
            return None

    def get_merchant_message(self):
        if 'messageId' in self.resp:
            return response_codes[self.resp['messageId'][0]]['merchant_message']
        else:
            return None

    def auth_code(self):
        return self.resp.get('authCode', [None])[0]

    def name(self):
        return self.resp.get('accountName', [None])[0]

    def email(self):
        return self.resp.get('emailAddress', [None])[0]

    def billing_amount(self):
        return self.resp.get('billingAmount', [None])[0]

    def billing_date(self):
        if 'billingDate' in self.resp:
            return utilities.process_date(self.resp['billingDate'][0])
        else:
            return None

    def billing_period(self):
        return self.resp.get('billingPeriod', [None])[0]

    def billing_increment(self):
        return self.resp.get('billingIncrement', [None])[0]

    def period_from(self):
        if 'periodFrom' in self.resp:
            return utilities.process_date(self.resp['periodFrom'][0])
        else:
            return None

    def period_to(self):
        if 'periodTo' in self.resp:
            return utilities.process_date(self.resp['periodTo'][0])
        else:
            return None
{'fraction_non_alphanumeric': 0.13290229885057472, 'fraction_numerical': 0.007662835249042145, 'mean_word_length': 2.871177015755329, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1523935', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1256, 'n_words': 280}