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.
- {triangle_api-0.1.1 → triangle_api-0.1.3}/PKG-INFO +1 -1
- {triangle_api-0.1.1 → triangle_api-0.1.3}/setup.py +1 -1
- triangle_api-0.1.3/triangle_api/__init__.py +4 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api/client.py +11 -9
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api.egg-info/PKG-INFO +1 -1
- triangle_api-0.1.1/triangle_api/__init__.py +0 -4
- {triangle_api-0.1.1 → triangle_api-0.1.3}/README.md +0 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/setup.cfg +0 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api/exceptions.py +0 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api.egg-info/SOURCES.txt +0 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api.egg-info/dependency_links.txt +0 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api.egg-info/requires.txt +0 -0
- {triangle_api-0.1.1 → triangle_api-0.1.3}/triangle_api.egg-info/top_level.txt +0 -0
|
@@ -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.
|
|
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",
|
|
@@ -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
|
-
#
|
|
96
|
-
page.wait_for_load_state("
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|