o
    ˷ei                     @   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 Templates API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/templates/
Schema: https://api.mailchimp.com/schema/3.0/Templates/Instance.json
    )unicode_literals)BaseApi)TemplateDefaultContentc                       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 )	Templatesz
    Manage your MailChimp templates. A template is an HTML file used to create
    the layout and basic design for a campaign.
    c                    s0   t t| j|i | d| _d| _t| | _dS )z)
        Initialize the endpoint
        	templatesN)superr   __init__endpointtemplate_idr   default_content)selfargskwargs	__class__ T/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/templates.pyr      s   zTemplates.__init__c                 C   sT   d|vrt dd|vrt d| jj|  |d}|dur%|d | _|S d| _|S )a  
        Create a new template for the account. Only Classic templates are
        supported.

        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*,
            "html": string*
        }
        nameThe template must have a namehtmlThe template must have htmlurldataNid)KeyError
_mc_client_post_build_pathr
   )r   r   responser   r   r   create   s   
zTemplates.createFc                 K   s<   d| _ |r| jdd|  i|S | jjdd|  i|S )uW  
        Get a list of an account’s available templates.

        :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['created_by'] = string
        queryparams['before_created_at'] = string
        queryparams['since_created_at'] = string
        queryparams['type'] = string
        queryparams['folder_id'] = string
        Nr   r   )r
   _iterater   r   _get)r   get_allqueryparamsr   r   r   all5   s   zTemplates.allc                 K   s"   || _ | jjdd| |i|S )a*  
        Get information about a specific template.

        :param template_id: The unique id for the template.
        :type template_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   getM   s   
zTemplates.getc                 C   s<   d|vrt dd|vrt d|| _| jj| ||dS )a`  
        Update the name, HTML, or folder_id of an existing template.

        :param template_id: The unique id for the template.
        :type template_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*,
            "html": string*
        }
        r   r   r   r   r   )r   r
   r   _patchr   )r   r
   r   r   r   r   update[   s   zTemplates.updatec                 C   s   || _ | jj| |dS )z
        Delete a specific template.

        :param template_id: The unique id for the template.
        :type template_id: :py:class:`str`
        )r   )r
   r   _deleter   )r   r
   r   r   r   deletep   s   zTemplates.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   *mailchimp3.entities.templatedefaultcontentr   r   r   r   r   r   <module>   s
   