o
    ˷e                     @   s0   d Z ddlmZ ddlmZ G dd deZdS )z
The Batch Webhooks API Endpoint

Documentation: https://developer.mailchimp.com/documentation/mailchimp/reference/batch-webhooks/
    )unicode_literals)BaseApic                       sJ   e Zd ZdZ fddZdd ZdddZd	d
 Zdd Zdd Z	  Z
S )BatchWebhooksz/
    Manage webhooks for batch operations.
    c                    s&   t t| j|i | d| _d| _dS )z)
        Initialize the endpoint
        zbatch-webhooksN)superr   __init__endpointbatch_webhook_id)selfargskwargs	__class__ X/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/batchwebhooks.pyr      s   
zBatchWebhooks.__init__c                 C   sD   d|vrt d| jj|  |d}|dur|d | _|S d| _|S )z
        Configure a webhook that will fire whenever any batch request
        completes processing.

        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "url": string*
        }
        url'The batch webhook must have a valid urlr   dataNid)KeyError
_mc_client_post_build_pathr   )r	   r   responser   r   r   create   s   
zBatchWebhooks.createFc                 K   s<   d| _ |r| jdd|  i|S | jjdd|  i|S )a  
        Get all webhooks that have been configured for batches.

        :param get_all: Should the query get all results
        :type get_all: :py:class:`bool`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        queryparams['count'] = integer
        queryparams['offset'] = integer
        Nr   r   )r   _iterater   r   _get)r	   get_allqueryparamsr   r   r   all.   s   zBatchWebhooks.allc                 K   s"   || _ | jjdd| |i|S )a>  
        Get information about a specific batch webhook.

        :param batch_webhook_id: The unique id for the batch webhook.
        :type batch_webhook_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        r   Nr   )r   r   r   r   )r	   r   r   r   r   r   getA   s   
zBatchWebhooks.getc                 C   s,   || _ d|vrtd| jj| ||dS )am  
        Update a webhook that will fire whenever any batch request completes
        processing.

        :param batch_webhook_id: The unique id for the batch webhook.
        :type batch_webhook_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "url": string*
        }
        r   r   r   )r   r   r   _patchr   )r	   r   r   r   r   r   updateO   s   zBatchWebhooks.updatec                 C   s   || _ | jj| |dS )z
        Remove a batch webhook. Webhooks will no longer be sent to the given
        URL.

        :param batch_webhook_id: The unique id for the batch webhook.
        :type batch_webhook_id: :py:class:`str`
        )r   )r   r   _deleter   )r	   r   r   r   r   deleteb   s   zBatchWebhooks.delete)F)__name__
__module____qualname____doc__r   r   r   r    r"   r$   __classcell__r   r   r   r   r      s    	
r   N)r(   
__future__r   mailchimp3.baseapir   r   r   r   r   r   <module>   s   