From c16785509ef6ae7f98fbae78ceaa32a26aa75fc9 Mon Sep 17 00:00:00 2001 From: Pavel Sinitsin Date: Sat, 22 Jun 2024 21:56:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=20=5Flogin=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + bpiek/api.py | 20 ++++++++------------ pyproject.toml | 6 +++--- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5208b7e..1218ed5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ .env main.py +dist/ diff --git a/bpiek/api.py b/bpiek/api.py index dbb7ee4..308f9a5 100644 --- a/bpiek/api.py +++ b/bpiek/api.py @@ -6,19 +6,8 @@ API_URL = "https://bp.iek.ru/api/catalog/v1/" class BPIekApi: - def __init__(self, username, password) -> None: + def __init__(self) -> None: self.session = requests.Session() - self.username = username - self.password = password - - self._login() - - def _login(self) -> None: - auth = self.session.post( - url=f"{AUTH_URL}", - headers={"Content-Type": "application/x-www-form-urlencoded"}, - data={"username": self.username, "password": self.password}, - ) def _instance(self, endpoint, params: dict = {}): response = self.session.get( @@ -28,6 +17,13 @@ class BPIekApi: ) return response.json() + def login(self, username, password) -> None: + auth = self.session.post( + url=f"{AUTH_URL}", + headers={"Content-Type": "application/x-www-form-urlencoded"}, + data={"username": username, "password": password}, + ) + def get_parent_categories(self) -> list[models.Category] | models.Error: response = self._instance("client/catalog") diff --git a/pyproject.toml b/pyproject.toml index a983bc6..af51e46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] -name = "iek-python" -version = "0.1.0" -description = "" +name = "bpiek" +version = "1.0.0" +description = "API клиент для Бизнес-платформа IEK" authors = ["Pavel Sinitsin "] readme = "README.md"