63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
from kontur_focus.req import Request
|
||
from dotenv import load_dotenv
|
||
import os
|
||
|
||
|
||
class FocusCompliance(Request):
|
||
_basedir = os.path.abspath(os.path.dirname(__file__))
|
||
_focus_base_url = None
|
||
|
||
def __init__(self, inn: str, ogrn: str = None):
|
||
load_dotenv()
|
||
super().__init__(
|
||
base_url=os.environ.get('FOCUS_COMPLIANCE_BASE_URL'),
|
||
api_key=os.environ.get('FOCUS_COMPLIANCE_ACCESS_KEY'),
|
||
inn=inn,
|
||
ogrn=ogrn
|
||
)
|
||
self._focus_base_url = f'/banks/{os.environ.get('FOCUS_COMPLIANCE_BANK_ID')}'
|
||
|
||
# Компании
|
||
def company_is_foreign_agent(self):
|
||
"""Вхождение организации и ее руководителей в список иностранных агентов
|
||
|
||
:return: Дата формирования реестра, а также признаки присутствия или отсутствия в списках иностранных агентов
|
||
:rtype: dict
|
||
"""
|
||
response = self.get(path=f'{self._focus_base_url}/companies/lists')
|
||
foreign_agent_list = response['foreignAgentList']
|
||
company_in_list = []
|
||
persons_in_company_in_list = []
|
||
|
||
for item in foreign_agent_list['uls']:
|
||
if item['listItemStatus'] == 'NotInList':
|
||
continue
|
||
else:
|
||
company_in_list.append(item)
|
||
|
||
for person in foreign_agent_list['fls']:
|
||
if person['listItemStatus'] == 'NotInList':
|
||
continue
|
||
else:
|
||
persons_in_company_in_list.append(person)
|
||
|
||
fal_data = {
|
||
'list_date': str(foreign_agent_list['actualListDate']).split('T')[0],
|
||
'company_in_list': True if company_in_list else False,
|
||
'persons_in_company_in_list': True if persons_in_company_in_list else False
|
||
}
|
||
|
||
return fal_data
|
||
|
||
# Физлица
|
||
def person_is_foreign_agent(self):
|
||
"""Вхождение физлица в список иностранных агентов
|
||
|
||
:return: True или False
|
||
:rtype: bool
|
||
"""
|
||
response = self.get(path=f'{self._focus_base_url}/individuals')
|
||
fa = response[0]['foreignAgents']
|
||
|
||
return True if fa else False
|