LAgencia-prospects-softseguros 0.1.10__tar.gz → 0.1.11__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.
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/PKG-INFO +1 -1
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/pyproject.toml +1 -1
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/LAgencia_prospects_softseguros.egg-info/PKG-INFO +1 -1
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/main.py +20 -1
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/api.py +1 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/execute_load_to_db.py +57 -12
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softseguros/create_customers_libertador.py +3 -1
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/README.md +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/setup.cfg +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/LAgencia_prospects_softseguros.egg-info/SOURCES.txt +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/LAgencia_prospects_softseguros.egg-info/dependency_links.txt +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/LAgencia_prospects_softseguros.egg-info/requires.txt +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/LAgencia_prospects_softseguros.egg-info/top_level.txt +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/execute_synchronization.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/__init__.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/__init__.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/codes_status_api.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/custom_execptions_api.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/models_request.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_libertador/models_response.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softin/fetch_softin.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softseguros/api_softseguros.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softseguros/create_customers_softin.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softseguros/create_prospectsfrom_in_crm_softseguros.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softseguros/models_requests.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/api_softseguros/models_response.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/config/logging_config.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/config/settings.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/__init__.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/config_db.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/models/__init__.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/models/models.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/repositories/__init__.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/repositories/libertadors.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/repositories/softin.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/repositories/softseguros.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/database/repository.py +0 -0
- {lagencia_prospects_softseguros-0.1.10 → lagencia_prospects_softseguros-0.1.11}/src/softseguros/notifier/notificaciones.py +0 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
+
import os
|
|
2
3
|
from typing import Optional, Union
|
|
3
4
|
|
|
4
5
|
from dotenv import load_dotenv
|
|
5
6
|
|
|
7
|
+
from softseguros.api_libertador.api import OAuth2BearerAuth, RequestDataUnique, ServiceAPILibertador, State
|
|
6
8
|
from softseguros.api_libertador.execute_load_to_db import synchronize_prospects_libertador_table_for_castillo, synchronize_prospects_libertador_table_for_estrella, synchronize_prospects_libertador_table_for_villacruz # noqa: F401
|
|
9
|
+
from softseguros.api_libertador.models_request import RequestDataFull
|
|
7
10
|
from softseguros.api_softin.fetch_softin import fetch_data as fetch_data # noqa: F401
|
|
8
11
|
from softseguros.api_softin.fetch_softin import synchronize_prospects_softin_table_for_castillo, synchronize_prospects_softin_table_for_estrella, synchronize_prospects_softin_table_for_villacruz # noqa: F401
|
|
9
12
|
from softseguros.api_softseguros.create_customers_libertador import synchronize_the_softseguros_table_with_libertador_prospects # noqa: F401
|
|
@@ -55,7 +58,7 @@ def normalizar_fecha(fecha: Optional[Union[str, datetime]]) -> Optional[str]:
|
|
|
55
58
|
|
|
56
59
|
|
|
57
60
|
def main():
|
|
58
|
-
create_schemas_segutos_bolivar()
|
|
61
|
+
#create_schemas_segutos_bolivar()
|
|
59
62
|
|
|
60
63
|
# synchronize_prospects_libertador_table_for_estrella()
|
|
61
64
|
# synchronize_prospects_libertador_table_for_castillo()
|
|
@@ -73,6 +76,22 @@ def main():
|
|
|
73
76
|
#notify_prospect_from_softin()
|
|
74
77
|
#notify_prospect_from_libertador()
|
|
75
78
|
#!=========================================================
|
|
79
|
+
|
|
80
|
+
client_id = os.getenv("CLIENT_ID_ESTRELLA")
|
|
81
|
+
client_secret = os.getenv("CLIENT_SECRET_ESTRELLA")
|
|
82
|
+
|
|
83
|
+
service_libertador = ServiceAPILibertador(client_id=client_id, client_secret=client_secret)
|
|
84
|
+
|
|
85
|
+
data = RequestDataUnique(solicitud="11725333")
|
|
86
|
+
result = service_libertador.data_unique(data=data)
|
|
87
|
+
print(result)
|
|
88
|
+
|
|
89
|
+
# data = RequestDataFull(estado=State.APROBADA, fechaInicio=datetime(2025, 11, 20), fechaFin=datetime(2025, 11, 24))
|
|
90
|
+
# result = service_libertador.data_full(data=data)
|
|
91
|
+
# print(result)
|
|
92
|
+
|
|
93
|
+
# result = service_libertador.request_a_one_day_range()
|
|
94
|
+
# print(result)
|
|
76
95
|
...
|
|
77
96
|
|
|
78
97
|
|
|
@@ -100,6 +100,7 @@ class OAuth2BearerAuth(httpx.Auth):
|
|
|
100
100
|
def auth_flow(self, request: httpx.Request) -> Generator[httpx.Request, None, None]:
|
|
101
101
|
"""Se ejecuta antes de cada request httpx para añadir el token."""
|
|
102
102
|
self._ensure_valid_token()
|
|
103
|
+
print(f"{self.token}")
|
|
103
104
|
request.headers["Authorization"] = f"Bearer {self.token}"
|
|
104
105
|
yield request
|
|
105
106
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from datetime import datetime, timedelta
|
|
3
|
+
from typing import Optional, Union
|
|
3
4
|
|
|
4
5
|
from softseguros.api_libertador.api import RequestDataUnique, ServiceAPILibertador, State
|
|
5
6
|
from softseguros.api_libertador.models_request import RequestDataFull
|
|
@@ -7,6 +8,47 @@ from softseguros.database.models.models import ProspectsLibertador
|
|
|
7
8
|
from softseguros.database.repositories.libertadors import select_postponed_records_liberator, update_state_record_libertador, upsert_records
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
def normalizar_fecha(fecha: Optional[Union[str, datetime]]) -> Optional[str]:
|
|
12
|
+
"""
|
|
13
|
+
Convierte varios formatos de fecha a 'YYYY-MM-DD'.
|
|
14
|
+
Acepta:
|
|
15
|
+
- '1974-01-21T00:00'
|
|
16
|
+
- '1974-01-21'
|
|
17
|
+
- datetime.datetime
|
|
18
|
+
Devuelve:
|
|
19
|
+
- '1974-01-21' o None si no puede parsear / viene None.
|
|
20
|
+
"""
|
|
21
|
+
if fecha is None:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
# Si ya es datetime, solo la formateamos
|
|
25
|
+
if isinstance(fecha, datetime):
|
|
26
|
+
return fecha.date().isoformat()
|
|
27
|
+
|
|
28
|
+
if isinstance(fecha, str):
|
|
29
|
+
fecha_str = fecha.strip()
|
|
30
|
+
|
|
31
|
+
# Caso simple: ya viene en 'YYYY-MM-DD'
|
|
32
|
+
if len(fecha_str) == 10 and fecha_str[4] == "-" and fecha_str[7] == "-":
|
|
33
|
+
return fecha_str
|
|
34
|
+
|
|
35
|
+
# Caso con 'T', tipo 'YYYY-MM-DDTHH:MM' o 'YYYY-MM-DDTHH:MM:SS'
|
|
36
|
+
if "T" in fecha_str:
|
|
37
|
+
solo_fecha = fecha_str.split("T", 1)[0]
|
|
38
|
+
# Nos aseguramos de que sea YYYY-MM-DD
|
|
39
|
+
try:
|
|
40
|
+
dt = datetime.strptime(solo_fecha, "%Y-%m-%d")
|
|
41
|
+
return dt.strftime("%Y-%m-%d")
|
|
42
|
+
except ValueError:
|
|
43
|
+
# si no matchea, dejamos caer al raise final
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
# Si llegamos aquí, no supimos interpretar la fecha
|
|
47
|
+
# raise ValueError(f"No se pudo normalizar la fecha: {fecha!r}")
|
|
48
|
+
print(f"No se pudo normalizar la fecha: {fecha!r}")
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
|
|
10
52
|
def synchronize_prospects_libertador_table(service_libertador: ServiceAPILibertador, start_date: datetime, end_date: datetime, source: str):
|
|
11
53
|
# Consultamos registros aplazados y actualizamos su estado APROBADO si aplica (02: "APLAZADA", "143": "APLAZADA-NUBE")
|
|
12
54
|
postponed_records_liberator = select_postponed_records_liberator(source=source)
|
|
@@ -26,6 +68,9 @@ def synchronize_prospects_libertador_table(service_libertador: ServiceAPILiberta
|
|
|
26
68
|
data = RequestDataFull(estado=State.NA, fechaInicio=start_date, fechaFin=end_date)
|
|
27
69
|
result = service_libertador.data_full(data=data)
|
|
28
70
|
if result.data:
|
|
71
|
+
for record in result.data:
|
|
72
|
+
record.fechaExpedicion = normalizar_fecha(record.fechaExpedicion)
|
|
73
|
+
|
|
29
74
|
records = [ProspectsLibertador(**{**record.model_dump(), "source": source}) for record in result.data]
|
|
30
75
|
upsert_records(records)
|
|
31
76
|
|
|
@@ -34,10 +79,10 @@ def synchronize_prospects_libertador_table_for_estrella():
|
|
|
34
79
|
client_id = os.getenv("CLIENT_ID_ESTRELLA")
|
|
35
80
|
client_secret = os.getenv("CLIENT_SECRET_ESTRELLA")
|
|
36
81
|
service_libertador = ServiceAPILibertador(client_id=client_id, client_secret=client_secret)
|
|
37
|
-
start_date = datetime.now().date()- timedelta(days=1)
|
|
82
|
+
start_date = datetime.now().date() - timedelta(days=1)
|
|
38
83
|
end_date = datetime.now().date()
|
|
39
|
-
#start_date = datetime(2025, 11, 1)
|
|
40
|
-
#end_date = datetime(2025, 11, 26)
|
|
84
|
+
# start_date = datetime(2025, 11, 1)
|
|
85
|
+
# end_date = datetime(2025, 11, 26)
|
|
41
86
|
synchronize_prospects_libertador_table(service_libertador=service_libertador, start_date=start_date, end_date=end_date, source="estrella")
|
|
42
87
|
|
|
43
88
|
|
|
@@ -45,10 +90,10 @@ def synchronize_prospects_libertador_table_for_castillo():
|
|
|
45
90
|
client_id = os.getenv("CLIENT_ID_CASTILLO")
|
|
46
91
|
client_secret = os.getenv("CLIENT_SECRET_CASTILLO")
|
|
47
92
|
service_libertador = ServiceAPILibertador(client_id=client_id, client_secret=client_secret)
|
|
48
|
-
start_date = datetime.now().date()- timedelta(days=1)
|
|
93
|
+
start_date = datetime.now().date() - timedelta(days=1)
|
|
49
94
|
end_date = datetime.now().date()
|
|
50
|
-
#start_date = datetime(2025, 11, 1)
|
|
51
|
-
#end_date = datetime(2025, 11, 26)
|
|
95
|
+
# start_date = datetime(2025, 11, 1)
|
|
96
|
+
# end_date = datetime(2025, 11, 26)
|
|
52
97
|
synchronize_prospects_libertador_table(service_libertador=service_libertador, start_date=start_date, end_date=end_date, source="castillo")
|
|
53
98
|
|
|
54
99
|
|
|
@@ -56,10 +101,10 @@ def synchronize_prospects_libertador_table_for_villacruz():
|
|
|
56
101
|
client_id = os.getenv("CLIENT_ID_VILLACRUZ")
|
|
57
102
|
client_secret = os.getenv("CLIENT_SECRET_VILLACRUZ")
|
|
58
103
|
service_libertador = ServiceAPILibertador(client_id=client_id, client_secret=client_secret)
|
|
59
|
-
start_date = datetime.now().date()- timedelta(days=1)
|
|
104
|
+
start_date = datetime.now().date() - timedelta(days=1)
|
|
60
105
|
end_date = datetime.now().date()
|
|
61
|
-
#start_date = datetime(2025, 11, 1)
|
|
62
|
-
#end_date = datetime(2025, 11, 26)
|
|
106
|
+
# start_date = datetime(2025, 11, 1)
|
|
107
|
+
# end_date = datetime(2025, 11, 26)
|
|
63
108
|
synchronize_prospects_libertador_table(service_libertador=service_libertador, start_date=start_date, end_date=end_date, source="villacruz")
|
|
64
109
|
|
|
65
110
|
|
|
@@ -67,8 +112,8 @@ def synchronize_prospects_libertador_table_for_livin():
|
|
|
67
112
|
client_id = os.getenv("CLIENT_ID_LIVIN")
|
|
68
113
|
client_secret = os.getenv("CLIENT_SECRET_LIVIN")
|
|
69
114
|
service_libertador = ServiceAPILibertador(client_id=client_id, client_secret=client_secret)
|
|
70
|
-
start_date = datetime.now().date()- timedelta(days=1)
|
|
115
|
+
start_date = datetime.now().date() - timedelta(days=1)
|
|
71
116
|
end_date = datetime.now().date()
|
|
72
|
-
#start_date = datetime(2025, 11, 1)
|
|
73
|
-
#end_date = datetime(2025, 11, 26)
|
|
117
|
+
# start_date = datetime(2025, 11, 1)
|
|
118
|
+
# end_date = datetime(2025, 11, 26)
|
|
74
119
|
synchronize_prospects_libertador_table(service_libertador=service_libertador, start_date=start_date, end_date=end_date, source="livin")
|
|
@@ -58,7 +58,9 @@ def normalizar_fecha(fecha: Optional[Union[str, datetime]]) -> Optional[str]:
|
|
|
58
58
|
pass
|
|
59
59
|
|
|
60
60
|
# Si llegamos aquí, no supimos interpretar la fecha
|
|
61
|
-
raise ValueError(f"No se pudo normalizar la fecha: {fecha!r}")
|
|
61
|
+
#raise ValueError(f"No se pudo normalizar la fecha: {fecha!r}")
|
|
62
|
+
print(f"No se pudo normalizar la fecha: {fecha!r}")
|
|
63
|
+
return None
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
def synchronize_the_softseguros_table_with_libertador_prospects():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|