Currently if I do a timed.tasks.get() I get greeted with a dict of many values.
If I want to get the ID of the associated task I'd have to do the following:
print(timed.reports.get()[0]["relationships"]["task"]["data"]["id"])
This isn't very readable and clutters the codebase of end-user applications like timedctl.
My approach would be the following (code example):
>>> reports = timed.reports.get()
>>> some_report = reports[0]
>>> type(some_report)
<class 'libtimed.Report'>
>>> task = some_report.task
>>> type(task)
<class 'libtimed.Task'>
>>> print(task.id)
1234
basically we also want a class for the singular version of each datatype; Task for Tasks, etc.
This way we have a much cleaner code base and an easier development flow as people don't have to look at the raw dicts that the API would return.
However, to maintain backwards compatibility we also need the __dict__ method of each object to still return the dict how it used to be.
Currently if I do a
timed.tasks.get()I get greeted with a dict of many values.If I want to get the ID of the associated task I'd have to do the following:
This isn't very readable and clutters the codebase of end-user applications like timedctl.
My approach would be the following (code example):
basically we also want a class for the singular version of each datatype;
TaskforTasks, etc.This way we have a much cleaner code base and an easier development flow as people don't have to look at the raw dicts that the API would return.
However, to maintain backwards compatibility we also need the
__dict__method of each object to still return the dict how it used to be.