Skip to content

Commit

Permalink
Merge pull request #4 from YuriAlessandro/develop
Browse files Browse the repository at this point in the history
Update master
  • Loading branch information
YuriAlessandro authored Nov 22, 2018
2 parents 1d25dd4 + 4fd124b commit 3137a76
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions pagarme_surfmappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from pagarme_surfmappers.utils import set_api_key
from pagarme_surfmappers.transaction import Transaction
from pagarme_surfmappers.bank import BankAccount
15 changes: 15 additions & 0 deletions pagarme_surfmappers/bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
import pagarme_surfmappers.constants as constants
import pagarme_surfmappers.utils as utils


class BankAccount(object):
def __init__(self):
super(BankAccount, self).__init__()

def create(self, data):
return utils.request_post(constants.CREATE_BANK_URL, data)

def get(self, bank_account_id):
url = constants.GET_BANK_URL.format(bank_account_id)
return utils.request_get(url)
4 changes: 4 additions & 0 deletions pagarme_surfmappers/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
BASE_URL = "https://api.pagar.me/1/"
# Transaction's URLs:
CREATE_TRANSACTION_URL = BASE_URL + "transactions"
CAPTURE_TRANSACTION_URL = BASE_URL + "transactions/{0}/capture"
# Bank's URLs:
CREATE_BANK_URL = BASE_URL + "bank_accounts"
GET_BANK_URL = BASE_URL + "bank_accounts/{0}"
4 changes: 2 additions & 2 deletions pagarme_surfmappers/transaction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import constants
import utils
import pagarme_surfmappers.constants as constants
import pagarme_surfmappers.utils as utils


class Transaction(object):
Expand Down
5 changes: 5 additions & 0 deletions pagarme_surfmappers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ def set_api_key(api_key):
def request_post(url, data, headers=headers()):
data['api_key'] = KEYS['api_key']
return requests.post(url, json=data, headers=headers)


def request_get(url, data={}, headers=headers()):
data['api_key'] = KEYS['api_key']
return requests.get(url)

0 comments on commit 3137a76

Please sign in to comment.