
    i                    n    d Z ddlmZ ddlmZ 	 	 dddZddZ	 	 dddZddZddZ	d dZ
d!dZd"dZdS )#uw  
JMAP Task and TaskList method builders and response parsers.

These are pure functions — no HTTP, no state. They build the request
tuples that go into a ``methodCalls`` list, and parse the corresponding
``methodResponses`` entries.

Method shapes follow RFC 8620 §3.3 (get), §3.5 (set); Task-specific
properties are defined in draft-ietf-jmap-tasks (built on RFC 8984).
    )annotationsparse_set_responseN
account_idstridslist[str] | None
propertiesreturntuplec                $    | |d}|||d<   d|dfS )a  Build a ``TaskList/get`` method call tuple.

    Args:
        account_id: The JMAP accountId to query.
        ids: List of task list IDs to fetch, or ``None`` to fetch all.
        properties: List of property names to return, or ``None`` for all.

    Returns:
        A 3-tuple ``("TaskList/get", arguments_dict, call_id)`` suitable
        for inclusion in a ``methodCalls`` list.
    	accountIdr   Nr
   zTaskList/getztasklist-get-0 r   r   r
   argss       T/root/projects/butler/venv/lib/python3.11/site-packages/caldav/jmap/_methods/task.pybuild_task_list_getr      s/       *#66D'\D"233    response_argsdict
list[dict]c                H    t          |                     dg                     S )a`  Parse the arguments dict from a ``TaskList/get`` method response.

    Args:
        response_args: The second element of a ``methodResponses`` entry
            whose method name is ``"TaskList/get"``.

    Returns:
        List of raw JMAP TaskList dicts as returned by the server.
        Returns an empty list if ``"list"`` is absent or empty.
    listr   getr   s    r   parse_task_list_getr   '   "     !!&"--...r   c                $    | |d}|||d<   d|dfS )a@  Build a ``Task/get`` method call tuple.

    Args:
        account_id: The JMAP accountId to query.
        ids: List of task IDs to fetch, or ``None`` to fetch all.
        properties: List of property names to return, or ``None`` for all.

    Returns:
        A 3-tuple ``("Task/get", arguments_dict, call_id)``.
    r   Nr
   zTask/getz
task-get-0r   r   s       r   build_task_getr!   5   s.      *#66D'\l++r   c                H    t          |                     dg                     S )aT  Parse the arguments dict from a ``Task/get`` method response.

    Args:
        response_args: The second element of a ``methodResponses`` entry
            whose method name is ``"Task/get"``.

    Returns:
        List of raw JMAP Task dicts as returned by the server.
        Returns an empty list if ``"list"`` is absent or empty.
    r   r   r   s    r   parse_task_getr#   J   r   r   tasksdict[str, dict]c                ,    d| t          |          ddfS )u   Build a ``Task/set`` method call for creating tasks.

    Args:
        account_id: The JMAP accountId.
        tasks: Map of client-assigned creation ID → JMAP Task dict.

    Returns:
        A 3-tuple ``("Task/set", arguments_dict, call_id)``.
    Task/set)r   createztask-set-create-0)r   )r   r$   s     r   build_task_set_creater)   X   s,     	#5kk	
 	
 	 r   updatesc                    d| |ddfS )u   Build a ``Task/set`` method call for updating tasks.

    Args:
        account_id: The JMAP accountId.
        updates: Map of task ID → partial patch dict.

    Returns:
        A 3-tuple ``("Task/set", arguments_dict, call_id)``.
    r'   )r   updateztask-set-update-0r   )r   r*   s     r   build_task_set_updater-   o   s     	 G44 r   	list[str]c                    d| |ddfS )zBuild a ``Task/set`` method call for destroying tasks.

    Args:
        account_id: The JMAP accountId.
        ids: List of task IDs to destroy.

    Returns:
        A 3-tuple ``("Task/set", arguments_dict, call_id)``.
    r'   )r   destroyztask-set-destroy-0r   )r   r   s     r   build_task_set_destroyr1      s     	 S11 r   .tuple[dict, dict, list[str], dict, dict, dict]c                     t          |           S )zParse the arguments dict from a ``Task/set`` method response.

    Returns a 6-tuple ``(created, updated, destroyed, not_created, not_updated, not_destroyed)``.
    See :func:`caldav.jmap._methods.parse_set_response` for field semantics.
    r   r   s    r   parse_task_setr4      s     m,,,r   )NN)r   r   r   r	   r
   r	   r   r   )r   r   r   r   )r   r   r$   r%   r   r   )r   r   r*   r%   r   r   )r   r   r   r.   r   r   )r   r   r   r2   )__doc__
__future__r   caldav.jmap._methodsr   r   r   r!   r#   r)   r-   r1   r4   r   r   r   <module>r8      s   	 	 # " " " " " 3 3 3 3 3 3
 !#'4 4 4 4 4,/ / / /  !#', , , , ,*/ / / /   .   (   (- - - - - -r   