Todo Operations¶
Operations for managing todos and todo-related data.
API Reference¶
TodoOperations
¶
Bases: BaseOperations
Class to handle all operations related to todos.
Note
This class is already initialized via the client and usable as
client.todo.method
Methods:
-
list
–List all todos for a specific user or meeting.
-
create
–Create a new todo.
-
complete
–Mark a todo as complete.
-
update
–Update an existing todo.
-
details
–Retrieve the details of a specific todo item by its ID.
-
create_many
–Create multiple todos in a best-effort manner.
Functions¶
list
¶
List all todos for a specific user or meeting.
Parameters:
-
user_id
(int | None
, default:None
) –The ID of the user (default is the initialized user ID)
-
meeting_id
(int | None
, default:None
) –The ID of the meeting
Returns:
-
list[Todo]
–A list of Todo model instances
Raises:
-
ValueError
–If both user_id and meeting_id are provided
create
¶
create(title: str, meeting_id: int, due_date: str | None = None, user_id: int | None = None, notes: str | None = None) -> Todo
Create a new todo.
Parameters:
-
title
(str
) –The title of the new todo
-
meeting_id
(int
) –The ID of the meeting associated with the todo
-
due_date
(str | None
, default:None
) –The due date of the todo (optional)
-
user_id
(int | None
, default:None
) –The ID of the user responsible for the todo (default: initialized user ID)
-
notes
(str | None
, default:None
) –Additional notes for the todo (optional)
Returns:
-
Todo
–A Todo model instance representing the newly created todo
complete
¶
update
¶
Update an existing todo.
Parameters:
-
todo_id
(int
) –The ID of the todo to update
-
title
(str | None
, default:None
) –The new title of the todo (optional)
-
due_date
(str | None
, default:None
) –The new due date of the todo (optional)
Returns:
-
Todo
–A Todo model instance containing the updated todo details
Raises:
-
ValueError
–If no update fields are provided
-
RuntimeError
–If the update request fails
details
¶
Retrieve the details of a specific todo item by its ID.
Parameters:
-
todo_id
(int
) –The ID of the todo item to retrieve
Returns:
-
Todo
–A Todo model instance containing the todo details
Raises:
-
RuntimeError
–If the request to retrieve the todo details fails
create_many
¶
Create multiple todos in a best-effort manner.
Processes each todo sequentially to avoid rate limiting. Failed operations are captured and returned alongside successful ones.
Parameters:
-
todos
(list[dict[str, Any]]
) –List of dictionaries containing todo data. Each dict should have: - title (required): Title of the todo - meeting_id (required): ID of the associated meeting - due_date (optional): Due date in string format - user_id (optional): ID of the responsible user (defaults to current user) - notes (optional): Additional notes for the todo
Returns:
-
BulkCreateResult[Todo]
–BulkCreateResult containing: - successful: List of Todo instances for successful creations - failed: List of BulkCreateError instances for failed creations
Raises:
-
ValueError
–When required parameters are missing in todo data
Async Version¶
The async version AsyncTodoOperations
provides the same methods as above, but with async/await support:
AsyncTodoOperations
¶
Async class to handle all operations related to todos.
Note
This class is already initialized via the client and usable as
client.todo.method
Initialize the async todo operations.
Parameters:
-
client
(AsyncClient
) –The async HTTP client to use for API requests.
Async Usage
All methods have the same parameters and return types as their sync counterparts. Simply add await
before each method call.
Usage Examples¶
from bloomy import Client
with Client(api_key="your-api-key") as client:
# List todos for current user
todos = client.todo.list()
for todo in todos:
print(f"{todo.name} - Due: {todo.due_date}")
# List todos for a specific meeting
meeting_todos = client.todo.list(meeting_id=123)
# Create a new todo
new_todo = client.todo.create(
title="Review quarterly report",
meeting_id=123,
due_date="2024-12-31"
)
# Update a todo
client.todo.update(
todo_id=new_todo.id,
title="Review Q4 report",
due_date="2024-12-15"
)
# Mark a todo as complete
client.todo.complete(todo_id=new_todo.id)
# Delete a todo
client.todo.delete(todo_id=new_todo.id)
import asyncio
from bloomy import AsyncClient
async def main():
async with AsyncClient(api_key="your-api-key") as client:
# List todos for current user
todos = await client.todo.list()
for todo in todos:
print(f"{todo.name} - Due: {todo.due_date}")
# List todos for a specific meeting
meeting_todos = await client.todo.list(meeting_id=123)
# Create a new todo
new_todo = await client.todo.create(
title="Review quarterly report",
meeting_id=123,
due_date="2024-12-31"
)
# Update a todo
await client.todo.update(
todo_id=new_todo.id,
title="Review Q4 report",
due_date="2024-12-15"
)
# Mark a todo as complete
await client.todo.complete(todo_id=new_todo.id)
# Delete a todo
await client.todo.delete(todo_id=new_todo.id)
asyncio.run(main())
Available Methods¶
Method | Description | Parameters |
---|---|---|
list() |
Get todos | user_id , meeting_id , include_closed |
details() |
Get detailed todo information | todo_id |
create() |
Create a new todo | title , meeting_id , user_id , due_date |
update() |
Update an existing todo | todo_id , title , meeting_id , user_id , due_date |
delete() |
Delete a todo | todo_id |
complete() |
Mark a todo as complete | todo_id |
Filtering
You can filter todos by either user_id
or meeting_id
, but not both at the same time.