o
    ÌÄ.jÑ  ã                   @  s|   d Z ddlmZ ddlmZ 		d$d%dd„Zd&dd„Z		d$d%dd„Zd&dd„Zd'dd„Z	d(dd„Z
d)dd „Zd*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                 C  ó$   | |dœ}|dur||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	   Úargsr   r   úN/home/thesage/.local/lib/python3.10/site-packages/caldav/jmap/_methods/task.pyÚbuild_task_list_get   s   

r   Úresponse_argsÚdictú
list[dict]c                 C  ó   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   r   r   r   Úparse_task_list_get'   ó   r   c                 C  r   )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   r   r   r   Úbuild_task_get5   s   

r   c                 C  r   )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   r   r   r   Úparse_task_getJ   r   r   Útasksúdict[str, dict]c                 C  s   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    r   r   r   Úbuild_task_set_createX   s   þúr$   Úupdatesc                 C  ó   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%   r   r   r   Úbuild_task_set_updateo   ó   ýr(   ú	list[str]c                 C  r&   )zãBuild 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   r   r   r   Úbuild_task_set_destroyƒ   r)   r,   ú.tuple[dict, dict, list[str], dict, dict, dict]c                 C  s   t | ƒS )zòParse 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   r   r   r   Úparse_task_set—   s   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
   r-   )Ú__doc__Ú
__future__r   Úcaldav.jmap._methodsr   r   r   r   r   r$   r(   r,   r.   r   r   r   r   Ú<module>   s    ý
ý



