Skip to content

Commit

Permalink
Add method get_positions
Browse files Browse the repository at this point in the history
  • Loading branch information
alteralt committed Sep 5, 2023
1 parent 59bf614 commit cb8d8cb
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tippisell_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ async def get_categories(
result = await self._request(
path="/v2/category/all",
http_method="get",
params={
key: value
for key, value in {
"offset": offset,
"limit": limit,
"shop_id": self.shop_id,
}.items()
if value is not None
},
params=self._clear_dict(
{"offset": offset, "limit": limit, "shop_id": self.shop_id}
),
)
return result

async def get_positions(self, product_id: typing.Union[str, int]):
result = await self._request(
path="/v2/position/all",
http_method="get",
params=self._clear_dict(
{"shop_id": self.shop_id, "product_id": product_id}
),
)
return result

Expand Down Expand Up @@ -152,3 +156,7 @@ def _check_response(cls, http_response: models.HttpResponse):

if http_response.result["ok"] is False:
raise exceptions.BaseTippisellException(http_response.result["message"])

@classmethod
def _clear_dict(cls, data: dict) -> dict:
return {key: value for key, value in data.items() if value is not None}

0 comments on commit cb8d8cb

Please sign in to comment.