From cc655f3d1ce174474c7901a7849e41a806cd7389 Mon Sep 17 00:00:00 2001 From: Kevin Rosales Date: Thu, 21 Aug 2025 15:41:45 -0600 Subject: [PATCH] Se modificaron tareas asincronas --- controllers/RESTController.py | 7 ++++--- controllers/SOAPController.py | 11 +++++++++-- utils/peticiones.py | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/controllers/RESTController.py b/controllers/RESTController.py index 02882cb..118c417 100644 --- a/controllers/RESTController.py +++ b/controllers/RESTController.py @@ -60,7 +60,7 @@ class APIController: """ Método para obtener las credenciales de VUCEM desde la API. """ - return await self._make_request_async('GET', f'vucem/vucem/?contribuyente={importador}') + return await self._make_request_async('GET', f'vucem/vucem/?importador={importador}') async def post_pedimento_service(self, data: Dict[str, Any]) -> Dict[str, Any]: """ @@ -83,7 +83,7 @@ class APIController: """ return await self._make_request_async('PUT', f'customs/pedimentos/{pedimento_id}/', data=data) - async def post_document(self, soap_response=None, organizacion: str = None, pedimento: str = None, file_name: str = None, document_type: int = 2, binary_content: bytes = None) -> Dict[str, Any]: + async def post_document(self, soap_response=None, organizacion: str = None, pedimento: str = None, file_name: str = None, document_type: int = 2, binary_content: bytes = None, fuente: int = 2) -> Dict[str, Any]: """ Método para enviar documentos (XML, PDF, etc.) a la API. @@ -170,7 +170,8 @@ class APIController: 'pedimento': pedimento, 'extension': file_extension, 'document_type': document_type, - 'size': file_size + 'size': file_size, + 'fuente': fuente } # Subir archivo diff --git a/controllers/SOAPController.py b/controllers/SOAPController.py index a00af3a..d537b1b 100644 --- a/controllers/SOAPController.py +++ b/controllers/SOAPController.py @@ -14,11 +14,18 @@ class SOAPController: self.base_url = settings.SOAP_SERVICE_URL self.timeout = settings.TIMEOUT # Timeout por default + import ssl + # Contexto SSL personalizado para permitir claves DH pequeñas + ssl_context = ssl.create_default_context() + ssl_context.set_ciphers('DEFAULT@SECLEVEL=1') + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + async def make_request(self, endpoint, data=None, headers=None, max_retries=5): intento = 0 while intento < settings.MAX_RETRIES: try: - with httpx.Client(verify=settings.context, timeout=self.timeout) as client: + with httpx.Client(verify=self.ssl_context, timeout=self.timeout) as client: content = data.encode('utf-8') if data else None response = client.post( f"{self.base_url}/{endpoint}", @@ -53,7 +60,7 @@ class SOAPController: intento = 0 while intento < settings.MAX_RETRIES: try: - async with httpx.AsyncClient(verify=settings.context, timeout=self.timeout) as client: + async with httpx.AsyncClient(verify=self.ssl_context, timeout=self.timeout) as client: content = data.encode('utf-8') if data else None response = await client.post( f"{self.base_url}/{endpoint}", diff --git a/utils/peticiones.py b/utils/peticiones.py index 3ca8f6b..2c8b1df 100644 --- a/utils/peticiones.py +++ b/utils/peticiones.py @@ -309,7 +309,8 @@ async def get_soap_pedimento_completo(credenciales, response_service, soap_contr organizacion=response_service['organizacion'], pedimento=response_service['pedimento']['id'], file_name=_file_name, - document_type=2 + document_type=2, + ) data['organizacion'] = response_service['organizacion']