o
    ˷e                     @   s<   d Z ddlmZ ddlmZ ddlmZ G dd deZdS )z
The List Webhooks API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/lists/webhooks/
Schema: https://api.mailchimp.com/schema/3.0/Lists/Webhooks/Instance.json
    )unicode_literals)BaseApi)	check_urlc                       sH   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Zdd Z	  Z
S )ListWebhooksz8
    Manage webhooks for a specific MailChimp list.
    c                    s,   t t| j|i | d| _d| _d| _dS )z)
        Initialize the endpoint
        listsN)superr   __init__endpointlist_id
webhook_id)selfargskwargs	__class__ W/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/listwebhooks.pyr      s   
zListWebhooks.__init__c                 C   sZ   || _ d|vrtdt|d  | jj| |d|d}|dur(|d | _|S d| _|S )a  
        Create a new webhook for a specific list.

        The documentation does not include any required request body
        parameters but the url parameter is being listed here as a required
        parameter in documentation and error-checking based on the description
        of the method

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "url": string*
        }
        urlz The list webhook must have a urlwebhooksr   dataNid)r
   KeyErrorr   
_mc_client_post_build_pathr   )r   r
   r   responser   r   r   create   s   
zListWebhooks.createc                 C   s"   || _ d| _| jj| |ddS )z
        Get information about all webhooks for a specific list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        Nr   r   r
   r   r   _getr   )r   r
   r   r   r   all9   s   zListWebhooks.allc                 C   $   || _ || _| jj| |d|dS )z
        Get information about a specific webhook.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param webhook_id: The unique id for the webhook.
        :type webhook_id: :py:class:`str`
        r   r   r   r   r
   r   r   r   r   getE      	zListWebhooks.getc                 C   s&   || _ || _| jj| |d||dS )z
        Update the settings for an existing webhook.

        :param list_id: The unique id for the list
        :type list_id: :py:class:`str`
        :param webhook_id: The unique id for the webhook
        :type webhook_id: :py:class:`str`
        r   r   )r
   r   r   _patchr   )r   r
   r   r   r   r   r   updateS   s   	zListWebhooks.updatec                 C   r"   )z
        Delete a specific webhook in a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param webhook_id: The unique id for the webhook.
        :type webhook_id: :py:class:`str`
        r   r   )r
   r   r   _deleter   r#   r   r   r   deletea   r%   zListWebhooks.delete)__name__
__module____qualname____doc__r   r   r!   r$   r'   r)   __classcell__r   r   r   r   r      s    
r   N)r-   
__future__r   mailchimp3.baseapir   mailchimp3.helpersr   r   r   r   r   r   <module>   s
   