Skip to content

Commit

Permalink
How to install
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckm45k committed Nov 22, 2022
1 parent 43efb22 commit e5f1ed9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AioAbcpApi
## AioAbcpApi

Async library for [API ABCP](https://www.abcp.ru/wiki/ABCP.API "API ABCP")
with [asyncio](https://docs.python.org/3/library/asyncio.html "asyncio")
Expand All @@ -13,9 +13,10 @@ and [aiohttp](https://github.com/aio-libs/aiohttp "aiohttp")


Присоединяйтесь к [телеграм чату](https://t.me/aioabcpapi "Телеграм чат")
### Установка
`pip install aioabcpapi`


## Описание
### Описание

------------

Expand All @@ -30,7 +31,7 @@ and [aiohttp](https://github.com/aio-libs/aiohttp "aiohttp")
Для использования этого метода нам нужно будет обратиться к `await api.ts.client.cart.update()`

#### Доступ к API
### Доступ к API

------------
[Для API Администратора](https://cp.abcp.ru/?page=allsettings&systemsettings&apiInformation)
Expand Down
10 changes: 5 additions & 5 deletions aioabcpapi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(

self.timeout = timeout

async def get_new_session(self) -> aiohttp.ClientSession:
async def _get_new_session(self) -> aiohttp.ClientSession:
return aiohttp.ClientSession(
connector=self._connector_class(**self._connector_init),
json_serialize=json.dumps
Expand All @@ -67,13 +67,13 @@ async def get_new_session(self) -> aiohttp.ClientSession:
def loop(self) -> Optional[asyncio.AbstractEventLoop]:
return self._main_loop

async def get_session(self) -> Optional[aiohttp.ClientSession]:
async def _get_session(self) -> Optional[aiohttp.ClientSession]:
if self._session is None or self._session.closed:
self._session = await self.get_new_session()
self._session = await self._get_new_session()

if not self._session._loop.is_running():
await self._session.close()
self._session = await self.get_new_session()
self._session = await self._get_new_session()

return self._session

Expand Down Expand Up @@ -109,5 +109,5 @@ async def request(self, method: str,
if data is None:
data = {'userlogin': self._login, 'userpsw': self._password}

return await api.make_request(await self.get_session(), self._host, self._admin,
return await api.make_request(await self._get_session(), self._host, self._admin,
method, data, post, timeout=self.timeout, **kwargs)
1 change: 1 addition & 0 deletions examples/basket_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def get_basket_params():
shipment_office_index=0)
orders_list = api.cp.client.orders.orders_list(orders=[94233131,
93745568])
await api.cp.admin.distributors
logger.info(f'{orders_list}')


Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pytz>=2022.1
pyRFC3339~=1.1
environs~=9.5.0
aiohttp~=3.8.1
ujson~=5.4.0
certifi~=2022.6.15

0 comments on commit e5f1ed9

Please sign in to comment.