U
    ä«FcÍ†  ã                   @   sØ   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  G dd„ de!ƒZ"dS )z2Twilio SendGrid v3/mail/send response body builderé   )ÚBcc)ÚCc)ÚContent)Ú	CustomArg)ÚDynamicTemplateData)ÚEmail)ÚFrom)ÚHeader)ÚMimeType)ÚPersonalization)ÚReplyTo)ÚSendAt)ÚSubject)ÚSubstitution)Ú
TemplateId)ÚToc                   @   s@  e Zd ZdZdzdd„Zdd„ Zd{d	d
„Zdd„ Zdd„ Zdd„ Z	d|dd„Z
edd„ ƒZd}dd„Zedd„ ƒZejd~dd„ƒZddd„Zedd„ ƒZejd€dd„ƒZd�dd „Zed!d"„ ƒZejd‚d#d"„ƒZdƒd$d%„Zed&d'„ ƒZejd(d'„ ƒZed)d*„ ƒZed+d,„ ƒZejd-d,„ ƒZd.d/„ Zed0d1„ ƒZejd2d1„ ƒZd3d4„ Zed5d6„ ƒZed7d8„ ƒZejd9d8„ ƒZd:d;„ Zed<d=„ ƒZejd>d=„ ƒZed?d@„ ƒZejdAd@„ ƒZedBdC„ ƒZ e jdDdC„ ƒZ edEdF„ ƒZ!e!jdGdF„ ƒZ!edHdI„ ƒZ"edJdK„ ƒZ#e#jdLdK„ ƒZ#d„dMdN„Z$edOdP„ ƒZ%edQdR„ ƒZ&e&jdSdR„ ƒZ&dTdU„ Z'edVdW„ ƒZ(e(jdXdW„ ƒZ(edYdZ„ ƒZ)ed[d\„ ƒZ*e*jd]d\„ ƒZ*d^d_„ Z+ed`da„ ƒZ,edbdc„ ƒZ-e-jdddc„ ƒZ-dedf„ Z.edgdh„ ƒZ/e/jdidh„ ƒZ/edjdk„ ƒZ0e0jdldk„ ƒZ0edmdn„ ƒZ1e1jdodn„ ƒZ1edpdq„ ƒZ2e2jdrdq„ ƒZ2edsdt„ ƒZ3e3jdudt„ ƒZ3dvdw„ Z4e5dxdy„ ƒZ6dS )…ÚMailz*Creates the response body for v3/mail/sendNFc	           	      C   sÞ   d| _ d| _d| _d| _d| _g | _d| _d| _d| _d| _	d| _
d| _d| _d| _d| _d| _d| _|dk	rt|| _|dk	rŠ|  |||¡ |dk	r˜|| _|dk	r®|  |tj¡ |dk	rÄ|  |tj¡ |dk	rÚ|  |tj¡ dS )a  
        Creates the response body for a v3/mail/send API call

        :param from_email: The email address of the sender
        :type from_email: From, tuple, optional
        :param subject: The subject of the email
        :type subject: Subject, optional
        :param to_emails: The email address of the recipient
        :type to_emails: To, str, tuple, list(str), list(tuple),
                         list(To), optional
        :param plain_text_content: The plain text body of the email
        :type plain_text_content: string, optional
        :param html_content: The html body of the email
        :type html_content: string, optional
        :param amp_html_content: The amp-html body of the email
        :type amp_html_content: string, optional
        N)Ú_attachmentsÚ_categoriesÚ	_contentsÚ_custom_argsÚ_headersÚ_personalizationsÚ	_sectionsÚ_asmÚ	_batch_idÚ_from_emailÚ_ip_pool_nameÚ_mail_settingsÚ	_reply_toÚ_send_atÚ_subjectÚ_template_idÚ_tracking_settingsÚ
from_emailÚadd_toÚsubjectÚadd_contentr
   ÚtextÚampÚhtml)	Úselfr$   Ú	to_emailsr&   Zplain_text_contentZhtml_contentZamp_html_contentÚglobal_substitutionsÚis_multiple© r/   ú>/tmp/pip-unpacked-wheel-7j3043uk/sendgrid/helpers/mail/mail.pyÚ__init__   s:    zMail.__init__c                 C   s   t |  ¡ ƒS )z¢A JSON-ready string representation of this Mail object.

        :returns: A JSON-ready string representation of this Mail object.
        :rtype: string
        )ÚstrÚget©r+   r/   r/   r0   Ú__str__R   s    zMail.__str__é    c                 C   s   |pg }|  ||¡ |S )aZ  Ensure an item is appended to a list or create a new empty list

        :param new_items: the item(s) to append
        :type new_items: list(obj)
        :param append_to: the list on which to append the items
        :type append_to: list()
        :param index: index of the list on which to append the items
        :type index: int
        ©Úinsert)r+   Ú	new_itemsZ	append_toÚindexr/   r/   r0   Ú_ensure_appendZ   s    
zMail._ensure_appendc                 C   s   |pg }|  d|¡ |S )a  Ensure an item is inserted to a list or create a new empty list

        :param new_items: the item(s) to insert
        :type new_items: list(obj)
        :param insert_to: the list on which to insert the items at index 0
        :type insert_to: list()
        r6   r7   )r+   r9   Z	insert_tor/   r/   r0   Ú_ensure_inserth   s    zMail._ensure_insertc                 C   s&   t ƒ }dd„ |pg D ƒ}dd„ |D ƒS )z]Flatten a dict

        :param dicts: Flatten a dict
        :type dicts: list(dict)
        c                 S   s   g | ]}|  ¡ ‘qS r/   ©r3   )Ú.0Údr/   r/   r0   Ú
<listcomp>{   s     z'Mail._flatten_dicts.<locals>.<listcomp>c                 S   s$   i | ]}|  ¡ D ]\}}||“qqS r/   )Úitems)r>   r?   ÚkÚvr/   r/   r0   Ú
<dictcomp>|   s
     
   z'Mail._flatten_dicts.<locals>.<dictcomp>)Údict)r+   Zdictsr?   Zlist_of_dictsr/   r/   r0   Ú_flatten_dictst   s    zMail._flatten_dictsc                 C   s   |dk	r|  ¡ S dS )z¾Get the JSON representation of the object, else return None

        :param from_obj: Get the JSON representation of the object,
        else return None
        :type from_obj: obj
        Nr=   )r+   Zfrom_objr/   r/   r0   Ú_get_or_none~   s    zMail._get_or_nonec           	      C   sJ  |dkržt |tƒr8|D ]}tƒ }| |¡ |  |¡ qntƒ }| |¡ |  |¡ |dk	rœt |tƒr†|D ]}| jD ]}| |¡ qrqhn| jD ]}| |¡ qŒn¨z| j| }d}W n tk
rÎ   tƒ }d}Y nX t |tƒrð|D ]}| |¡ qÞn
| |¡ |dk	�r2t |tƒ�r(|D ]}| |¡ �qn
| |¡ |�sF| j||d� dS )a  Adds emails to the Personalization object

        :param emails: An Email or list of Email objects
        :type emails: Email, list(Email)
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        TNF©r:   )	Ú
isinstanceÚlistr   Z	add_emailÚadd_personalizationÚpersonalizationsÚadd_substitutionr   Ú
IndexError)	r+   Zemailsr-   r.   ÚpÚemailÚpersonalizationÚsubstitutionÚhas_internal_personalizationr/   r/   r0   Ú_set_emails‡   sB    












zMail._set_emailsc                 C   s   | j S )z]A list of one or more Personalization objects

        :rtype: list(Personalization)
        )r   r4   r/   r/   r0   rL   À   s    zMail.personalizationsc                 C   s   |   || j|¡| _dS )zìAdd a Personalization object

        :param personalization: Add a Personalization object
        :type personalization: Personalization
        :param index: The index where to add the Personalization
        :type index: int
        N)r;   r   )r+   rQ   r:   r/   r/   r0   rK   È   s
      ÿzMail.add_personalizationc                 C   s   d S ©Nr/   r4   r/   r/   r0   ÚtoÓ   s    zMail.toc                 C   sš   t |tƒrV|D ]D}t |tƒr&t|dƒ}t |tƒrBt|d |d ƒ}|  ||||¡ qn@t |tƒrjt|dƒ}t |tƒr†t|d |d ƒ}|  ||||¡ dS )a>  Adds To objects to the Personalization object

        :param to_emails: The email addresses of all recipients
        :type to_emails: To, str, tuple, list(str), list(tuple), list(To)
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        Nr6   r   )rI   rJ   r2   r   Útupler%   )r+   r,   r-   r.   rO   rP   r/   r/   r0   rV   ×   s    






c                 C   sÀ   t |tƒrl|D ]Z}t |tƒr(t|dƒ}n0t |tƒrFt|d |d ƒ}nt |tƒsXtdƒ‚|  ||||¡ qnPt |tƒr€t|dƒ}t |tƒrœt|d |d ƒ}t |tƒr¬|j}|  ||||¡ dS )a#  Adds a To object to the Personalization object

        :param to_email: A To object
        :type to_email: To, str, tuple, list(str), list(tuple), list(To)
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        Nr6   r   z<Please use a To/Cc/Bcc, tuple, or a str for a to_email list.)	rI   rJ   r2   r   rW   r   Ú
ValueErrorrT   rQ   )r+   Úto_emailr-   r.   rO   rP   r/   r/   r0   r%   ó   s$    



ÿ



zMail.add_toc                 C   s   d S rU   r/   r4   r/   r/   r0   Úcc  s    zMail.ccc                 C   sš   t |tƒrV|D ]D}t |tƒr&t|dƒ}t |tƒrBt|d |d ƒ}|  ||||¡ qn@t |tƒrjt|dƒ}t |tƒr†t|d |d ƒ}|  ||||¡ dS )a  Adds Cc objects to the Personalization object

        :param cc_emails: An Cc or list of Cc objects
        :type cc_emails: Cc, list(Cc), tuple
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        Nr6   r   )rI   rJ   r2   r   rW   Úadd_ccr   )r+   Z	cc_emailsr-   r.   rO   rP   r/   r/   r0   rZ     s    






c                 C   sV   t |tƒrt|dƒ}t |tƒr0t|d |d ƒ}t |tƒr@|j}| j||||d� dS )aø  Adds a Cc object to the Personalization object

        :param to_emails: An Cc object
        :type to_emails: Cc
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        Nr6   r   ©r.   rO   )rI   r2   r   rW   r   rQ   rT   )r+   Úcc_emailr-   r.   rO   r/   r/   r0   r[   6  s    



   ÿzMail.add_ccc                 C   s   d S rU   r/   r4   r/   r/   r0   ÚbccM  s    zMail.bccc                 C   sš   t |tƒrV|D ]D}t |tƒr&t|dƒ}t |tƒrBt|d |d ƒ}|  ||||¡ qn@t |tƒrjt|dƒ}t |tƒr†t|d |d ƒ}|  ||||¡ dS )a  Adds Bcc objects to the Personalization object

        :param bcc_emails: An Bcc or list of Bcc objects
        :type bcc_emails: Bcc, list(Bcc), tuple
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        Nr6   r   )rI   rJ   r2   r   rW   Úadd_bcc)r+   Z
bcc_emailsr-   r.   rO   rP   r/   r/   r0   r^   Q  s    






c                 C   sV   t |tƒrt|dƒ}t |tƒr0t|d |d ƒ}t |tƒr@|j}| j||||d� dS )aû  Adds a Bcc object to the Personalization object

        :param to_emails: An Bcc object
        :type to_emails: Bcc
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personalization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        Nr6   r   r\   )rI   r2   r   rW   r   rQ   rT   )r+   Ú	bcc_emailr-   r.   rO   r/   r/   r0   r_   r  s    



üzMail.add_bccc                 C   s   | j S )z;The global Subject object

        :rtype: Subject
        )r!   r4   r/   r/   r0   r&   �  s    zMail.subjectc                 C   s|   t |tƒrn|jdk	rfz| j|j }d}W n tk
rF   tƒ }d}Y nX |j|_|sl| j||jd� qx|| _n
t|ƒ| _dS )z|The subject of the email(s)

        :param value: The subject of the email(s)
        :type value: Subject, string
        NTFrH   )	rI   r   rQ   r   rN   r   r&   rK   r!   ©r+   ÚvaluerQ   rS   r/   r/   r0   r&   ˜  s"    


ÿ
þc                 C   s   | j S )zFA list of global Header objects

        :rtype: list(Header)
        )r   r4   r/   r/   r0   Úheaders³  s    zMail.headersc                 C   s   d S rU   r/   r4   r/   r/   r0   Úheader»  s    zMail.headerc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )z Add headers to the email

        :param value: A list of Header objects or a dict of header key/values
        :type value: Header, list(Header), dict
        N)rI   rJ   Ú
add_header)r+   rc   Úhr/   r/   r0   rd   ¿  s    
c                 C   sØ   |j dk	rŽz| j|j  }d}W n tk
r<   tƒ }d}Y nX t|tƒrnt| ¡ ƒd \}}| t	||ƒ¡ n
| |¡ |sÔ| j
||j d� nFt|tƒrÄt| ¡ ƒd \}}|  t	||ƒ| j¡| _n|  || j¡| _dS )z²Add headers to the email globaly or to a specific Personalization

        :param value: A Header object or a dict of header key/values
        :type value: Header, dict
        NTFr6   rH   )rQ   r   rN   r   rI   rE   rJ   rA   re   r	   rK   r;   r   )r+   rd   rQ   rS   rB   rC   r/   r/   r0   re   Ì  s0    

ÿ


þ
 ÿzMail.add_headerc                 C   s   d S rU   r/   r4   r/   r/   r0   rR   ì  s    zMail.substitutionc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )z“Add substitutions to the email

        :param value: Add substitutions to the email
        :type value: Substitution, list(Substitution)
        N)rI   rJ   rM   )r+   rR   Úsr/   r/   r0   rR   ð  s    
c                 C   s    |j rZz| j|j  }d}W n tk
r8   tƒ }d}Y nX | |¡ |sœ| j||j d� nBt|tƒr†|D ]}| jD ]}| |¡ qrqhn| jD ]}| |¡ qŒdS )z�Add a substitution to the email

        :param value: Add a substitution to the email
        :type value: Substitution
        TFrH   N)	rQ   r   rN   r   rM   rK   rI   rJ   rL   )r+   rR   rQ   rS   rg   rO   r/   r/   r0   rM   ý  s(    
ÿ

 ÿ


zMail.add_substitutionc                 C   s   | j S )zLA list of global CustomArg objects

        :rtype: list(CustomArg)
        ©r   r4   r/   r/   r0   Úcustom_args  s    zMail.custom_argsc                 C   s   | j S rU   rh   r4   r/   r/   r0   Ú
custom_arg!  s    zMail.custom_argc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )zÇAdd custom args to the email

        :param value: A list of CustomArg objects or a dict of custom arg
                      key/values
        :type value: CustomArg, list(CustomArg), dict
        N)rI   rJ   Úadd_custom_arg)r+   rj   Úcr/   r/   r0   rj   %  s    
c                 C   sØ   |j dk	rŽz| j|j  }d}W n tk
r<   tƒ }d}Y nX t|tƒrnt| ¡ ƒd \}}| t	||ƒ¡ n
| |¡ |sÔ| j
||j d� nFt|tƒrÄt| ¡ ƒd \}}|  t	||ƒ| j¡| _n|  || j¡| _dS )zÀAdd custom args to the email globaly or to a specific Personalization

        :param value: A CustomArg object or a dict of custom arg key/values
        :type value: CustomArg, dict
        NTFr6   rH   )rQ   r   rN   r   rI   rE   rJ   rA   rk   r   rK   r;   r   )r+   rj   rQ   rS   rB   rC   r/   r/   r0   rk   3  s6    

ÿ


 ÿ
 ÿ ÿzMail.add_custom_argc                 C   s   | j S )z9The global SendAt object

        :rtype: SendAt
        )r    r4   r/   r/   r0   Úsend_atS  s    zMail.send_atc                 C   s|   t |tƒrn|jdk	rfz| j|j }d}W n tk
rF   tƒ }d}Y nX |j|_|sl| j||jd� qx|| _n
t|ƒ| _dS )zÒA unix timestamp specifying when your email should
        be delivered.

        :param value: A unix timestamp specifying when your email should
        be delivered.
        :type value: SendAt, int
        NTFrH   )	rI   r   rQ   r   rN   r   rm   rK   r    ra   r/   r/   r0   rm   [  s"    	


ÿ
 ÿc                 C   s   d S rU   r/   r4   r/   r/   r0   Údynamic_template_dataw  s    zMail.dynamic_template_datac                 C   sf   t |tƒst|ƒ}z| j|j }d}W n tk
rD   tƒ }d}Y nX |j|_|sb| j||jd� dS )z«Data for a transactional template

        :param value: Data for a transactional template
        :type value: DynamicTemplateData, a JSON-serializable structure
        TFrH   N)rI   r   r   rQ   rN   r   rn   rK   ra   r/   r/   r0   rn   {  s    

 ÿc                 C   s   | j S )z>The email address of the sender

        :rtype: From
        )r   r4   r/   r/   r0   r$   �  s    zMail.from_emailc                 C   s:   t |tƒrt|dƒ}t |tƒr0t|d |d ƒ}|| _dS )z…The email address of the sender

        :param value: The email address of the sender
        :type value: From, str, tuple
        Nr6   r   )rI   r2   r   rW   r   ©r+   rb   r/   r/   r0   r$   ˜  s
    


c                 C   s   | j S )z<The reply to email address

        :rtype: ReplyTo
        )r   r4   r/   r/   r0   Úreply_to¥  s    zMail.reply_toc                 C   s:   t |tƒrt|dƒ}t |tƒr0t|d |d ƒ}|| _dS )z~The reply to email address

        :param value: The reply to email address
        :type value: ReplyTo, str, tuple
        Nr6   r   )rI   r2   r   rW   r   ro   r/   r/   r0   rp   ­  s
    


c                 C   s   | j S )zAThe contents of the email

        :rtype: list(Content)
        )r   r4   r/   r/   r0   Úcontentsº  s    zMail.contentsc                 C   s   d S rU   r/   r4   r/   r/   r0   ÚcontentÂ  s    zMail.contentc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )z‰The content(s) of the email

        :param contents: The content(s) of the email
        :type contents: Content, list(Content)
        N)rI   rJ   r'   )r+   rq   rl   r/   r/   r0   rr   Æ  s    
c                 C   sÄ   t |tƒrt||ƒ}|jtjkr2|  || j¡| _nŽ|jtjkr–| jr|| jD ].}|jtjkrdd} q€qJ|jtj	krJd} q€qJnd}| j
|| j|d�| _n*| jr¨t| jƒ}nd}| j
|| j|d�| _dS )zÔAdd content to the email

        :param contents: Content to be added to the email
        :type contents: Content
        :param mime_type: Override the mime type
        :type mime_type: MimeType, str
        r   r6   rH   N)rI   r2   r   Ú	mime_typer
   r(   r<   r   r)   r*   r;   Úlen)r+   rr   rs   Ú_contentr:   r/   r/   r0   r'   Ó  s6    


  ÿ
  ÿzMail.add_contentc                 C   s   | j S )zHThe attachments to this email

        :rtype: list(Attachment)
        )r   r4   r/   r/   r0   Úattachmentsö  s    zMail.attachmentsc                 C   s   d S rU   r/   r4   r/   r/   r0   Ú
attachmentþ  s    zMail.attachmentc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )z›Add attachment(s) to this email

        :param attachment: Add attachment(s) to this email
        :type attachment: Attachment, list(Attachment)
        N)rI   rJ   Úadd_attachment)r+   rw   Úar/   r/   r0   rw     s    
c                 C   s   |   || j¡| _dS )z‰Add an attachment to this email

        :param attachment: Add an attachment to this email
        :type attachment: Attachment
        N)r;   r   )r+   rw   r/   r/   r0   rx     s    zMail.add_attachmentc                 C   s   | j S )zQThe transactional template id for this email

        :rtype: TemplateId
        )r"   r4   r/   r/   r0   Útemplate_id  s    zMail.template_idc                 C   s    t |tƒr|| _n
t|ƒ| _dS )z™The transactional template id for this email

        :param value: The transactional template id for this email
        :type value: TemplateId
        N)rI   r   r"   ro   r/   r/   r0   rz     s    
c                 C   s   | j S )zXThe block sections of code to be used as substitutions

        :rtype: Section
        )r   r4   r/   r/   r0   Úsections+  s    zMail.sectionsc                 C   s   d S rU   r/   r4   r/   r/   r0   Úsection3  s    zMail.sectionc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )zgThe block sections of code to be used as substitutions

        :rtype: Section, list(Section)
        N)rI   rJ   Úadd_section)r+   r|   rf   r/   r/   r0   r|   7  s    
c                 C   s   |   || j¡| _dS )z¨A block section of code to be used as substitutions

        :param section: A block section of code to be used as substitutions
        :type section: Section
        N)r;   r   )r+   r|   r/   r/   r0   r}   C  s    zMail.add_sectionc                 C   s   | j S )zPThe categories assigned to this message

        :rtype: list(Category)
        )r   r4   r/   r/   r0   Ú
categoriesK  s    zMail.categoriesc                 C   s   d S rU   r/   r4   r/   r/   r0   ÚcategoryS  s    zMail.categoryc                 C   s.   t |tƒr |D ]}|  |¡ qn
|  |¡ dS )zPAdd categories assigned to this message

        :rtype: list(Category)
        N)rI   rJ   Úadd_category)r+   r~   rl   r/   r/   r0   r   W  s    
c                 C   s   |   || j¡| _dS )zJAdd a category assigned to this message

        :rtype: Category
        N)r;   r   )r+   r   r/   r/   r0   r€   c  s    zMail.add_categoryc                 C   s   | j S )z=The batch id for this email

        :rtype: BatchId
        ©r   r4   r/   r/   r0   Úbatch_idj  s    zMail.batch_idc                 C   s
   || _ dS )ztThe batch id for this email

        :param value: The batch id for this email
        :type value: BatchId
        Nr�   ro   r/   r/   r0   r‚   r  s    c                 C   s   | j S )zHAn object specifying unsubscribe behavior.

        :rtype: Asm
        ©r   r4   r/   r/   r0   Úasm{  s    zMail.asmc                 C   s
   || _ dS )zŽAn object specifying unsubscribe behavior.

        :param value: An object specifying unsubscribe behavior.
        :type value: Asm
        Nrƒ   ro   r/   r/   r0   r„   ƒ  s    c                 C   s   | j S )z\The IP Pool that you would like to send this email from

        :rtype: IpPoolName
        ©r   r4   r/   r/   r0   Úip_pool_nameŒ  s    zMail.ip_pool_namec                 C   s
   || _ dS )z¯The IP Pool that you would like to send this email from

        :paran value: The IP Pool that you would like to send this email from
        :type value: IpPoolName
        Nr…   ro   r/   r/   r0   r†   ”  s    c                 C   s   | j S )zGThe mail settings for this email

        :rtype: MailSettings
        ©r   r4   r/   r/   r0   Úmail_settings�  s    zMail.mail_settingsc                 C   s
   || _ dS )zƒThe mail settings for this email

        :param value: The mail settings for this email
        :type value: MailSettings
        Nr‡   ro   r/   r/   r0   rˆ   ¥  s    c                 C   s   | j S )zOThe tracking settings for this email

        :rtype: TrackingSettings
        ©r#   r4   r/   r/   r0   Útracking_settings®  s    zMail.tracking_settingsc                 C   s
   || _ dS )z�The tracking settings for this email

        :param value: The tracking settings for this email
        :type value: TrackingSettings
        Nr‰   ro   r/   r/   r0   rŠ   ¶  s    c                 C   sâ   |   | j¡|   | j¡dd„ | jp"g D ƒdd„ | jp4g D ƒdd„ | jpFg D ƒ|   | j¡|  | j¡|  | j	¡dd„ | j
pvg D ƒ|  | j¡|   | j¡|   | j¡|   | j¡|   | j¡|   | j¡|   | j¡|   | j¡dœ}dd„ | ¡ D ƒS )	z¡
        Get a JSON-ready representation of this Mail object.

        :returns: This Mail object, ready for use in a request body.
        :rtype: dict
        c                 S   s   g | ]}|  ¡ ‘qS r/   r=   )r>   rO   r/   r/   r0   r@   É  s     zMail.get.<locals>.<listcomp>c                 S   s   g | ]}|  ¡ ‘qS r/   r=   ©r>   rl   r/   r/   r0   r@   Ê  s     c                 S   s   g | ]}|  ¡ ‘qS r/   r=   )r>   ry   r/   r/   r0   r@   Ë  s     c                 S   s   g | ]}|  ¡ ‘qS r/   r=   r‹   r/   r/   r0   r@   Ï  s     )Úfromr&   rL   rr   rv   rz   r{   rc   r~   ri   rm   r‚   r„   r†   rˆ   rŠ   rp   c                 S   s.   i | ]&\}}|d k	r|g kr|i kr||“qS rU   r/   )r>   Úkeyrb   r/   r/   r0   rD   Ú  s      ÿ zMail.get.<locals>.<dictcomp>)rG   r$   r&   rL   rq   rv   rz   rF   r{   rc   r~   ri   rm   r‚   r„   r†   rˆ   rŠ   rp   rA   )r+   Úmailr/   r/   r0   r3   ¿  s&    












ïzMail.getc                 C   s�   | t | d¡ƒ| d¡t | d¡ƒd�}z| ¡ }W n tk
rP   | ¡ }Y nX | t| ¡ | ¡ ƒ¡ | 	¡ D ]\}}| 
t||ƒ¡ qr|S )z�Create a Mail object from an instance of
        email.message.EmailMessage.

        :type message: email.message.EmailMessage
        :rtype: Mail
        r   r   r   )r$   r&   r,   )r   r3   Úget_contentÚAttributeErrorÚget_payloadr'   r   Úget_content_typeÚstriprA   re   r	   )ÚclsÚmessagerŽ   ÚbodyrB   rC   r/   r/   r0   Úfrom_EmailMessageÝ  s     ýþzMail.from_EmailMessage)NNNNNNNF)r6   )NFr6   )r6   )NFr6   )NFr6   )NFr6   )NFr6   )NFr6   )NFr6   )N)7Ú__name__Ú
__module__Ú__qualname__Ú__doc__r1   r5   r;   r<   rF   rG   rT   ÚpropertyrL   rK   rV   Úsetterr%   rZ   r[   r^   r_   r&   rc   rd   re   rR   rM   ri   rj   rk   rm   rn   r$   rp   rq   rr   r'   rv   rw   rx   rz   r{   r|   r}   r~   r   r€   r‚   r„   r†   rˆ   rŠ   r3   Úclassmethodr—   r/   r/   r/   r0   r      s          ÷
;


     ÿ
9


     ÿ
#
     ÿ

   û#   û





 




 











#




















r   N)#r›   r`   r   r]   r   rr   r   rj   r   rn   r   rP   r   r$   r   rd   r	   rs   r
   rQ   r   rp   r   rm   r   r&   r   rR   r   rz   r   rY   r   Úobjectr   r/   r/   r/   r0   Ú<module>   s"   