Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Add details for tasks (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabellaalstrom authored Aug 14, 2020
1 parent 3687ca8 commit 1f8c26f
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 156 deletions.
33 changes: 31 additions & 2 deletions pygrocy/grocy.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def next_execution_assigned_user(self) -> User:

class Task(DataModel):
def __init__(self, response: TaskResponse):

self._id = response.id
self._name = response.name
self._description = response.description
Expand All @@ -345,6 +346,34 @@ def id(self) -> str:
def name(self) -> str:
return self._name

@property
def description(self) -> str:
return self._description

@property
def due_date(self) -> datetime:
return self._due_date

@property
def done(self) -> int:
return self._done

@property
def done_timestamp(self) -> datetime:
return self._done_timestamp

@property
def category_id(self) -> int:
return self._category_id

@property
def assigned_to_user_id(self) -> int:
return self._assigned_to_user_id

@property
def userfields(self) -> Dict[str, str]:
return self._userfields


class RecipeItem(DataModel):
def __init__(self, response: RecipeDetailsResponse):
Expand Down Expand Up @@ -562,8 +591,8 @@ def tasks(self) -> List[Task]:
raw_tasks = self._api_client.get_tasks()
return [Task(task) for task in raw_tasks]

def complete_task(self, task_id):
return self._api_client.complete_task(task_id)
def complete_task(self, task_id, done_time):
return self._api_client.complete_task(task_id, done_time)

def meal_plan(self, get_details: bool = False) -> List[MealPlanItem]:
raw_meal_plan = self._api_client.get_meal_plan()
Expand Down
Loading

0 comments on commit 1f8c26f

Please sign in to comment.