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

Commit

Permalink
Feature/documentar bankaccount (#111)
Browse files Browse the repository at this point in the history
* Subindo estado atual

* Muda list_bank_accounts para list_bank_accounts_by_seller

* Adiciona exemplos de create, list e delete de BankAccount

* Adiciona na documentação exemplos de BankAccount

* Formatação

* fmt

* Corrige testes de list_bank_accounts_by_seller

* Update examples/bank_account/bank_account_create.py

Confiando que não vai quebrar nada.

Co-authored-by: Rodrigo Castro <rodrigondec@gmail.com>

* Update examples/bank_account/bank_account_remove.py

Co-authored-by: Rodrigo Castro <rodrigondec@gmail.com>

* Adiciona docstring

Co-authored-by: Rodrigo Castro <rodrigondec@gmail.com>
  • Loading branch information
PedroRegisPOAR and rodrigondec authored Oct 13, 2020
1 parent 415ec12 commit b7f4513
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 5 deletions.
14 changes: 14 additions & 0 deletions docs/examples/bank_account.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Exemplos de conta bancária
========================================

Criar conta bancária
-----------------------------------------
.. literalinclude:: ../../examples/bank_account/bank_account_create.py

Lista as contas bancárias de um vendedor
-----------------------------------------
.. literalinclude:: ../../examples/bank_account/bank_account_list.py

Remover a conta bancária de um vendedor
-----------------------------------------
.. literalinclude:: ../../examples/bank_account/bank_account_delete.py
Empty file.
30 changes: 30 additions & 0 deletions examples/bank_account/bank_account_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os

from zoop_wrapper import ZoopWrapper, BankAccount
from examples.utils import dump_response


"""
Nesse momento as constantes podem ser criadas no arquivo .py.
Mas é recomendado utilizar como variável de ambiente em um '.env'
"""
from zoop_wrapper.constants import MARKETPLACE_ID, ZOOP_KEY


client = ZoopWrapper(marketplace_id=MARKETPLACE_ID, key=ZOOP_KEY)

seller_brian = "0b05a360f4b749498f74e13004c08024"
brian = client.retrieve_seller(seller_brian)

ba = {
"account_number": "123",
"bank_code": "237",
"holder_name": "Algum Nome",
"routing_number": "foo",
"taxpayer_id": brian.instance.taxpayer_id,
"type": BankAccount.SAVING_TYPE,
}

response = client.add_bank_account(ba)

dump_response(response, os.path.basename(__file__).split(".")[0])
19 changes: 19 additions & 0 deletions examples/bank_account/bank_account_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

from zoop_wrapper import ZoopWrapper
from examples.utils import dump_response

"""
Nesse momento as constantes podem ser criadas no arquivo .py.
Mas é recomendado utilizar como variável de ambiente em um '.env'
"""
from zoop_wrapper.constants import MARKETPLACE_ID, ZOOP_KEY


client = ZoopWrapper(marketplace_id=MARKETPLACE_ID, key=ZOOP_KEY)

seller_brian = "0b05a360f4b749498f74e13004c08024"

response = client.list_bank_accounts_by_seller(seller_brian)

dump_response(response, os.path.basename(__file__).split(".")[0])
19 changes: 19 additions & 0 deletions examples/bank_account/bank_account_remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

from zoop_wrapper import ZoopWrapper
from examples.utils import dump_response


"""
Nesse momento as constantes podem ser criadas no arquivo .py.
Mas é recomendado utilizar como variável de ambiente em um '.env'
"""
from zoop_wrapper.constants import MARKETPLACE_ID, ZOOP_KEY


client = ZoopWrapper(marketplace_id=MARKETPLACE_ID, key=ZOOP_KEY)


response = client.remove_bank_account("e85edf6d0add48339e3d8189f615c3b1")

dump_response(response, os.path.basename(__file__).split(".")[0])
30 changes: 30 additions & 0 deletions examples/data/bank_account_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "e85edf6d0add48339e3d8189f615c3b1",
"resource": "bank_account",
"holder_name": "Algum Nome",
"taxpayer_id": "94998862499",
"description": null,
"bank_name": "Banco Bradesco S.A.",
"bank_code": "237",
"type": "Savings",
"account_number": "123",
"country_code": "BR",
"routing_number": "foo",
"routing_check_digit": null,
"phone_number": null,
"is_active": true,
"is_verified": false,
"debitable": false,
"customer": "0b05a360f4b749498f74e13004c08024",
"fingerprint": "5415ba4927cb5cec4aa4dfd309a4f6813b5f2644423533ffb2d245713a285a61",
"address": null,
"verification_checklist": {
"postal_code_check": "unchecked",
"address_line1_check": "unchecked",
"deposit_check": "unchecked"
},
"metadata": {},
"uri": "/v1/marketplaces/foo/bank_accounts/e85edf6d0add48339e3d8189f615c3b1",
"created_at": "2020-10-09T19:54:56+00:00",
"updated_at": "2020-10-09T19:54:57+00:00"
}
42 changes: 42 additions & 0 deletions examples/data/bank_account_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"resource": "list",
"uri": "/v1/marketplaces/foo/sellers/0b05a360f4b749498f74e13004c08024/bank_accounts?limit=100&offset=0",
"items": [
{
"id": "682cd3a336124ca1a9a891195960c16e",
"resource": "bank_account",
"holder_name": "Algum Nome",
"taxpayer_id": "94998862499",
"description": null,
"bank_name": "Banco Bradesco S.A.",
"bank_code": "237",
"type": "Savings",
"last4_digits": "123",
"account_number": "123",
"country_code": "BR",
"routing_number": "foo",
"routing_check_digit": null,
"phone_number": null,
"is_active": true,
"is_verified": false,
"debitable": false,
"customer": "0b05a360f4b749498f74e13004c08024",
"fingerprint": "5415ba4927cb5cec4aa4dfd309a4f6813b5f2644423533ffb2d245713a285a61",
"address": null,
"verification_checklist": {
"postal_code_check": "unchecked",
"address_line1_check": "unchecked",
"deposit_check": "unchecked"
},
"metadata": {},
"uri": "/v1/marketplaces/foo/bank_accounts/682cd3a336124ca1a9a891195960c16e",
"created_at": "2020-10-09T19:50:37+00:00",
"updated_at": "2020-10-09T19:50:37+00:00"
}
],
"limit": 100,
"offset": 0,
"has_more": false,
"query_count": 0,
"total": 4
}
5 changes: 5 additions & 0 deletions examples/data/bank_account_remove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "e85edf6d0add48339e3d8189f615c3b1",
"resource": "bank_account",
"deleted": true
}
6 changes: 4 additions & 2 deletions tests/wrapper/test_bank_accounts_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ def test_list_bank_accounts(self):
"""
Test list_bank_accounts method.
"""
self.set_get_mock(200, {"items": [IndividualBankAccountFactory().to_dict()]})
response = self.client.list_bank_accounts()
self.set_get_mock(
200, {"items": [IndividualBankAccountFactory(id="foo").to_dict()]}
)
response = self.client.list_bank_accounts_by_seller("foo")
self.assertEqual(response.status_code, 200, msg=response.data)
items = response.data.get("items")
self.assertTrue(items)
Expand Down
2 changes: 1 addition & 1 deletion tests/wrapper/test_card_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_retrieve_card(self):
"""
self.set_get_mock(200, CardFactory(id="foo").to_dict())

response = self.client.list_bank_accounts()
response = self.client.list_bank_accounts_by_seller("foo")
self.assertEqual(response.status_code, 200, msg=response.data)
self.assertEqual(response.data.get("id"), "foo")
self.assertIsInstance(response.instance, Card)
Expand Down
20 changes: 18 additions & 2 deletions zoop_wrapper/wrapper/bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ class BankAccountWrapper(BaseZoopWrapper):
Essa classe precisa de métodos presentes em outro wrapper
"""

def list_bank_accounts(self):
def list_bank_accounts_by_seller(self, identifier):
"""
Lista todas as :class:`.BankAccount`'s.
Returns:
response with instances of :class:`.BankAccount`
"""
url = self._construct_url(action="bank_accounts")
url = self._construct_url(
action="sellers", identifier=identifier, subaction="bank_accounts"
)
return self._get(url)

def retrieve_bank_account(self, identifier):
Expand Down Expand Up @@ -89,3 +91,17 @@ def add_bank_account(self, data: dict):

url = self._construct_url(action="bank_accounts")
return self._post(url, data=data)

def remove_bank_account(self, identifier: str):
"""
Remove todas as :class:`.BankAccount` de um
:class:`.Seller` usando o `identifier` deste.
Args:
identifier: uuid id
Returns:
:class:`.ZoopResponse`
"""
url = self._construct_url(action="bank_accounts", identifier=identifier)
return self._delete(url)

0 comments on commit b7f4513

Please sign in to comment.