ó
º9—^c           @   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  d d l! m" Z" d d l# m$ Z$ d e% f d „  ƒ  YZ& d S(   s2   Twilio SendGrid v3/mail/send response body builderi   (   t   Bcc(   t   Cc(   t   Content(   t	   CustomArg(   t   Email(   t   From(   t   Header(   t   HtmlContent(   t   MimeType(   t   Personalization(   t   PlainTextContent(   t   ReplyTo(   t   SendAt(   t   Subject(   t   Substitution(   t
   TemplateId(   t   To(   t   DynamicTemplateDatat   Mailc           B   sC  e  Z d  Z dG dG dG dG dG dG e d „ Z d „  Z d d „ Z d „  Z d „  Z	 d „  Z
 dG e d d „ Z e d	 „  ƒ Z d d
 „ Z e d „  ƒ Z e j dG e d d „ ƒ Z dG e d d „ Z e d „  ƒ Z e j dG e d d „ ƒ Z dG e d d „ Z e d „  ƒ Z e j dG e d d „ ƒ Z dG e d d „ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z d „  Z e d „  ƒ Z e j d „  ƒ Z d „  Z e d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z d  „  Z e d! „  ƒ Z e j d" „  ƒ Z e d# „  ƒ Z  e  j d$ „  ƒ Z  e d% „  ƒ Z! e! j d& „  ƒ Z! e d' „  ƒ Z" e" j d( „  ƒ Z" e d) „  ƒ Z# e d* „  ƒ Z$ e$ j d+ „  ƒ Z$ dG d, „ Z% e d- „  ƒ Z& e d. „  ƒ Z' e' j d/ „  ƒ Z' d0 „  Z( e d1 „  ƒ Z) e) j d2 „  ƒ Z) e d3 „  ƒ Z* e d4 „  ƒ Z+ e+ j d5 „  ƒ Z+ d6 „  Z, e d7 „  ƒ Z- e d8 „  ƒ Z. e. j d9 „  ƒ Z. d: „  Z/ e d; „  ƒ Z0 e0 j d< „  ƒ Z0 e d= „  ƒ Z1 e1 j d> „  ƒ Z1 e d? „  ƒ Z2 e2 j d@ „  ƒ Z2 e dA „  ƒ Z3 e3 j dB „  ƒ Z3 e dC „  ƒ Z4 e4 j dD „  ƒ Z4 dE „  Z5 e6 dF „  ƒ Z7 RS(H   s*   Creates the response body for v3/mail/sendc         C   s3  d |  _ d |  _ d |  _ d |  _ d |  _ g  |  _ d |  _ d |  _ d |  _	 d |  _
 d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ | d k	 r± | |  _ n  | d k	 rÓ |  j | | | ƒ n  | d k	 rë | |  _ n  | d k	 r|  j | t j ƒ n  | d k	 r/|  j | t j ƒ n  d S(   sS  
        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, tuple, 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
        N(   t   Nonet   _attachmentst   _categoriest	   _contentst   _custom_argst   _headerst   _personalizationst	   _sectionst   _asmt	   _batch_idt   _from_emailt   _ip_pool_namet   _mail_settingst	   _reply_tot   _send_att   _subjectt   _template_idt   _tracking_settingst
   from_emailt   add_tot   subjectt   add_contentR   t   textt   html(   t   selfR%   t	   to_emailsR'   t   plain_text_contentt   html_contentt   global_substitutionst   is_multiple(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   __init__   s6    																	c         C   s   t  |  j ƒ  ƒ S(   s¢   A JSON-ready string representation of this Mail object.

        :returns: A JSON-ready string representation of this Mail object.
        :rtype: string
        (   t   strt   get(   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   __str__M   s    i    c         C   s    | p	 g  } | j  | | ƒ | S(   sZ  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
        (   t   insert(   R+   t	   new_itemst	   append_tot   index(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   _ensure_appendU   s    
c         C   s    | p	 g  } | j  d | ƒ | S(   s  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()
        i    (   R5   (   R+   R6   t	   insert_to(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   _ensure_insertc   s    c         C   s<   t  ƒ  } g  | p g  D] } | j ƒ  ^ q } d „  | Dƒ S(   s]   Flatten a dict

        :param dicts: Flatten a dict
        :type dicts: list(dict)
        c         S   s2   i  |  ]( } | j  ƒ  D] \ } } | | “ q q S(    (   t   items(   t   .0t   dt   kt   v(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pys
   <dictcomp>w   s   	 (   t   dictR3   (   R+   t   dictsR>   t   list_of_dicts(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   _flatten_dictso   s    	%c         C   s   | d k	 r | j ƒ  Sd S(   s¾   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
        N(   R   R3   (   R+   t   from_obj(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   _get_or_noney   s    c   	      C   sÏ  | t  k rì t | t ƒ rR xW | D]) } t ƒ  } | j | ƒ |  j | ƒ q" Wn# t ƒ  } | j | ƒ |  j | ƒ | d k	 rËt | t ƒ rÅ xS | D]' } x |  j D] } | j | ƒ q§ Wq— Wqé x! |  j D] } | j | ƒ qÏ WqËnß y |  j	 | } t  } Wn  t
 k
 r%t ƒ  } t } n Xt | t ƒ rVx+ | D] } | j | ƒ q<Wn | j | ƒ | d k	 r¯t | t ƒ rŸx+ | D] } | j | ƒ q…Wq¯| j | ƒ n  | sË|  j | d | ƒn  d S(   s  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 personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        R8   N(   t   Truet
   isinstancet   listR	   t	   add_emailt   add_personalizationR   t   personalizationst   add_substitutionR   t
   IndexErrort   False(	   R+   t   emailsR/   R0   t   pt   emailt   personalizationt   substitutiont   has_internal_personalization(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   _set_emails‚   sB    		
	
c         C   s   |  j  S(   s\   A list of one or more Personaliztion objects

        :rtype: list(Personalization)
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRL   »   s    c         C   s   |  j  | |  j | ƒ |  _ d S(   sí   Add a Personaliztion object

        :param personalizations: Add a Personalization object
        :type personalizations: Personalization
        :param index: The index where to add the Personalization
        :type index: int
        N(   R9   R   (   R+   RS   R8   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRK   Ã   s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   toÎ   s    c         C   sç   t  | t ƒ rƒ xÑ | D]f } t  | t ƒ r= t | d ƒ } n  t  | t ƒ rf t | d | d ƒ } n  |  j | | | | ƒ q Wn` t  | t ƒ r¤ t | d ƒ } n  t  | t ƒ rÍ t | d | d ƒ } n  |  j | | | | ƒ d S(   s  Adds To objects to the Personalization object

        :param to_emails: An To or list of To objects
        :type to_emails: To, list(To), str, tuple
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        i    i   N(   RH   RI   R2   R   R   t   tupleR&   (   R+   R,   R/   R0   RQ   RR   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRW   Ò   s    c         C   s  t  | t ƒ rƒ xì | D]f } t  | t ƒ r= t | d ƒ } n  t  | t ƒ rf t | d | d ƒ } n  |  j | | | | ƒ q Wn{ t  | t ƒ r¤ t | d ƒ } n  t  | t ƒ rÍ t | d | d ƒ } n  t  | t ƒ rè | j } n  |  j | | | | ƒ d S(   s  Adds a To object to the Personalization object

        :param to_emails: A To object
        :type to_emails: To, str, tuple
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        i    i   N(	   RH   RI   R2   R   R   RX   RV   R   RS   (   R+   t   to_emailR/   R0   RQ   RR   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR&   î   s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   cc  s    c         C   sç   t  | t ƒ rƒ xÑ | D]f } t  | t ƒ r= t | d ƒ } n  t  | t ƒ rf t | d | d ƒ } n  |  j | | | | ƒ q Wn` t  | t ƒ r¤ t | d ƒ } n  t  | t ƒ rÍ t | d | d ƒ } n  |  j | | | | ƒ d S(   s  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 personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        i    i   N(   RH   RI   R2   R   R   RX   t   add_ccR   (   R+   t	   cc_emailsR/   R0   RQ   RR   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRZ     s    c         C   s…   t  | t ƒ r! t | d ƒ } n  t  | t ƒ rJ t | d | d ƒ } n  t  | t ƒ re | j } n  |  j | | d | d | ƒd S(   sø  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 personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        i    i   R0   RQ   N(   RH   R2   R   R   RX   R   RS   RV   (   R+   t   cc_emailR/   R0   RQ   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR[   -  s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   bccD  s    c         C   sç   t  | t ƒ rƒ xÑ | D]f } t  | t ƒ r= t | d ƒ } n  t  | t ƒ rf t | d | d ƒ } n  |  j | | | | ƒ q Wn` t  | t ƒ r¤ t | d ƒ } n  t  | t ƒ rÍ t | d | d ƒ } n  |  j | | | | ƒ d S(   s  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 personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        i    i   N(   RH   RI   R2   R    R   RX   t   add_bcc(   R+   t
   bcc_emailsR/   R0   RQ   RR   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR^   H  s    c         C   s…   t  | t ƒ r! t | d ƒ } n  t  | t ƒ rJ t | d | d ƒ } n  t  | t ƒ re | j } n  |  j | | d | d | ƒd S(   sû  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 personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        i    i   R0   RQ   N(   RH   R2   R    R   RX   R   RS   RV   (   R+   t	   bcc_emailR/   R0   RQ   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR_   i  s    c         C   s   |  j  S(   s;   The global Subject object

        :rtype: Subject
        (   R"   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR'   ‡  s    c         C   s¨   t  | t ƒ r• | j d k	 r‰ y |  j | j } t } Wn  t k
 rZ t ƒ  } t } n X| j	 | _	 | s’ |  j
 | d | j ƒq’ q¤ | |  _ n t | ƒ |  _ d S(   s|   The subject of the email(s)

        :param value: The subject of the email(s)
        :type value: Subject, string
        R8   N(   RH   R   RS   R   R   RG   RN   R	   RO   R'   RK   R"   (   R+   t   valueRS   RU   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR'     s    
	
c         C   s   |  j  S(   sF   A list of global Header objects

        :rtype: list(Header)
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   headersª  s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   header²  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   s    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(   RH   RI   t
   add_header(   R+   Rc   t   h(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRd   ¶  s    c         C   s*  | j  d k	 r¿ y |  j | j  } t } Wn  t k
 rK t ƒ  } t } n Xt | t ƒ r t	 | j
 ƒ  ƒ d \ } } | j t | | ƒ ƒ n | j | ƒ | s&|  j | d | j  ƒq&ng t | t ƒ rt	 | j
 ƒ  ƒ d \ } } |  j t | | ƒ |  j ƒ |  _ n |  j | |  j ƒ |  _ d S(   s²   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
        i    R8   N(   RS   R   R   RG   RN   R	   RO   RH   RA   RI   R<   Re   R   RK   R9   R   (   R+   Rd   RS   RU   R?   R@   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRe   Ã  s(    
	
c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRT   ã  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   s“   Add substitutions to the email

        :param value: Add substitutions to the email
        :type value: Substitution, list(Substitution)
        N(   RH   RI   RM   (   R+   RT   t   s(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRT   ç  s    c         C   sÞ   | j  ru y |  j | j  } t } Wn  t k
 rE t ƒ  } t } n X| j | ƒ | sÚ |  j | d | j  ƒqÚ ne t | t	 ƒ r¹ xS | D]' } x |  j
 D] } | j | ƒ q› Wq‹ Wn! x |  j
 D] } | j | ƒ qÃ Wd S(   s   Add a substitution to the email

        :param value: Add a substitution to the email
        :type value: Substitution
        R8   N(   RS   R   RG   RN   R	   RO   RM   RK   RH   RI   RL   (   R+   RT   RS   RU   Rg   RQ   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRM   ô  s"    	
	
c         C   s   |  j  S(   sL   A list of global CustomArg objects

        :rtype: list(CustomArg)
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   custom_args  s    c         C   s   |  j  S(   N(   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt
   custom_arg  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   sÇ   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(   RH   RI   t   add_custom_arg(   R+   Ri   t   c(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRi     s    c         C   s*  | j  d k	 r¿ y |  j | j  } t } Wn  t k
 rK t ƒ  } t } n Xt | t ƒ r t	 | j
 ƒ  ƒ d \ } } | j t | | ƒ ƒ n | j | ƒ | s&|  j | d | j  ƒq&ng t | t ƒ rt	 | j
 ƒ  ƒ d \ } } |  j t | | ƒ |  j ƒ |  _ n |  j | |  j ƒ |  _ d S(   sÀ   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
        i    R8   N(   RS   R   R   RG   RN   R	   RO   RH   RA   RI   R<   Rj   R   RK   R9   R   (   R+   Ri   RS   RU   R?   R@   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRj   *  s(    
	
c         C   s   |  j  S(   s9   The global SendAt object

        :rtype: SendAt
        (   R!   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   send_atJ  s    c         C   s¨   t  | t ƒ r• | j d k	 r‰ y |  j | j } t } Wn  t k
 rZ t ƒ  } t } n X| j	 | _	 | s’ |  j
 | d | j ƒq’ q¤ | |  _ n t | ƒ |  _ d S(   sÒ   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
        R8   N(   RH   R   RS   R   R   RG   RN   R	   RO   Rl   RK   R!   (   R+   Rb   RS   RU   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRl   R  s    	
	
c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   dynamic_template_datan  s    c         C   sŠ   t  | t ƒ s t | ƒ } n  y |  j | j } t } Wn  t k
 rZ t ƒ  } t } n X| j | _ | s† |  j	 | d | j ƒn  d S(   s¬   Data for a transactional template

        :param value: Data for a transactional template
        :type value: DynamicTemplateData, a JSON-serializeable structure
        R8   N(
   RH   R   R   RS   RG   RN   R	   RO   Rm   RK   (   R+   Rb   RS   RU   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRm   r  s    
	
c         C   s   |  j  S(   s>   The email address of the sender

        :rtype: From
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR%   ‡  s    c         C   sW   t  | t ƒ r! t | d ƒ } n  t  | t ƒ rJ t | d | d ƒ } n  | |  _ d S(   s…   The email address of the sender

        :param value: The email address of the sender
        :type value: From, str, tuple
        i    i   N(   RH   R2   R   R   RX   R   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR%     s
    c         C   s   |  j  S(   s<   The reply to email address

        :rtype: ReplyTo
        (   R    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   reply_toœ  s    c         C   sW   t  | t ƒ r! t | d ƒ } n  t  | t ƒ rJ t | d | d ƒ } n  | |  _ d S(   s~   The reply to email address

        :param value: The reply to email address
        :type value: ReplyTo, str, tuple
        i    i   N(   RH   R2   R   R   RX   R    (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRn   ¤  s
    c         C   s   |  j  S(   sA   The contents of the email

        :rtype: list(Content)
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   contents±  s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   content¹  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   s‰   The content(s) of the email

        :param contents: The content(s) of the email
        :type contents: Content, list(Content)
        N(   RH   RI   R(   (   R+   Ro   Rk   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRp   ½  s    c         C   sŽ   t  | t ƒ r! t | | ƒ } n  | j d k rK |  j | |  j ƒ |  _ n? |  j rf t |  j ƒ } n d } |  j | |  j d | ƒ|  _ d S(   sÔ   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
        s
   text/plaini    R8   N(   RH   R2   R   t	   mime_typeR;   R   t   lenR9   (   R+   Rp   Rq   R8   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR(   Ê  s    	c         C   s   |  j  S(   sH   The attachments to this email

        :rtype: list(Attachment)
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   attachmentsß  s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt
   attachmentç  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   s›   Add attachment(s) to this email

        :param attachment: Add attachment(s) to this email
        :type attachment: Attachment, list(Attachment)
        N(   RH   RI   t   add_attachment(   R+   Rt   t   a(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRt   ë  s    c         C   s   |  j  | |  j ƒ |  _ d S(   s‰   Add an attachment to this email

        :param attachment: Add an attachment to this email
        :type attachment: Attachment
        N(   R9   R   (   R+   Rt   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRu   ø  s    c         C   s   |  j  S(   sQ   The transactional template id for this email

        :rtype: TemplateId
        (   R#   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   template_id   s    c         C   s.   t  | t ƒ r | |  _ n t | ƒ |  _ d S(   s™   The transactional template id for this email

        :param value: The transactional template id for this email
        :type value: TemplateId
        N(   RH   R   R#   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRw     s    c         C   s   |  j  S(   sX   The block sections of code to be used as substitutions

        :rtype: Section
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   sections  s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   section  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   sg   The block sections of code to be used as substitutions

        :rtype: Section, list(Section)
        N(   RH   RI   t   add_section(   R+   Ry   Rf   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRy      s    c         C   s   |  j  | |  j ƒ |  _ d S(   s¨   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(   R9   R   (   R+   Ry   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyRz   ,  s    c         C   s   |  j  S(   sP   The categories assigned to this message

        :rtype: list(Category)
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt
   categories4  s    c         C   s   d  S(   N(    (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   category<  s    c         C   sA   t  | t ƒ r0 x+ | D] } |  j | ƒ q Wn |  j | ƒ d S(   sP   Add categories assigned to this message

        :rtype: list(Category)
        N(   RH   RI   t   add_category(   R+   R{   Rk   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR|   @  s    c         C   s   |  j  | |  j ƒ |  _ d S(   sJ   Add a category assigned to this message

        :rtype: Category
        N(   R9   R   (   R+   R|   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR}   L  s    c         C   s   |  j  S(   s=   The batch id for this email

        :rtype: BatchId
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   batch_idS  s    c         C   s   | |  _  d S(   st   The batch id for this email

        :param value: The batch id for this email
        :type value: BatchId
        N(   R   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR~   [  s    c         C   s   |  j  S(   sH   An object specifying unsubscribe behavior.

        :rtype: Asm
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   asmd  s    c         C   s   | |  _  d S(   sŽ   An object specifying unsubscribe behavior.

        :param value: An object specifying unsubscribe behavior.
        :type value: Asm
        N(   R   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR   l  s    c         C   s   |  j  S(   s\   The IP Pool that you would like to send this email from

        :rtype: IpPoolName
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   ip_pool_nameu  s    c         C   s   | |  _  d S(   s¯   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
        N(   R   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR€   }  s    c         C   s   |  j  S(   sG   The mail settings for this email

        :rtype: MailSettings
        (   R   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   mail_settings†  s    c         C   s   | |  _  d S(   sƒ   The mail settings for this email

        :param value: The mail settings for this email
        :type value: MailSettings
        N(   R   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR   Ž  s    c         C   s   |  j  S(   sO   The tracking settings for this email

        :rtype: TrackingSettings
        (   R$   (   R+   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   tracking_settings—  s    c         C   s   | |  _  d S(   s   The tracking settings for this email

        :param value: The tracking settings for this email
        :type value: TrackingSettings
        N(   R$   (   R+   Rb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR‚   Ÿ  s    c         C   sµ  i |  j  |  j ƒ d 6|  j  |  j ƒ d 6g  |  j p8 g  D] } | j ƒ  ^ q9 d 6g  |  j pa g  D] } | j ƒ  ^ qb d 6g  |  j pŠ g  D] } | j ƒ  ^ q‹ d 6|  j  |  j ƒ d 6|  j |  j	 ƒ d 6|  j |  j
 ƒ d 6g  |  j pì g  D] } | j ƒ  ^ qí d	 6|  j |  j ƒ d
 6|  j  |  j ƒ d 6|  j  |  j ƒ d 6|  j  |  j ƒ d 6|  j  |  j ƒ d 6|  j  |  j ƒ d 6|  j  |  j ƒ d 6|  j  |  j ƒ d 6} d „  | j ƒ  Dƒ S(   s¡   
        Get a JSON-ready representation of this Mail object.

        :returns: This Mail object, ready for use in a request body.
        :rtype: dict
        t   fromR'   RL   Rp   Rs   Rw   Rx   Rc   R{   Rh   Rl   R~   R   R€   R   R‚   Rn   c         S   sC   i  |  ]9 \ } } | d  k	 r | g  k r | i  k r | | “ q S(   N(   R   (   R=   t   keyRb   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pys
   <dictcomp>Ã  s   	 	(   RF   R%   R'   RL   R3   Ro   Rs   Rw   RD   Rx   Rc   R{   Rh   Rl   R~   R   R€   R   R‚   Rn   R<   (   R+   RQ   Rk   Rv   t   mail(    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR3   ¨  s&    ))))c      	   C   sË   |  d t  | j d ƒ ƒ d | j d ƒ d t  | j d ƒ ƒ ƒ } y | j ƒ  } Wn t k
 rq | j ƒ  } n X| j t | j ƒ  | j ƒ  ƒ ƒ x0 | j	 ƒ  D]" \ } } | j
 t | | ƒ ƒ q¡ W| S(   s   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   t   get_contentt   AttributeErrort   get_payloadR(   R   t   get_content_typet   stripR<   Re   R   (   t   clst   messageR…   t   bodyR?   R@   (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   from_EmailMessageÆ  s    		N(8   t   __name__t
   __module__t   __doc__R   RO   R1   R4   R9   R;   RD   RF   RV   t   propertyRL   RK   RW   t   setterR&   RZ   R[   R^   R_   R'   Rc   Rd   Re   RT   RM   Rh   Ri   Rj   Rl   Rm   R%   Rn   Ro   Rp   R(   Rs   Rt   Ru   Rw   Rx   Ry   Rz   R{   R|   R}   R~   R   R€   R   R‚   R3   t   classmethodRŽ   (    (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyR      s¦   -			
	
8	 		 									N('   R‘   Ra   R    R]   R   Rp   R   Ri   R   RR   R   R%   R   Rd   R   R.   R   Rq   R   RS   R	   R-   R
   Rn   R   Rl   R   R'   R   RT   R   Rw   R   RY   R   Rm   R   t   objectR   (    (    (    s<   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/mail.pyt   <module>   s&   