Skip to content

Commit

Permalink
black format
Browse files Browse the repository at this point in the history
  • Loading branch information
alteralt committed Sep 4, 2023
1 parent efb4bac commit 59bf614
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tippisell_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async def upload_goods(self, product_id: int, data: typing.List[str]) -> int:
async def get_purchases(
self, user_id: typing.Optional[typing.Union[str, int]] = None, limit=None
):
result = await self._request(
methods.GetPurchases(user_id=user_id, limit=limit)
)
result = await self._request(methods.GetPurchases(user_id=user_id, limit=limit))
return result

async def get_shop(self) -> models.Shop:
Expand All @@ -53,9 +51,13 @@ async def get_categories(
http_method="get",
params={
key: value
for key, value in {"offset": offset, "limit": limit, "shop_id": self.shop_id}.items()
for key, value in {
"offset": offset,
"limit": limit,
"shop_id": self.shop_id,
}.items()
if value is not None
}
},
)
return result

Expand Down Expand Up @@ -97,11 +99,11 @@ async def get_count_positions_in_product(self, product_id: int) -> int:
return result["count"]

async def _request(
self,
method: typing.Optional[methods.BaseMethod] = None,
path: typing.Optional[str] = None,
http_method: typing.Optional[typing.Literal["get", "post"]] = None,
**kwargs
self,
method: typing.Optional[methods.BaseMethod] = None,
path: typing.Optional[str] = None,
http_method: typing.Optional[typing.Literal["get", "post"]] = None,
**kwargs
):
if method is not None:
method.attach_shop_id(self.shop_id)
Expand All @@ -113,8 +115,12 @@ async def _request(
response = await session.request(**data)
await response.read()
else:
async with aiohttp.ClientSession(headers={"api-key": self.api_key}) as session:
response = await session.request(http_method, self._base_url + path, **kwargs)
async with aiohttp.ClientSession(
headers={"api-key": self.api_key}
) as session:
response = await session.request(
http_method, self._base_url + path, **kwargs
)
await response.read()

result = await response.json()
Expand Down

0 comments on commit 59bf614

Please sign in to comment.