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

Commit

Permalink
Feature/use homolog instead sandbox (#81)
Browse files Browse the repository at this point in the history
* Update deps

* Update brcode because crc was updated

* Update url to use homolog instead sandbox

* Update docs

* Number should be string

* Fix tests

* Generate new data test
  • Loading branch information
jgdsfilho authored Dec 30, 2024
1 parent 64eed7b commit 88f3074
Show file tree
Hide file tree
Showing 11 changed files with 577 additions and 478 deletions.
6 changes: 3 additions & 3 deletions bb_wrapper/services/brcode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from crc import CrcCalculator, Configuration
from crc import Calculator, Configuration


class BRCodeService:
Expand Down Expand Up @@ -56,8 +56,8 @@ def crc_16_ccitt_ffff(self, data: str):
reverse_input=False,
reverse_output=False,
)
crc_calculator = CrcCalculator(crc_configuration)
crc_calculator = Calculator(crc_configuration)
data_to_encode = bytes(data, encoding="utf-8")
crc_value = crc_calculator.calculate_checksum(data_to_encode)
crc_value = crc_calculator.checksum(data_to_encode)
crc_value = str(hex(crc_value))[2:].upper()
return crc_value
2 changes: 1 addition & 1 deletion bb_wrapper/wrapper/cobrancas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class CobrancasBBWrapper(BaseBBWrapper):
SCOPE = "cobrancas.boletos-info cobrancas.boletos-requisicao"

SANDBOX_BASE_URL = "https://api.sandbox.bb.com.br/cobrancas/v2/boletos"
SANDBOX_BASE_URL = "https://api.hm.bb.com.br/cobrancas/v2/boletos"
BASE_URL = "https://api.bb.com.br/cobrancas/v2/boletos"

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion bb_wrapper/wrapper/pagamento_lote.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PagamentoLoteBBWrapper(BaseBBWrapper):
"""

SCOPE = "pagamentos-lote.lotes-requisicao pagamentos-lote.transferencias-info pagamentos-lote.transferencias-requisicao pagamentos-lote.cancelar-requisicao pagamentos-lote.devolvidos-info pagamentos-lote.lotes-info pagamentos-lote.pagamentos-guias-sem-codigo-barras-info pagamentos-lote.pagamentos-info pagamentos-lote.pagamentos-guias-sem-codigo-barras-requisicao pagamentos-lote.pagamentos-codigo-barras-info pagamentos-lote.boletos-requisicao pagamentos-lote.guias-codigo-barras-info pagamentos-lote.guias-codigo-barras-requisicao pagamentos-lote.transferencias-pix-info pagamentos-lote.transferencias-pix-requisicao pagamentos-lote.pix-info pagamentos-lote.boletos-info" # noqa
SANDBOX_BASE_URL = "https://api.sandbox.bb.com.br/pagamentos-lote/v1"
SANDBOX_BASE_URL = "https://api.hm.bb.com.br/pagamentos-lote/v1"
BASE_URL = "https://api-ip.bb.com.br/pagamentos-lote/v1"

def _valida_lote_data(self, model, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion docs/bb/API_Cobranca_postman_collection_e7409199cc.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
]
},
"url": {
"raw": "https://oauth.sandbox.bb.com.br/oauth/token?",
"raw": "https://oauth.hm.bb.com.br/oauth/token?",
"protocol": "https",
"host": [
"oauth",
Expand Down
2 changes: 1 addition & 1 deletion docs/pix/swagger pix.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
"type": "oauth2",
"flows": {
"clientCredentials": {
"tokenUrl": "https://oauth.sandbox.bb.com.br/oauth/token",
"tokenUrl": "https://oauth.hm.bb.com.br/oauth/token",
"scopes": {
"cob.write": "Permissão para alteração de cobranças",
"cob.read": "Permissão para consulta de cobranças",
Expand Down
31 changes: 16 additions & 15 deletions examples/cobranças/data/registra_boleto_1.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/cobranças/registra_boleto_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

wrapper = CobrancasBBWrapper()

number = 9999999983
number = "9999999984"
today = date.today()
bb_fmt = "%d.%m.%Y"

Expand Down
976 changes: 538 additions & 438 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,25 @@ classifiers = [
include = []

[tool.poetry.dependencies]
python = ">= 3.8, < 3.10"
requests = "^2.26.0"
python = ">= 3.9, < 3.12"
requests = "^2.32.3"
python-decouple = "^3.4"
pydantic = ">=2.0.0"
python-barcode = "^0.15.1"
Unidecode = "^1.2.0"
qrcode = "^7.3"
crc = "^1.0.1"
qrcode = "^8.0"
crc = "^7.1.0"
pycpfcnpj = "^1.5.1"
pillow = ">=9.5.0,<=10.3.0"
pillow = "11.0.0"

[tool.poetry.dev-dependencies]
flake8 = "^3.9.2"
black = "^22.3.0"
coverage = {extras = ["toml"], version = "^5.5"}
flake8 = "^7.1.1"
black = "^24.10.0"
coverage = {extras = ["toml"], version = "7.6.10"}
isort = "^5.9.2"
freezegun = "^1.1.0"
responses = "^0.21.0"
py-bdd-context = ">=0.0.2"
responses = "^0.25.3"
py-bdd-context = ">=0.0.4"

[tool.poetry.scripts]

Expand Down
8 changes: 3 additions & 5 deletions tests/wrapper/test_cobrancas.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ def test_build_url(self):
- for chamado wrapper._construct_url()
Então:
- o resultado deve ser
"https://api.sandbox.bb.com.br/cobrancas/v2/boletos"
"https://api.hm.bb.com.br/cobrancas/v2/boletos"
f"?gw-dev-app-key={GW_APP_KEY}"
"""
wrapper = CobrancasBBWrapper()
result = wrapper._construct_url()

expected = (
"https://api.sandbox.bb.com.br/cobrancas/v2/boletos"
"https://api.hm.bb.com.br/cobrancas/v2/boletos"
f"?gw-dev-app-key={wrapper._gw_app_key}"
)

Expand Down Expand Up @@ -295,8 +295,6 @@ def test_construct_url_1(self):
"""
result = CobrancasBBWrapper()._construct_url(end_bar=True)

expected = (
"https://api.sandbox.bb.com.br/cobrancas/v2/boletos/?gw-dev-app-key=KEY"
)
expected = "https://api.hm.bb.com.br/cobrancas/v2/boletos/?gw-dev-app-key=KEY"

self.assertIn(expected, result)
4 changes: 2 additions & 2 deletions tests/wrapper/test_pagamentos.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def test_construct_url_1(self):
- for chamado PagamentoLoteBBWrapper()._construct_url(end_bar=True)
Então:
- o resultado deve ter pelo menos o texto
'https://api.sandbox.bb.com.br/pagamentos-lote/v1/?gw-dev-app-key='
'https://api.hm.bb.com.br/pagamentos-lote/v1/?gw-dev-app-key='
"""
result = PagamentoLoteBBWrapper()._construct_url(end_bar=True)

expected = (
f"https://api.sandbox.bb.com.br/pagamentos-lote/v1/"
f"https://api.hm.bb.com.br/pagamentos-lote/v1/"
f"?gw-dev-app-key={PagamentoLoteBBWrapper()._gw_app_key}"
)

Expand Down

0 comments on commit 88f3074

Please sign in to comment.