@@ -473,6 +473,45 @@ def uncomplete_task(self, task_id: str) -> bool:
473473 endpoint = get_api_url (f"{ TASKS_PATH } /{ task_id } /reopen" )
474474 return post (self ._session , endpoint , self ._token )
475475
476+ def move_task (
477+ self ,
478+ task_id : str ,
479+ project_id : str | None = None ,
480+ section_id : str | None = None ,
481+ parent_id : str | None = None ,
482+ ) -> bool :
483+ """
484+ Move a task to a different project, section, or parent task.
485+
486+ `project_id` takes predence, followed by
487+ `section_id` (which also updates `project_id`),
488+ and then `parent_id` (which also updates `section_id` and `project_id`).
489+
490+ :param task_id: The ID of the task to move.
491+ :param project_id: The ID of the project to move the task to.
492+ :param section_id: The ID of the section to move the task to.
493+ :param parent_id: The ID of the parent to move the task to.
494+ :return: True if the task was moved successfully,
495+ False otherwise (possibly raise `HTTPError` instead).
496+ :raises requests.exceptions.HTTPError: If the API request fails.
497+ :raises ValueError: If neither `project_id`, `section_id`,
498+ nor `parent_id` is provided.
499+ """
500+ if project_id is None and section_id is None and parent_id is None :
501+ raise ValueError (
502+ "Either `project_id`, `section_id`, or `parent_id` must be provided."
503+ )
504+
505+ data : dict [str , Any ] = {}
506+ if project_id is not None :
507+ data ["project_id" ] = project_id
508+ if section_id is not None :
509+ data ["section_id" ] = section_id
510+ if parent_id is not None :
511+ data ["parent_id" ] = parent_id
512+ endpoint = get_api_url (f"{ TASKS_PATH } /{ task_id } /move" )
513+ return post (self ._session , endpoint , self ._token , data = data )
514+
476515 def delete_task (self , task_id : str ) -> bool :
477516 """
478517 Delete a task.
0 commit comments