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"