o
    Ž¨ÊhÏ  ã                   @   s(   d dl Z ddlmZ G dd„ deƒZdS )é    Né   )ÚResourcec                   @   sD   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )ÚSuppressionListzó
    SuppressionList class used to search, get and modify suppression status.
    For detailed request and response formats, see the `Suppresion List API
    documentation
    <https://www.sparkpost.com/api#/reference/suppression-list>`_.
    zsuppression-listc                    sF   ddddddœ‰ t ‡ ‡fdd„tˆ  ¡ ƒD ƒƒ}| jd	| j|d
�}|S )a£  
        List supression list entries based on the supplied parameters

        :param datetime from_date: DateTime to start listing
        :param datetime to_date: DateTime to end listing
        :param list types: Types of entries to return
        :param int limit: Maximum number of entries to return

        :returns: a ``list`` of entries
        :raises: :exc:`SparkPostAPIException` if API call fails
        ÚfromÚtoÚtypesÚsourcesÚlimit)Ú	from_dateÚto_dater   r   r	   c                    s$   g | ]}|ˆv rˆ | ˆ| f‘qS © r   )Ú.0Úi©Úkey_mapÚkwargsr   úL/var/www/html/env/lib/python3.10/site-packages/sparkpost/suppression_list.pyÚ
<listcomp>#   s    ÿz(SuppressionList.list.<locals>.<listcomp>ÚGET)Úparams)ÚdictÚlistÚkeysÚrequestÚuri)Úselfr   r   Úresultsr   r   r   r      s   û zSuppressionList.listc                 C   ó   d| j |f }|  d|¡}|S )a%  
        Retrieve a suppression list entry for a specific recipient by email

        :param str email: Email of the recipient whose status you want to
            check_status

        :returns: a suppression list entry
        :raises: :exc:`SparkPostAPIException` if API call fails
        ú%s/%sr   ©r   r   ©r   Úemailr   r   r   r   r   Úget(   ó   
zSuppressionList.getc                 C   sJ   | j }t|tƒrd| j | dd ¡f }nd|i}| jd|t |¡d�}|S )Nr   r!   Ú
recipientsÚPUT)Údata)r   Ú
isinstancer   Úpopr   ÚjsonÚdumps)r   Ústatusr   r   r   r   r   Ú_upsert6   s   
zSuppressionList._upsertc                 C   ó
   |   |¡S )aÐ  
        Create a suppression list entry.

        :param dict|list status: If dict it is a single entry to create
            ``{
            'email': 'test@test.com',
            'transactional': True,
            'non_transactional': True,
            'description': 'Test description'
            }``, if list it is multiple entries to create

        :returns: a ``dict`` with a message
        :raises: :exc:`SparkPostAPIException` if API call fails
        ©r,   ©r   Úentryr   r   r   Úcreate@   ó   
zSuppressionList.createc                 C   r-   )aÐ  
        Update a suppression list entry.

        :param dict|list status: If dict it is a single entry to update
            ``{
            'email': 'test@test.com',
            'transactional': True,
            'non_transactional': True,
            'description': 'Test description'
            }``, if list it is multiple entries to update

        :returns: a ``dict`` with a message
        :raises: :exc:`SparkPostAPIException` if API call fails
        r.   r/   r   r   r   ÚupdateQ   r2   zSuppressionList.updatec                 C   r   )a  
        Delete the suppression status for a specific recipient by email

        :param str email: Email of the recipient whose status you want to
            remove

        :returns: TODO
        :raises: :exc:`SparkPostAPIException` if API call fails
        r   ÚDELETEr   r    r   r   r   Údeleteb   r#   zSuppressionList.deleteN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úkeyr   r"   r,   r1   r3   r5   r   r   r   r   r      s    
r   )r)   Úbaser   r   r   r   r   r   Ú<module>   s    