diff --git a/CHANGELOG.md b/CHANGELOG.md index 340142d..73f7b43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `TodoistAPIAsync` now performs true async HTTP I/O with `httpx2.AsyncClient`. - Support for Python 3.14. - `add_project` and `update_project` accept the `table` view style. +- `add_reminder`, `update_reminder`, `add_location_reminder`, and `update_location_reminder` accept `notify_uid` to choose which project collaborator receives the reminder. ### Removed diff --git a/tests/test_api_location_reminders.py b/tests/test_api_location_reminders.py index 437fa73..f13a6ad 100644 --- a/tests/test_api_location_reminders.py +++ b/tests/test_api_location_reminders.py @@ -115,6 +115,7 @@ async def test_add_location_reminder( "loc_long": "-0.1278", "loc_trigger": "on_enter", "radius": 200, + "notify_uid": "34567", }, response_json=default_location_reminder_response, response_status=200, @@ -127,6 +128,7 @@ async def test_add_location_reminder( loc_long="-0.1278", loc_trigger="on_enter", radius=200, + notify_uid="34567", ) assert len(respx_mock.calls) == 1 @@ -139,6 +141,7 @@ async def test_add_location_reminder( loc_long="-0.1278", loc_trigger="on_enter", radius=200, + notify_uid="34567", ) assert len(respx_mock.calls) == 2 @@ -152,9 +155,10 @@ async def test_update_location_reminder( respx_mock: respx.MockRouter, default_location_reminder: LocationReminder, ) -> None: - args = { + args: dict[str, Any] = { "name": "Home Office", "radius": 150, + "notify_uid": "2671362", } updated_dict = default_location_reminder.to_dict() | args diff --git a/tests/test_api_reminders.py b/tests/test_api_reminders.py index dca6b1b..1bb41e3 100644 --- a/tests/test_api_reminders.py +++ b/tests/test_api_reminders.py @@ -111,6 +111,7 @@ async def test_add_reminder( "reminder_type": "absolute", "due": {"string": "tomorrow at 12", "lang": "en"}, "service": "push", + "notify_uid": "34567", }, response_json=default_reminder_response, response_status=200, @@ -122,6 +123,7 @@ async def test_add_reminder( due_string="tomorrow at 12", due_lang="en", service="push", + notify_uid="34567", ) assert len(respx_mock.calls) == 1 @@ -133,6 +135,7 @@ async def test_add_reminder( due_string="tomorrow at 12", due_lang="en", service="push", + notify_uid="34567", ) assert len(respx_mock.calls) == 2 @@ -146,8 +149,9 @@ async def test_update_reminder( respx_mock: respx.MockRouter, default_reminder: Reminder, ) -> None: - args = { + args: dict[str, Any] = { "minute_offset": 45, + "notify_uid": "2671362", } updated_reminder_dict = default_reminder.to_dict() | args diff --git a/todoist_api_python/api.py b/todoist_api_python/api.py index a0c4af3..6070bad 100644 --- a/todoist_api_python/api.py +++ b/todoist_api_python/api.py @@ -1577,6 +1577,7 @@ def add_reminder( due_lang: LanguageCode | None = None, due_timezone: str | None = None, service: Literal["email", "push"] | None = None, + notify_uid: str | None = None, ) -> Reminder: """ Create a new reminder. @@ -1593,6 +1594,8 @@ def add_reminder( :param due_lang: Language for parsing the due date. :param due_timezone: Timezone for the due date. :param service: The notification service ("email" or "push"). + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. Defaults to the user creating the reminder. :return: The newly created reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1613,6 +1616,7 @@ def add_reminder( minute_offset=minute_offset, due=due or None, service=service, + notify_uid=notify_uid, ) response = post( @@ -1636,6 +1640,7 @@ def update_reminder( due_lang: LanguageCode | None = None, due_timezone: str | None = None, service: Literal["email", "push"] | None = None, + notify_uid: str | None = None, ) -> Reminder: """ Update an existing reminder. @@ -1650,6 +1655,8 @@ def update_reminder( :param due_lang: Language for parsing the due date. :param due_timezone: Timezone for the due date. :param service: The notification service ("email" or "push"). + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. :return: The updated reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1668,6 +1675,7 @@ def update_reminder( minute_offset=minute_offset, due=due or None, service=service, + notify_uid=notify_uid, ) response = post( @@ -1761,6 +1769,7 @@ def add_location_reminder( loc_trigger: Literal["on_enter", "on_leave"], *, radius: int | None = None, + notify_uid: str | None = None, ) -> LocationReminder: """ Create a new location reminder. @@ -1771,6 +1780,8 @@ def add_location_reminder( :param loc_long: The longitude coordinate. :param loc_trigger: When to trigger ("on_enter" or "on_leave"). :param radius: The radius in meters (default: 100). + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. Defaults to the user creating the reminder. :return: The newly created location reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1783,6 +1794,7 @@ def add_location_reminder( loc_long=loc_long, loc_trigger=loc_trigger, radius=radius, + notify_uid=notify_uid, ) response = post( @@ -1804,6 +1816,7 @@ def update_location_reminder( loc_long: str | None = None, loc_trigger: Literal["on_enter", "on_leave"] | None = None, radius: int | None = None, + notify_uid: str | None = None, ) -> LocationReminder: """ Update an existing location reminder. @@ -1816,6 +1829,8 @@ def update_location_reminder( :param loc_long: The longitude coordinate. :param loc_trigger: When to trigger ("on_enter" or "on_leave"). :param radius: The radius in meters. + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. :return: The updated location reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1827,6 +1842,7 @@ def update_location_reminder( loc_long=loc_long, loc_trigger=loc_trigger, radius=radius, + notify_uid=notify_uid, ) response = post( diff --git a/todoist_api_python/api_async.py b/todoist_api_python/api_async.py index 8f3e106..0206564 100644 --- a/todoist_api_python/api_async.py +++ b/todoist_api_python/api_async.py @@ -1597,6 +1597,7 @@ async def add_reminder( due_lang: LanguageCode | None = None, due_timezone: str | None = None, service: Literal["email", "push"] | None = None, + notify_uid: str | None = None, ) -> Reminder: """ Create a new reminder. @@ -1613,6 +1614,8 @@ async def add_reminder( :param due_lang: Language for parsing the due date. :param due_timezone: Timezone for the due date. :param service: The notification service ("email" or "push"). + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. Defaults to the user creating the reminder. :return: The newly created reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1633,6 +1636,7 @@ async def add_reminder( minute_offset=minute_offset, due=due or None, service=service, + notify_uid=notify_uid, ) response = await post_async( @@ -1656,6 +1660,7 @@ async def update_reminder( due_lang: LanguageCode | None = None, due_timezone: str | None = None, service: Literal["email", "push"] | None = None, + notify_uid: str | None = None, ) -> Reminder: """ Update an existing reminder. @@ -1670,6 +1675,8 @@ async def update_reminder( :param due_lang: Language for parsing the due date. :param due_timezone: Timezone for the due date. :param service: The notification service ("email" or "push"). + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. :return: The updated reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1688,6 +1695,7 @@ async def update_reminder( minute_offset=minute_offset, due=due or None, service=service, + notify_uid=notify_uid, ) response = await post_async( @@ -1783,6 +1791,7 @@ async def add_location_reminder( loc_trigger: Literal["on_enter", "on_leave"], *, radius: int | None = None, + notify_uid: str | None = None, ) -> LocationReminder: """ Create a new location reminder. @@ -1793,6 +1802,8 @@ async def add_location_reminder( :param loc_long: The longitude coordinate. :param loc_trigger: When to trigger ("on_enter" or "on_leave"). :param radius: The radius in meters (default: 100). + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. Defaults to the user creating the reminder. :return: The newly created location reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1805,6 +1816,7 @@ async def add_location_reminder( loc_long=loc_long, loc_trigger=loc_trigger, radius=radius, + notify_uid=notify_uid, ) response = await post_async( @@ -1826,6 +1838,7 @@ async def update_location_reminder( loc_long: str | None = None, loc_trigger: Literal["on_enter", "on_leave"] | None = None, radius: int | None = None, + notify_uid: str | None = None, ) -> LocationReminder: """ Update an existing location reminder. @@ -1838,6 +1851,8 @@ async def update_location_reminder( :param loc_long: The longitude coordinate. :param loc_trigger: When to trigger ("on_enter" or "on_leave"). :param radius: The radius in meters. + :param notify_uid: The ID of the user to notify, who must be a collaborator + of the task's project. :return: The updated location reminder. :raises httpx2.HTTPStatusError: If the API request fails. """ @@ -1849,6 +1864,7 @@ async def update_location_reminder( loc_long=loc_long, loc_trigger=loc_trigger, radius=radius, + notify_uid=notify_uid, ) response = await post_async(