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 List Merge Fields API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/lists/merge-fields/
Schema: https://api.mailchimp.com/schema/3.0/Lists/MergeFields/Instance.json
    )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 )ListMergeFieldszH
    Manage merge fields (formerly merge vars) for a specific list.
    c                    s,   t t| j|i | d| _d| _d| _dS )z)
        Initialize the endpoint
        listsN)superr   __init__endpointlist_idmerge_id)selfargskwargs	__class__ Z/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/listmergefields.pyr      s   
zListMergeFields.__init__c                 C   s^   || _ d|vrtdd|vrtd| jj| |d|d}|dur*|d | _|S d| _|S )	aB  
        Add a new merge field for a specific list.

        :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 = {
            "name": string*,
            "type": string*
        }
        name%The list merge field must have a nametypez%The list merge field must have a typemerge-fieldsurldataNr
   )r	   KeyError
_mc_client_post_build_pathr
   )r   r	   r   responser   r   r   create   s   
zListMergeFields.createFc                 K   sJ   || _ d| _|r| jdd| |di|S | jjdd| |di|S )a3  
        Get a list of all merge fields (formerly merge vars) for a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :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
        queryparams['type'] = string
        queryparams['required'] = boolean
        Nr   r   r   )r	   r
   _iterater   r   _get)r   r	   get_allqueryparamsr   r   r   all5   s
   zListMergeFields.allc                 C   $   || _ || _| jj| |d|dS )a  
        Get information about a specific merge field in a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param merge_id: The id for the merge field.
        :type merge_id: :py:class:`str`
        r   r   )r	   r
   r   r    r   r   r	   r
   r   r   r   getM      	zListMergeFields.getc                 C   s6   || _ || _d|vrtd| jj| |d||dS )a  
        Update a specific merge field in a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param merge_id: The id for the merge field.
        :type merge_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*
        }
        r   r   r   r   )r	   r
   r   r   _patchr   )r   r	   r
   r   r   r   r   update[   s
   zListMergeFields.updatec                 C   r$   )z
        Delete a specific merge field in a list.

        :param list_id: The unique id for the list.
        :type list_id: :py:class:`str`
        :param merge_id: The id for the merge field.
        :type merge_id: :py:class:`str`
        r   r%   )r	   r
   r   _deleter   r&   r   r   r   deletep   r(   zListMergeFields.delete)F)__name__
__module____qualname____doc__r   r   r#   r'   r*   r,   __classcell__r   r   r   r   r      s    

r   N)r0   
__future__r   mailchimp3.baseapir   r   r   r   r   r   <module>   s   