# encoding: utf-8

import json
import requests

from .exceptions import PagarmeApiError

class AbstractResource(object):
    def __init__(self):
        raise NotImplementedError

    def handle_response(self, data):
        self.data.update(data)

    def error(self, response):
        data = json.loads(response)
        e = data['errors'][0]
        error_string = e['type'] + ' - ' + e['message']
        raise PagarmeApiError(error_string)

    def create(self):
        url = self.BASE_URL
        pagarme_response = requests.post(url, data=self.get_data())
        if pagarme_response.status_code == 200:
            self.handle_response(json.loads(pagarme_response.content))
        else:
            self.error(pagarme_response.content)

    def get_data(self):
        return self.data

f4e827b8faf274c66856af18aa342269afc6b8f2
<mask token>


class AbstractResource(object):
    <mask token>

    def handle_response(self, data):
        self.data.update(data)

    def error(self, response):
        data = json.loads(response)
        e = data['errors'][0]
        error_string = e['type'] + ' - ' + e['message']
        raise PagarmeApiError(error_string)
    <mask token>

    def get_data(self):
        return self.data

<mask token>


class AbstractResource(object):

    def __init__(self):
        raise NotImplementedError

    def handle_response(self, data):
        self.data.update(data)

    def error(self, response):
        data = json.loads(response)
        e = data['errors'][0]
        error_string = e['type'] + ' - ' + e['message']
        raise PagarmeApiError(error_string)
    <mask token>

    def get_data(self):
        return self.data

<mask token>


class AbstractResource(object):

    def __init__(self):
        raise NotImplementedError

    def handle_response(self, data):
        self.data.update(data)

    def error(self, response):
        data = json.loads(response)
        e = data['errors'][0]
        error_string = e['type'] + ' - ' + e['message']
        raise PagarmeApiError(error_string)

    def create(self):
        url = self.BASE_URL
        pagarme_response = requests.post(url, data=self.get_data())
        if pagarme_response.status_code == 200:
            self.handle_response(json.loads(pagarme_response.content))
        else:
            self.error(pagarme_response.content)

    def get_data(self):
        return self.data

import json
import requests
from .exceptions import PagarmeApiError


class AbstractResource(object):

    def __init__(self):
        raise NotImplementedError

    def handle_response(self, data):
        self.data.update(data)

    def error(self, response):
        data = json.loads(response)
        e = data['errors'][0]
        error_string = e['type'] + ' - ' + e['message']
        raise PagarmeApiError(error_string)

    def create(self):
        url = self.BASE_URL
        pagarme_response = requests.post(url, data=self.get_data())
        if pagarme_response.status_code == 200:
            self.handle_response(json.loads(pagarme_response.content))
        else:
            self.error(pagarme_response.content)

    def get_data(self):
        return self.data

# encoding: utf-8

import json
import requests

from .exceptions import PagarmeApiError

class AbstractResource(object):
    def __init__(self):
        raise NotImplementedError

    def handle_response(self, data):
        self.data.update(data)

    def error(self, response):
        data = json.loads(response)
        e = data['errors'][0]
        error_string = e['type'] + ' - ' + e['message']
        raise PagarmeApiError(error_string)

    def create(self):
        url = self.BASE_URL
        pagarme_response = requests.post(url, data=self.get_data())
        if pagarme_response.status_code == 200:
            self.handle_response(json.loads(pagarme_response.content))
        else:
            self.error(pagarme_response.content)

    def get_data(self):
        return self.data
