99from human_requests import ApiChild , ApiParent , api_child_field , autotest
1010from human_requests .abstraction import FetchResponse , HttpMethod
1111
12+ from ..abstraction import DeliveryMode
13+
1214if TYPE_CHECKING :
1315 from ..manager import ChizhikAPI # noqa: F401
1416
@@ -37,6 +39,32 @@ async def tree(self, city_id: Optional[str] = None) -> FetchResponse:
3739 if city_id :
3840 url += f"?city_id={ city_id } "
3941 return await self ._parent ._request (HttpMethod .GET , url )
42+
43+ @autotest
44+ async def delivery_tree (self ,
45+ store_id : str ,
46+ mode : DeliveryMode = DeliveryMode .STORE ,
47+ include_restrict : bool = True ):
48+ url = f"{ self ._parent .DELIVERY_API_URL } /catalog/v3/stores/{ store_id } /categories?mode={ mode } &include_subcategories=1&include_restrict={ str (include_restrict ).lower ()} "
49+ return await self ._parent ._request (HttpMethod .GET , url )
50+
51+ @autotest
52+ async def delivery_tree_extended (self ,
53+ store_id : str ,
54+ category_alias : str ,
55+ mode : DeliveryMode = DeliveryMode .STORE ,
56+ include_restrict : bool = True ):
57+ url = f"{ self ._parent .DELIVERY_API_URL } /catalog/v2/stores/{ store_id } /categories/{ category_alias } /extended?mode={ mode } &include_restrict={ str (include_restrict ).lower ()} "
58+ return await self ._parent ._request (HttpMethod .GET , url )
59+
60+ @autotest
61+ async def delivery_tree_ancestors (self ,
62+ store_id : str ,
63+ category_alias : str ,
64+ mode : DeliveryMode = DeliveryMode .STORE ,
65+ include_restrict : bool = True ):
66+ url = f"{ self ._parent .DELIVERY_API_URL } /catalog/v3/stores/{ store_id } /categories/{ category_alias } /ancestors?mode={ mode } &include_restrict={ str (include_restrict ).lower ()} "
67+ return await self ._parent ._request (HttpMethod .GET , url )
4068
4169 @autotest
4270 async def products_list (
@@ -56,6 +84,8 @@ async def products_list(
5684 url += f"&term={ urllib .parse .quote (search )} "
5785 return await self ._parent ._request (HttpMethod .GET , url )
5886
87+ async def products_list_v2 ():
88+ url = "https://app.chizhik.club/delivery/api/catalog/v2/stores/HB55/categories/264C39153/products?mode=store&include_restrict=true&limit=499&offset=0"
5989
6090class ProductService (ApiChild ["ChizhikAPI" ]):
6191 """Сервис для работы с товарами в каталоге."""
@@ -78,3 +108,13 @@ async def info(
78108 if city_id :
79109 url += f"?city_id={ city_id } "
80110 return await self ._parent ._request (HttpMethod .GET , url )
111+
112+ @autotest
113+ async def delivery_info (self ,
114+ store_id : str ,
115+ product_id : int ,
116+ mode : DeliveryMode = DeliveryMode .STORE ,
117+ include_restrict : bool = True ):
118+ # TODO
119+ url = f"{ self ._parent .DELIVERY_API_URL } /catalog/v2/stores/{ store_id } /products/{ product_id } ?mode={ mode } &include_restrict={ str (include_restrict ).lower ()} "
120+ return await self ._parent ._request (HttpMethod .GET , url )
0 commit comments