commit ab90faf9ec715bd93df400be14c97ce7ff96b890 Author: Ilya Sapunov Date: Fri Apr 26 13:12:59 2024 +0300 First commit. Added part of legal entities methods. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4a187df --- /dev/null +++ b/.gitignore @@ -0,0 +1,167 @@ +### IDEA files +.idea +kontur-focus-lib.iml +test.py + +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + diff --git a/kontur_focus/__init__.py b/kontur_focus/__init__.py new file mode 100644 index 0000000..7fd271f --- /dev/null +++ b/kontur_focus/__init__.py @@ -0,0 +1,4 @@ +from .focus import Focus +from .government_lists import gl + +__all__ = [Focus, gl] diff --git a/kontur_focus/focus.py b/kontur_focus/focus.py new file mode 100644 index 0000000..6fcd61c --- /dev/null +++ b/kontur_focus/focus.py @@ -0,0 +1,60 @@ +import requests +import os +from dotenv import load_dotenv +from kontur_focus.government_lists import gl + + +class Focus: + _base_url = None + _access_key = None + _inn = None + _orgn = None + + def __init__(self, inn: str, ogrn: str = None): + load_dotenv() + self._base_url = os.environ.get('BASE_URL') + self._access_key = os.environ.get('ACCESS_KEY') + self._inn = inn + self._orgn = ogrn + + def _r_get(self, path: str): + full_url = f'{self._base_url}{path}' + payload = {'key': self._access_key, 'inn': self._inn, 'ogrn': self._orgn} + + return requests.get(url=full_url, params=payload).json() + + def base_info(self): + return self._r_get('/req') + + def advanced_info(self): + return self._r_get('/egrDetails') + + def founders_history(self): + return self._r_get('/foundersHistory') + + def foreign_representatives(self): + return self._r_get('/foreignRepresentatives') + + def full_analytics(self): + return self._r_get('/analytics') + + @staticmethod + def government_lists(): + formatted_list = [(elem.get('name'), elem.get('description')) for elem in gl] + + return formatted_list + + def check_if_in_lists(self, list_name: str = None): + """ + Check if organization is consist in Government lists + + :param list_name: str List name + :return: json + """ + if not list_name: + return self._r_get('/analyticLists') + else: + data = self._r_get('/analyticLists')[0]['listsEntries'] + list_id = next(item['uid'] for item in gl if item['name'] == list_name) + + return next(lst['isInList'] for lst in data if lst['id'] == list_id) diff --git a/kontur_focus/government_lists.py b/kontur_focus/government_lists.py new file mode 100644 index 0000000..107d67e --- /dev/null +++ b/kontur_focus/government_lists.py @@ -0,0 +1,112 @@ +gl = [ + { + 'name': 'illicit_reward', + 'uid': '53a2d6b8-2ca3-41a6-b3c2-f942d58b35fd', + 'description': 'Участники закупок, привлечённые к административной ответственности по ст. 19.28 КоАП РФ' + }, + { + 'name': 'banks', + 'uid': '7c1c310a-9c26-4e08-80f5-8b7611f28460', + 'description': 'Перечень кредитных организаций' + }, + { + 'name': 'insurance_business', + 'uid': 'c18dd28d-0028-4bad-b73c-c15de023d843', + 'description': 'Страховые компании' + }, + { + 'name': 'foreign_agents', + 'uid': 'fcfc856d-89f8-408b-afef-56750cb90fed', + 'description': 'Иностранные агенты' + }, + { + 'name': 'golden_share', + 'uid': 'd103af01-bf6d-470a-9eea-1536b840c287', + 'description': 'Золотая акция государства' + }, + { + 'name': 'msp_support', + 'uid': 'f0efa959-854f-4617-b24a-0f5dc7d8e28a', + 'description': 'Инфраструктура поддержки МСП' + }, + { + 'name': 'construction_sro_excluded', + 'uid': 'c318de8e-95b0-4b8e-bb13-1d65e43aa471', + 'description': 'Исключенные из реестра СРО в области строительства' + }, + { + 'name': 'design_sro_excluded', + 'uid': 'fa890998-6c87-40a5-9aee-ef547056a07f', + 'description': 'Исключённые из СРО в области изысканий и (или) проектирования' + }, + { + 'name': 'major_taxpayers', + 'uid': '91f7e831-cb59-47ae-b86a-c662ada337da', + 'description': 'Крупнейшие налогоплательщики' + }, + { + 'name': 'nko_public', + 'uid': '937e8c0c-c7da-42ff-b8ca-2a526a33e48b', + 'description': 'НКО - исполнители общественно полезных услуг Минюста России' + }, + { + 'name': 'pyramid_scheme', + 'uid': 'cd5b5b63-9cae-4ac5-b74f-d58b8066e696', + 'description': 'Признаки финансовой пирамиды' + }, + { + 'name': 'illegal_lender', + 'uid': '2227c3f1-934d-4d1f-8d08-a542518bfad9', + 'description': 'Признаки нелегального кредитора' + }, + { + 'name': 'illegal_brokers', + 'uid': 'b22b4c23-e02d-4819-8a7a-f32ca4185bc2', + 'description': 'Признаки нелегального профессионального участника рынка ценных бумаг' + }, + { + 'name': 'timber_transactions', + 'uid': 'bead481d-d201-4283-be29-5011621925b1', + 'description': 'Продавцы из реестра Сделки с древесиной' + }, + { + 'name': 'tour_operators', + 'uid': 'da30f33a-7034-4a4a-8869-4a4e523ec85d', + 'description': 'Реестр туроператоров' + }, + { + 'name': 'brokers', + 'uid': '04cec8e4-b375-4bbd-b0ff-6ef6d201da93', + 'description': 'Список брокеров' + }, + { + 'name': 'strategic_enterprises', + 'uid': 'd764d2a2-b33b-446f-b60e-be517698864d', + 'description': 'Стратегические предприятия и стратегические АО' + }, + { + 'name': 'facilitators', + 'uid': '202f2c7d-3cb2-41ae-aa14-817824b81a76', + 'description': 'Участники информационного ресурса фасилити-операторов' + }, + { + 'name': 'apk_charter', + 'uid': '3a255260-d236-476d-939f-6b1d947c110f', + 'description': 'Участники Хартии АПК' + }, + { + 'name': 'ats_charter', + 'uid': 'b15bc70b-611e-45d0-b836-9fdb123cb9c2', + 'description': 'Участники Хартии АТС' + }, + { + 'name': 'design_sro_members', + 'uid': '83b314dd-6ba1-4e66-a9bb-91affecd336b', + 'description': 'Члены СРО в области изысканий и (или) проектирования' + }, + { + 'name': 'construction_sro_members', + 'uid': 'a9278dcd-1999-4c0d-b467-dac85b09e337', + 'description': 'Члены СРО в области строительства' + }, +] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d44fe44 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +python-dotenv \ No newline at end of file