Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit f59ddc5

Browse files
committed
adiciona valores bancários como opcionais
1 parent c2ff8f4 commit f59ddc5

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
lines changed

bb_wrapper/models/pagamentos.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class TipoChavePIX(IntEnum):
3737
uuid = 4
3838

3939

40+
class TipoContaPIX(IntEnum):
41+
"""
42+
1: Conta do tipo corrente
43+
2: Conta do tipo pagamento
44+
3: Conta do tipo poupança
45+
"""
46+
47+
conta_corrente = 1
48+
conta_pagamento = 3
49+
conta_poupanca = 3
50+
51+
4052
class FinalidadeTED(IntEnum):
4153
"""
4254
1: Conta corrente outros bancos
@@ -100,10 +112,10 @@ class TransferenciaDadosBancariosPIX(BaseModel):
100112
data: str
101113
valor: float
102114
documento: str
103-
tipoConta: str
104-
agencia: str
105-
conta: str
106-
digitoVerificadorConta: str
115+
tipoConta: TipoContaPIX
116+
agencia: Optional[str]
117+
conta: Optional[str]
118+
digitoVerificadorConta: Optional[str]
107119
formaIdentificacao: Optional[str]
108120
descricaoPagamento: Optional[str]
109121
cpf: Optional[str]

bb_wrapper/wrapper/pagamento_lote.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,10 @@ def criar_transferencia_por_dados_bancarios_pix(
617617
data_transferencia,
618618
valor_transferencia,
619619
tipo_conta_favorecido,
620-
agencia_favorecido,
621-
conta_favorecido,
622-
digito_verificador_conta,
623620
numero_ispb,
621+
agencia_favorecido=None,
622+
conta_favorecido=None,
623+
digito_verificador_conta=None,
624624
conta_pagamento=None,
625625
descricao="",
626626
tipo_pagamento=128,

tests/wrapper/test_pagamentos.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,63 @@ def test_criar_transferencia_pix_dados_bancarios(self):
10181018
self.assertEqual(2, self.total_requests())
10191019
self.mock_responses.assert_call_count(request_url, 1)
10201020

1021+
def test_criar_transferencia_pix_dados_bancarios2(self):
1022+
"""
1023+
Teste para verificar a URL da requisição e
1024+
dados de transferência PIX por dados bancarios
1025+
"""
1026+
1027+
request_url = PagamentoLoteBBWrapper()._construct_url(
1028+
"lotes-transferencias-pix"
1029+
)
1030+
1031+
expected_json = {
1032+
"numeroRequisicao": "123",
1033+
"agenciaDebito": "345",
1034+
"contaCorrenteDebito": "678",
1035+
"digitoVerificadorContaCorrente": "X",
1036+
"tipoPagamento": 128,
1037+
"listaTransferencias": [
1038+
{
1039+
"data": "19042023",
1040+
"valor": "50",
1041+
"descricaoPagamento": "Uma transferência via dados bancários",
1042+
"formaIdentificacao": 5,
1043+
"tipoConta": 1,
1044+
"contaPagamento": 12345678,
1045+
"numeroISPB": "360305",
1046+
"cpf": "28779295827",
1047+
}
1048+
],
1049+
}
1050+
1051+
self.mock_responses.add(
1052+
responses.POST,
1053+
request_url,
1054+
headers=self._build_authorization_header(1),
1055+
json=expected_json,
1056+
)
1057+
1058+
response = PagamentoLoteBBWrapper().criar_transferencia_por_dados_bancarios_pix(
1059+
n_requisicao="123",
1060+
agencia="345",
1061+
conta="678",
1062+
dv_conta="X",
1063+
data_transferencia="19042023",
1064+
valor_transferencia=12,
1065+
tipo_conta_favorecido=1,
1066+
conta_pagamento=12345678,
1067+
numero_ispb="360305",
1068+
descricao="Uma transferência via dados bancários",
1069+
documento="28779295827",
1070+
)
1071+
1072+
self.assertEqual(request_url, response.url)
1073+
self.assertEqual(self._get_headers(), response.headers)
1074+
self.assertEqual(expected_json, response.json())
1075+
self.assertEqual(2, self.total_requests())
1076+
self.mock_responses.assert_call_count(request_url, 1)
1077+
10211078
def test_consultar_pix(self):
10221079
"""
10231080
- Teste para consultar um pix de um determinado lote

0 commit comments

Comments
 (0)