11"""Реклама"""
22
3- from typing import TYPE_CHECKING
3+ from typing import TYPE_CHECKING , Literal
44
55from human_requests .abstraction import FetchResponse , HttpMethod
66
@@ -17,18 +17,18 @@ class ClassAdvertising:
1717 def __init__ (self , parent : "PyaterochkaAPI" ):
1818 self ._parent : "PyaterochkaAPI" = parent
1919
20- async def get_news (self , limit : int | None = None ) -> FetchResponse :
21- """
22- Asynchronously retrieves news from the Pyaterochka API.
23-
24- Args:
25- limit (int, optional): The maximum number of news items to retrieve. Defaults to None.
26-
27- Returns:
28- dict: A dictionary representing the news if the request is successful, error otherwise.
29- """
30- url = f" { self . _parent . MAIN_SITE_URL } /api/public/v1/news/"
31- if limit and limit > 0 :
32- url += f"?limit= { limit } "
33-
34- return await self ._parent ._request (method = HttpMethod .GET , url = url )
20+ async def news (self ,
21+ limit : int = 12 ,
22+ offset : int = 0 ):
23+ request_url = f" { self . _parent . CATALOG_URL } /public/v1/news/?limit= { limit } &offset= { offset } "
24+ return await self . _parent . _request ( method = HttpMethod . GET , url = request_url )
25+
26+ async def promo_offers ( self ,
27+ limit : int = 20 ,
28+ web_version : bool = True ,
29+ type_offers : Literal [ "mainpage_promotion" ,
30+ "zooclub_promotion" ,
31+ "childrenclub_promotion" ,
32+ "barclub_promotion" ] = "mainpage_promotion" ) -> FetchResponse :
33+ request_url = f" { self . _parent . CATALOG_URL } /public/v1/promo-offers/?limit= { limit } &web_version= { str ( web_version ). lower () } &type= { type_offers } "
34+ return await self ._parent ._request (method = HttpMethod .GET , url = request_url )
0 commit comments