o
    ˷er                     @   s0   d Z ddlmZ ddlmZ G dd deZdS )z
The File Manager Files API endpoint

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/file-manager/files/
Schema: https://api.mailchimp.com/schema/3.0/FileManager/Files/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 )FileManagerFilesz
    Manage specific files in the File Manager for your MailChimp account. The
    File Manager is a place to store images, documents, and other files you
    include or link to in your campaigns, templates, or signup forms.
    c                    s&   t t| j|i | d| _d| _dS )z)
        Initialize the endpoint
        zfile-manager/filesN)superr   __init__endpointfile_id)selfargskwargs	__class__ [/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/filemanagerfiles.pyr      s   
zFileManagerFiles.__init__c                 C   sT   d|vrt dd|vrt d| jj|  |d}|dur%|d | _|S d| _|S )z
        Upload a new image or file to the File Manager.

        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*,
            "file_data": string*
        }
        nameThe file must have a name	file_dataThe file must have file_dataurldataNid)KeyError
_mc_client_post_build_pathr   )r	   r   responser   r   r   create   s   
zFileManagerFiles.createFc                 K   s<   d| _ |r| jdd|  i|S | jjdd|  i|S )a  
        Get a list of available images and files stored in the File Manager for the account.

        :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['created_by'] = string
        queryparams['before_created_at'] = string
        queryparams['since_created_at'] = string
        queryparams['sort_field'] = string
        queryparams['sort_dir'] = string
        Nr   r   )r   _iterater   r   _get)r	   get_allqueryparamsr   r   r   all3   s   zFileManagerFiles.allc                 K   s"   || _ | jjdd| |i|S )a;  
        Get information about a specific file in the File Manager.

        :param file_id: The unique id for the File Manager file.
        :type file_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   getL   s   
zFileManagerFiles.getc                 C   s<   || _ d|vrtdd|vrtd| jj| ||dS )aL  
        Update a file in the File Manager.

        :param file_id: The unique id for the File Manager file.
        :type file_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "name": string*,
            "file_data": string*
        }
        r   r   r   r   r   )r   r   r   _patchr   )r	   r   r   r   r   r   updateZ   s   zFileManagerFiles.updatec                 C   s   || _ | jj| |dS )z
        Remove a specific file from the File Manager.

        :param file_id: The unique id for the File Manager file.
        :type file_id: :py:class:`str`
        )r   )r   r   _deleter   )r	   r   r   r   r   deleteo   s   zFileManagerFiles.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   