Updated requests, added express_report

This commit is contained in:
2025-03-12 19:03:13 +03:00
parent b380875582
commit 6fcb30c497
2 changed files with 30 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import os
from dotenv import load_dotenv
from kontur_focus.req import Request
from datetime import datetime
class Focus(Request):
@@ -40,7 +41,8 @@ class Focus(Request):
:rtype: str
"""
response = self.get('/excerpt')
filename = f'{self.inn}_report.pdf'
current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Выписка_{self.inn}_{current_datetime}.pdf'
if not path:
file_path = os.path.join(self._basedir, filename)
@@ -55,6 +57,27 @@ class Focus(Request):
except Exception:
return 'Saving error!'
def express_report(self, pdf: bool = True, path: str = None):
response = self.get('/briefReport', pdf=pdf)
current_datetime = datetime.now().strftime('%d-%m-%Y_%H-%M')
filename = f'Экспресс-отчет_{self.inn}_{current_datetime}.pdf'
if pdf:
if not path:
file_path = os.path.join(self._basedir, filename)
else:
file_path = os.path.join(path, filename)
try:
with open(file_path, mode='wb') as file:
file.write(response.content)
return f'File {file_path} saved'
except Exception:
return 'Saving error!'
else:
return response
def founders_history(self):
"""История владения организацией
@@ -71,7 +94,7 @@ class Focus(Request):
"""
return self.get('/foreignRepresentatives')
def government_lists(self):
def government_lists(self): # DEPRECATED
"""Вхождение организации в государственные реестры
:return: Список реестров
@@ -81,7 +104,7 @@ class Focus(Request):
return response['listsEntries']
def is_foreign_agent(self):
def is_foreign_agent(self): # DEPRECATED
"""Проверка наличия организации в Едином реестре иностранных агентов
:return: Результат проверки