Compare commits

...

1 Commits

Author SHA1 Message Date
slrover e03aed78f0 Fixed reports request 2026-04-03 16:48:44 +03:00
2 changed files with 19 additions and 15 deletions
+4
View File
@@ -41,6 +41,8 @@ class Focus(Request):
:rtype: str :rtype: str
""" """
response = self.get('/excerpt') response = self.get('/excerpt')
if response.status_code != 404:
current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M') current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Выписка_{self.inn}_{current_datetime}.pdf' filename = f'Выписка_{self.inn}_{current_datetime}.pdf'
@@ -56,6 +58,8 @@ class Focus(Request):
return {'success': True, 'filename': filename, 'path': file_path} return {'success': True, 'filename': filename, 'path': file_path}
except Exception as e: except Exception as e:
return {'success': False, 'message': e} return {'success': False, 'message': e}
else:
return {'success': False, 'message': 'Not found'}
def express_report(self, pdf: bool = True, path: str = None) -> dict: def express_report(self, pdf: bool = True, path: str = None) -> dict:
"""Экспресс-отчет по контрагенту """Экспресс-отчет по контрагенту
+2 -2
View File
@@ -36,8 +36,8 @@ class Request:
try: try:
response = requests.get(url=full_url, params=payload) response = requests.get(url=full_url, params=payload)
if response.headers['Content-Type'] == 'application/json' or \ if ('Content-Type' in response.headers and response.headers['Content-Type'] == 'application/json') or \
response.headers['Content-Type'] == 'application/json; charset=utf-8': ('Content-Type' in response.headers and response.headers['Content-Type'] == 'application/json; charset=utf-8'):
return response.json() return response.json()
else: else:
return response return response