Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
adiciona bank_account (#19)
Browse files Browse the repository at this point in the history
* adiciona bank_account

* fmt

* sobe bdd's

* fmt
  • Loading branch information
rodrigondec authored Oct 22, 2020
1 parent 349b624 commit f46e4fb
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 0 deletions.
Empty file.
16 changes: 16 additions & 0 deletions examples/bank_account/create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from imopay_wrapper import ImopayWrapper


client = ImopayWrapper()

data = {
"owner": "ID_DO_SELLER",
"bank": "001",
"type": "corrente",
"number": "123123",
"routing": "45678",
}

response = client.bank_account.create(data)

print(response.data)
10 changes: 10 additions & 0 deletions examples/bank_account/destroy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from imopay_wrapper import ImopayWrapper


client = ImopayWrapper()

imopay_id = "foo"

response = client.bank_account.destroy(imopay_id)

print(response.data)
10 changes: 10 additions & 0 deletions examples/bank_account/retrieve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from imopay_wrapper import ImopayWrapper


client = ImopayWrapper()

imopay_id = "foo"

response = client.bank_account.retrieve(imopay_id)

print(response.data)
18 changes: 18 additions & 0 deletions imopay_wrapper/models/bank_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from dataclasses import dataclass

from .base import BaseImopayObj
from ..validators import validate_obj_attr_in_collection


@dataclass
class BankAccount(BaseImopayObj):
owner: str
bank: str
number: str
routing: str
type: str

VALID_TYPES = {"poupança", "corrente"}

def _validate_type(self):
validate_obj_attr_in_collection(self, "type", self.VALID_TYPES)
2 changes: 2 additions & 0 deletions imopay_wrapper/wrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .address import AddressWrapper
from .bank_account import BankAccountWrapper
from .company import CompanyWrapper
from .person import PersonWrapper
from .transaction import TransactionWrapper
Expand All @@ -8,6 +9,7 @@
class ImopayWrapper:
def __init__(self, *args, **kwargs):
self.address = AddressWrapper(*args, **kwargs)
self.bank_account = BankAccountWrapper(*args, **kwargs)
self.company = CompanyWrapper(*args, **kwargs)
self.person = PersonWrapper(*args, **kwargs)
self.transaction = TransactionWrapper(*args, **kwargs)
Expand Down
16 changes: 16 additions & 0 deletions imopay_wrapper/wrapper/bank_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from .base import BaseImopayWrapper, CreateMixin, RetrieveMixin, DestroyMixin
from ..models.bank_account import BankAccount


class BankAccountWrapper(BaseImopayWrapper, CreateMixin, RetrieveMixin, DestroyMixin):
"""
Wrapper para os métodos de contas bancárias
"""

@property
def action(self):
return "bank_accounts"

@property
def model(self):
return BankAccount
42 changes: 42 additions & 0 deletions tests/wrapper/test_bank_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from ..utils import LocalImopayTestCase
from imopay_wrapper import ImopayWrapper
from imopay_wrapper.wrapper.base import CreateMixin, RetrieveMixin, DestroyMixin
from imopay_wrapper.models.bank_account import BankAccount


class BankAccountWrapperTestCase(LocalImopayTestCase):
def setUp(self):
self.client = ImopayWrapper().bank_account

def test_mixins(self):
"""
Dado:
- um client ImopayWrapper().bank_account
Quando:
- N/A
Então:
- client deve ser uma instância de (CreateMixin, RetrieveMixin, DestroyMixin) # noqa
"""
self.assertIsInstance(self.client, (CreateMixin, RetrieveMixin, DestroyMixin))

def test_model(self):
"""
Dado:
- um client ImopayWrapper().bank_account
Quando:
- N/A
Então:
- client.model deve ser BankAccount
"""
self.assertEqual(self.client.model, BankAccount)

def test_action(self):
"""
Dado:
- um client ImopayWrapper().bank_account
Quando:
- N/A
Então:
- client.action deve ser 'bank_accounts'
"""
self.assertEqual(self.client.action, "bank_accounts")

0 comments on commit f46e4fb

Please sign in to comment.