Se modificaron tareas asincronas
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}",
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user