bb_api 0.5.2__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bb_api
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Wrapper da API do Banco do Brasil.
5
5
  Requires-Python: >=3.13
6
6
  Description-Content-Type: text/markdown
@@ -4,7 +4,7 @@ from importlib.metadata import PackageNotFoundError, version
4
4
  try:
5
5
  __version__ = version("bb_api")
6
6
  except PackageNotFoundError:
7
- __version__ = "0.5.2"
7
+ __version__ = "0.5.3"
8
8
 
9
9
 
10
10
  from .common import Ambiente
@@ -761,6 +761,7 @@ class AccountabilityV3RepasseAPI(_AccountabilityV3BaseAPI):
761
761
  df = common.handle_results(
762
762
  extrato,
763
763
  main_list="listaLancamentosExtrato",
764
+ keep_header_when_empty=True,
764
765
  insertables=[
765
766
  "numeroAgenciaRecebedora",
766
767
  "digitoVerificadoraContaRecebedora",
@@ -913,6 +914,7 @@ class AccountabilityV3RepasseAPI(_AccountabilityV3BaseAPI):
913
914
  return common.handle_results(
914
915
  res,
915
916
  main_list="listaLancamentos",
917
+ keep_header_when_empty=True,
916
918
  insertables=[
917
919
  "codigoProgramaGoverno",
918
920
  "nomeProgramaGoverno",
@@ -1773,6 +1775,7 @@ class AccountabilityV3ControleAPI(_AccountabilityV3BaseAPI):
1773
1775
  df = common.handle_results(
1774
1776
  extrato,
1775
1777
  main_list="listaLancamentosExtrato",
1778
+ keep_header_when_empty=True,
1776
1779
  insertables=[
1777
1780
  "numeroAgenciaRecebedora",
1778
1781
  "digitoVerificadoraContaRecebedora",
@@ -1922,6 +1925,7 @@ class AccountabilityV3ControleAPI(_AccountabilityV3BaseAPI):
1922
1925
  return common.handle_results(
1923
1926
  res,
1924
1927
  main_list="listaLancamentos",
1928
+ keep_header_when_empty=True,
1925
1929
  insertables=[
1926
1930
  "codigoProgramaGoverno",
1927
1931
  "nomeProgramaGoverno",
@@ -81,11 +81,25 @@ def handle_results(
81
81
  insertables: Sequence[str] | None = None,
82
82
  explodeables: Sequence[str] | None = None,
83
83
  rename_dict: Mapping[str, str] | None = None,
84
+ *,
85
+ keep_header_when_empty: bool = False,
84
86
  ) -> pd.DataFrame:
87
+ """Monta o DataFrame da resposta: uma linha por item de ``main_list``.
88
+
89
+ Os campos de ``insertables`` ficam no nível de cima da resposta, fora da
90
+ lista, e são repetidos em todas as linhas.
91
+
92
+ Com ``keep_header_when_empty``, uma lista vazia devolve uma linha só com
93
+ esses campos, em vez de um DataFrame sem linha nenhuma. É o que preserva o
94
+ cabeçalho das respostas em que ele carrega o dado principal, como o
95
+ rendimento do mês nos extratos de aplicação.
96
+ """
85
97
  record = cast("Mapping[str, object]", data)
86
98
 
87
99
  if main_list is not None:
88
- df = pd.DataFrame(cast("list[dict[Hashable, object]]", record[main_list]))
100
+ itens = cast("list[dict[Hashable, object]]", record.get(main_list) or [])
101
+ so_cabecalho = not itens and keep_header_when_empty
102
+ df = pd.DataFrame(index=[0]) if so_cabecalho else pd.DataFrame(itens)
89
103
  else:
90
104
  df = pd.DataFrame([dict(record)])
91
105
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bb_api
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Wrapper da API do Banco do Brasil.
5
5
  Requires-Python: >=3.13
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bb_api"
3
- version = "0.5.2"
3
+ version = "0.5.3"
4
4
  description = "Wrapper da API do Banco do Brasil."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
File without changes
File without changes
File without changes
File without changes
File without changes