triangle-api 0.1.1__tar.gz → 0.1.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: triangle-api
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Unofficial Python wrapper for Canadian Tire Triangle Mastercard API
5
5
  Home-page: https://github.com/diogobas/triangle-api
6
6
  Author: Diogo Bastos
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="triangle-api", # Nome que aparecerá no PyPI
8
- version="0.1.1",
8
+ version="0.1.3",
9
9
  author="Diogo Bastos",
10
10
  author_email="seu-email@exemplo.com", # Opcional
11
11
  description="Unofficial Python wrapper for Canadian Tire Triangle Mastercard API",
@@ -0,0 +1,4 @@
1
+ from .client import TriangleClient
2
+
3
+ __version__ = "0.1.3"
4
+ __all__ = ["TriangleClient"]
@@ -92,21 +92,21 @@ class TriangleClient:
92
92
  # Fazemos um reload forçado para "pescar" o JSON do saldo atualizado
93
93
  print("[API] Capturando dados financeiros (retrieveAccount)...")
94
94
  try:
95
- # Esperamos a página estabilizar antes de recarregar
96
- page.wait_for_load_state("domcontentloaded")
95
+ # Garantimos que a página está estável antes de pedir o saldo
96
+ page.wait_for_load_state("networkidle", timeout=10000)
97
97
 
98
- with page.expect_response("**/retrieveAccount", timeout=30000) as resp:
98
+ # Tentamos capturar a resposta disparando um reload limpo
99
+ with page.expect_response("**/retrieveAccount", timeout=20000) as resp_info:
99
100
  page.goto("https://www.ctfs.com/content/dash/en/private/Summary.html")
100
101
 
101
- self.account_data = resp.value.json()
102
-
103
- # Salva os cookies/sessão somente após confirmar a captura dos dados
102
+ self.account_data = resp_info.value.json()
104
103
  if self.account_data:
105
104
  context.storage_state(path=self.session_path)
106
105
  print("[API] Sessão e dados financeiros salvos.")
107
-
108
106
  except Exception as e:
109
- print(f"[AVISO] Não foi possível capturar os dados via rede: {e}")
107
+ # Se falhar aqui, não quebramos o script, pois o get_transactions
108
+ # vai tentar sincronizar novamente mais tarde.
109
+ print(f"[AVISO] Falha temporária na captura do saldo: {e}")
110
110
 
111
111
  browser.close()
112
112
  return self.account_data
@@ -139,6 +139,7 @@ class TriangleClient:
139
139
  # MD5 para o Lunch Money
140
140
  ext_id = hashlib.md5(identifier.encode("utf-8")).hexdigest()
141
141
 
142
+ # Certifique-se de que o dicionário normalized tenha a chave 'notes'
142
143
  normalized.append({
143
144
  "date": t_date,
144
145
  "payee": payee,
@@ -146,7 +147,8 @@ class TriangleClient:
146
147
  "currency": "cad",
147
148
  "external_id": ext_id,
148
149
  "type": tx.get("type", "PURCHASE"),
149
- "status": "cleared" if tx.get("category") in ["POSTED", "STATEMENTED"] else "uncleared"
150
+ "status": "cleared" if tx.get("category") in ["POSTED", "STATEMENTED"] else "uncleared",
151
+ "notes": f"Type: {tx.get('type')} | Imported via Triangle API"
150
152
  })
151
153
 
152
154
  # Ordenar garantindo que não existam Nones na chave de ordenação
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: triangle-api
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Unofficial Python wrapper for Canadian Tire Triangle Mastercard API
5
5
  Home-page: https://github.com/diogobas/triangle-api
6
6
  Author: Diogo Bastos
@@ -1,4 +0,0 @@
1
- from .client import TriangleClient
2
-
3
- __version__ = "0.1.1"
4
- __all__ = ["TriangleClient"]
File without changes
File without changes