cybertron-spark 0.1.8__tar.gz → 0.1.10__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: cybertron-spark
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Automação do Zendesk com Selenium, Zenpy e integração Cybertron
5
5
  Author: Gustavo Sartorio
6
6
  Author-email: strov3rl@gmail.com
@@ -35,13 +35,13 @@ class Heartbeat():
35
35
  full_url = f"{self.base_endpoint.rstrip('/')}/{endpoint.lstrip('/')}"
36
36
 
37
37
  try:
38
- req = requests.post(full_url, json=payload, headers=self.headers, timeout=10)
38
+ req = requests.post(full_url, json=payload, headers=self.headers, timeout=60)
39
39
  req.raise_for_status()
40
40
  print(f"✅ Sucesso [{endpoint}]: {req.status_code}")
41
41
  return req
42
42
  except requests.exceptions.RequestException as e:
43
43
  print(f"❌ Erro ao conectar em {endpoint}: {e}")
44
- print(req.text)
44
+
45
45
  return None
46
46
 
47
47
  def _put(self, endpoint, payload):
@@ -50,13 +50,13 @@ class Heartbeat():
50
50
  full_url = f"{self.base_endpoint.rstrip('/')}/{endpoint.lstrip('/')}"
51
51
 
52
52
  try:
53
- req = requests.put(full_url, json=payload, headers=self.headers, timeout=10)
53
+ req = requests.put(full_url, json=payload, headers=self.headers, timeout=60)
54
54
  req.raise_for_status()
55
55
  print(f"✅ Sucesso [{endpoint}]: {req.status_code}")
56
56
  return req
57
57
  except requests.exceptions.RequestException as e:
58
58
  print(f"❌ Erro ao conectar em {endpoint}: {e}")
59
- print(req.text)
59
+
60
60
  return None
61
61
 
62
62
 
@@ -66,13 +66,13 @@ class Heartbeat():
66
66
  full_url = f"{self.base_endpoint.rstrip('/')}/{endpoint.lstrip('/')}"
67
67
 
68
68
  try:
69
- req = requests.patch(full_url, json=payload, headers=self.headers, timeout=10)
69
+ req = requests.patch(full_url, json=payload, headers=self.headers, timeout=60)
70
70
  req.raise_for_status()
71
71
  print(f"✅ Sucesso [{endpoint}]: {req.status_code}")
72
72
  return req
73
73
  except requests.exceptions.RequestException as e:
74
74
  print(f"❌ Erro ao conectar em {endpoint}: {e}")
75
- print(req.text)
75
+
76
76
  return None
77
77
 
78
78
  def _capture(self, exception):
@@ -206,34 +206,31 @@ class Heartbeat():
206
206
 
207
207
  return self._patch(endpoint, payload)
208
208
 
209
- def salvar_bugiganga(self, dataframe):
209
+ def salvar_bugiganga(self, lista_dados):
210
+ """
211
+ Recebe uma LISTA DE DICIONÁRIOS já tratada e envia para a API.
212
+ Não faz tratamento de dados.
213
+ """
210
214
  endpoint = '/transformers/bots-bugigangasave/'
211
215
 
212
- df_save = dataframe.copy()
213
- colunas_data = ['abertura', 'dt_status', 'dt_cancelamento', 'ult_msg', 'dt_entrega', 'dt_prevista', 'created_at']
214
-
215
- for col in colunas_data:
216
- if col in df_save.columns:
217
- df_save[col] = pd.to_datetime(df_save[col], errors='coerce').dt.strftime('%Y-%m-%dT%H:%M:%S')
218
-
219
- df_save = df_save.replace({np.nan: None})
220
- df_save = df_save.where(pd.notnull(df_save), None)
216
+ if not lista_dados or not isinstance(lista_dados, list):
217
+ print("⚠️ salvar_bugiganga: Lista vazia ou formato inválido recebido.")
218
+ return 0
221
219
 
222
- payload_total = df_save.to_dict(orient='records')
223
-
224
220
  batch_size = 500
225
221
  total_enviado = 0
226
222
 
227
- print(f"📦 Iniciando envio de {len(payload_total)} registros para o banco...")
223
+ print(f"📦 Biblioteca: Iniciando envio de {len(lista_dados)} registros...")
228
224
 
229
- for i in range(0, len(payload_total), batch_size):
230
- lote = payload_total[i:i + batch_size]
225
+ for i in range(0, len(lista_dados), batch_size):
226
+ lote = lista_dados[i:i + batch_size]
231
227
 
232
228
  response = self._post(endpoint, lote)
229
+
233
230
  if response and response.status_code in [200, 201]:
234
231
  total_enviado += len(lote)
235
232
  else:
236
- print(f"⚠️ Falha no lote {i} a {i+batch_size}")
233
+ print(f"⚠️ Falha no lote {i} - {i+batch_size}")
237
234
 
238
- print(f"🏁 Finalizado. Total salvo no banco: {total_enviado}")
235
+ print(f"🏁 Envio finalizado. Total aceito: {total_enviado}")
239
236
  return total_enviado
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cybertron-spark
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Automação do Zendesk com Selenium, Zenpy e integração Cybertron
5
5
  Author: Gustavo Sartorio
6
6
  Author-email: strov3rl@gmail.com
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as arq:
5
5
 
6
6
  setup(
7
7
  name='cybertron-spark',
8
- version='0.1.8',
8
+ version='0.1.10',
9
9
  license='MIT',
10
10
  author='Gustavo Sartorio',
11
11
  author_email='strov3rl@gmail.com',