10
10
from .data_models .generic import EntityType
11
11
from .data_models .meal_items import MealPlanItem , MealPlanSection , RecipeItem
12
12
from .data_models .product import Group , Product , ShoppingListProduct
13
+ from .data_models .system import SystemConfig , SystemInfo , SystemTime
13
14
from .data_models .task import Task
14
15
from .data_models .user import User # noqa: F401
15
16
from .errors import GrocyError # noqa: F401
@@ -109,8 +110,10 @@ def all_products(self) -> List[Product]:
109
110
product_datas = [ProductData (** product ) for product in raw_products ]
110
111
return [Product (product ) for product in product_datas ]
111
112
112
- def chores (self , get_details : bool = False ) -> List [Chore ]:
113
- raw_chores = self ._api_client .get_chores ()
113
+ def chores (
114
+ self , get_details : bool = False , query_filters : List [str ] = None
115
+ ) -> List [Chore ]:
116
+ raw_chores = self ._api_client .get_chores (query_filters )
114
117
chores = [Chore (chore ) for chore in raw_chores ]
115
118
116
119
if get_details :
@@ -123,8 +126,9 @@ def execute_chore(
123
126
chore_id : int ,
124
127
done_by : int = None ,
125
128
tracked_time : datetime = datetime .now (),
129
+ skipped : bool = False ,
126
130
):
127
- return self ._api_client .execute_chore (chore_id , done_by , tracked_time )
131
+ return self ._api_client .execute_chore (chore_id , done_by , tracked_time , skipped )
128
132
129
133
def chore (self , chore_id : int ) -> Chore :
130
134
resp = self ._api_client .get_chore (chore_id )
@@ -154,6 +158,22 @@ def consume_product(
154
158
product_id , amount , spoiled , transaction_type , allow_subproduct_substitution
155
159
)
156
160
161
+ def consume_recipe (
162
+ self ,
163
+ recipe_id : int ,
164
+ ):
165
+ return self ._api_client .consume_recipe (recipe_id )
166
+
167
+ def open_product (
168
+ self ,
169
+ product_id : int ,
170
+ amount : float = 1 ,
171
+ allow_subproduct_substitution : bool = False ,
172
+ ):
173
+ return self ._api_client .open_product (
174
+ product_id , amount , allow_subproduct_substitution
175
+ )
176
+
157
177
def inventory_product (
158
178
self ,
159
179
product_id : int ,
@@ -231,8 +251,10 @@ def inventory_product_by_barcode(
231
251
product .get_details (self ._api_client )
232
252
return product
233
253
234
- def shopping_list (self , get_details : bool = False ) -> List [ShoppingListProduct ]:
235
- raw_shoppinglist = self ._api_client .get_shopping_list ()
254
+ def shopping_list (
255
+ self , get_details : bool = False , query_filters : List [str ] = None
256
+ ) -> List [ShoppingListProduct ]:
257
+ raw_shoppinglist = self ._api_client .get_shopping_list (query_filters )
236
258
shopping_list = [ShoppingListProduct (resp ) for resp in raw_shoppinglist ]
237
259
238
260
if get_details :
@@ -264,8 +286,8 @@ def remove_product_in_shopping_list(
264
286
product_id , shopping_list_id , amount
265
287
)
266
288
267
- def product_groups (self ) -> List [Group ]:
268
- raw_groups = self ._api_client .get_product_groups ()
289
+ def product_groups (self , query_filters : List [ str ] = None ) -> List [Group ]:
290
+ raw_groups = self ._api_client .get_product_groups (query_filters )
269
291
return [Group (resp ) for resp in raw_groups ]
270
292
271
293
def add_product_pic (self , product_id : int , pic_path : str ):
@@ -281,8 +303,23 @@ def set_userfields(self, entity: str, object_id: int, key: str, value):
281
303
def get_last_db_changed (self ):
282
304
return self ._api_client .get_last_db_changed ()
283
305
284
- def tasks (self ) -> List [Task ]:
285
- raw_tasks = self ._api_client .get_tasks ()
306
+ def get_system_info (self ) -> SystemInfo :
307
+ raw_system_info = self ._api_client .get_system_info ()
308
+ if raw_system_info :
309
+ return SystemInfo (raw_system_info )
310
+
311
+ def get_system_time (self ) -> SystemTime :
312
+ raw_system_time = self ._api_client .get_system_time ()
313
+ if raw_system_time :
314
+ return SystemTime (raw_system_time )
315
+
316
+ def get_system_config (self ) -> SystemConfig :
317
+ raw_system_config = self ._api_client .get_system_config ()
318
+ if raw_system_config :
319
+ return SystemConfig (raw_system_config )
320
+
321
+ def tasks (self , query_filters : List [str ] = None ) -> List [Task ]:
322
+ raw_tasks = self ._api_client .get_tasks (query_filters )
286
323
return [Task (task ) for task in raw_tasks ]
287
324
288
325
def task (self , task_id : int ) -> Task :
@@ -292,8 +329,10 @@ def task(self, task_id: int) -> Task:
292
329
def complete_task (self , task_id , done_time : datetime = datetime .now ()):
293
330
return self ._api_client .complete_task (task_id , done_time )
294
331
295
- def meal_plan (self , get_details : bool = False ) -> List [MealPlanItem ]:
296
- raw_meal_plan = self ._api_client .get_meal_plan ()
332
+ def meal_plan (
333
+ self , get_details : bool = False , query_filters : List [str ] = None
334
+ ) -> List [MealPlanItem ]:
335
+ raw_meal_plan = self ._api_client .get_meal_plan (query_filters )
297
336
meal_plan = [MealPlanItem (data ) for data in raw_meal_plan ]
298
337
299
338
if get_details :
@@ -306,9 +345,16 @@ def recipe(self, recipe_id: int) -> RecipeItem:
306
345
if recipe :
307
346
return RecipeItem (recipe )
308
347
309
- def batteries (self ) -> List [Battery ]:
310
- raw_batteries = self ._api_client .get_batteries ()
311
- return [Battery (bat ) for bat in raw_batteries ]
348
+ def batteries (
349
+ self , query_filters : List [str ] = None , get_details : bool = False
350
+ ) -> List [Battery ]:
351
+ raw_batteries = self ._api_client .get_batteries (query_filters )
352
+ batteries = [Battery (bat ) for bat in raw_batteries ]
353
+
354
+ if get_details :
355
+ for item in batteries :
356
+ item .get_details (self ._api_client )
357
+ return batteries
312
358
313
359
def battery (self , battery_id : int ) -> Battery :
314
360
battery = self ._api_client .get_battery (battery_id )
@@ -329,11 +375,17 @@ def update_generic(self, entity_type: EntityType, object_id: int, updated_data):
329
375
def delete_generic (self , entity_type : EntityType , object_id : int ):
330
376
return self ._api_client .delete_generic (entity_type , object_id )
331
377
332
- def get_generic_objects_for_type (self , entity_type : EntityType ):
333
- return self ._api_client .get_generic_objects_for_type (entity_type .value )
378
+ def get_generic_objects_for_type (
379
+ self , entity_type : EntityType , query_filters : List [str ] = None
380
+ ):
381
+ return self ._api_client .get_generic_objects_for_type (
382
+ entity_type .value , query_filters
383
+ )
334
384
335
- def meal_plan_sections (self ) -> List [MealPlanSection ]:
336
- raw_sections = self ._api_client .get_meal_plan_sections ()
385
+ def meal_plan_sections (
386
+ self , query_filters : List [str ] = None
387
+ ) -> List [MealPlanSection ]:
388
+ raw_sections = self ._api_client .get_meal_plan_sections (query_filters )
337
389
return [MealPlanSection (section ) for section in raw_sections ]
338
390
339
391
def meal_plan_section (self , meal_plan_section_id : int ) -> MealPlanSection :
0 commit comments