ó
º9—^c           @   s   d  e  f d „  ƒ  YZ d S(   t   Personalizationc           B   sˆ  e  Z d  Z d „  Z d „  Z e d „  ƒ Z e j d „  ƒ Z d „  Z e d „  ƒ Z	 e	 j d „  ƒ Z	 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 d „  Z e d „  ƒ Z e j d „  ƒ Z 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 d „  Z RS(   ss   A Personalization defines who should receive an individual message and
    how that message should be handled.
    c         C   sU   g  |  _  g  |  _ g  |  _ d |  _ g  |  _ g  |  _ g  |  _ d |  _ d |  _	 d S(   s@   Create an empty Personalization and initialize member variables.N(
   t   _tost   _ccst   _bccst   Nonet   _subjectt   _headerst   _substitutionst   _custom_argst   _send_att   _dynamic_template_data(   t   self(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   __init__   s    								c         C   s|   t  | ƒ } | j d k r, |  j | ƒ d  S| j d k rL |  j | ƒ d  S| j d k rl |  j | ƒ d  St d ƒ ‚ d  S(   Nt   Tot   Cct   Bccs"   Please use a To, Cc or Bcc object.(   t   typet   __name__t   add_tot   add_cct   add_bcct
   ValueError(   R   t   emailt
   email_type(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt	   add_email   s    c         C   s   |  j  S(   sS   A list of recipients for this Personalization.

        :rtype: list(dict)
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   tos   s    c         C   s   | |  _  d  S(   N(   R   (   R   t   value(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   '   s    c         C   s«   | j  rR t | j  t ƒ r? x1 | j  D] } |  j | ƒ q% WqR |  j | j  ƒ n  | j r‘ t | j t ƒ r| | j |  _ q‘ | j j ƒ  |  _ n  |  j j | j ƒ  ƒ d S(   sT   Add a single recipient to this Personalization.

        :type email: Email
        N(	   t   substitutionst
   isinstancet   listt   add_substitutiont   subjectt   strt   getR   t   append(   R   R   t   substitution(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   +   s    		c         C   s   |  j  S(   s`   A list of recipients who will receive copies of this email.

        :rtype: list(dict)
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   ccs=   s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR$   E   s    c         C   s   |  j  j | j ƒ  ƒ d S(   s‹   Add a single recipient to receive a copy of this email.

        :param email: new recipient to be CCed
        :type email: Email
        N(   R   R"   R!   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   I   s    c         C   s   |  j  S(   sm   A list of recipients who will receive blind carbon copies of this email.

        :rtype: list(dict)
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   bccsQ   s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR%   Y   s    c         C   s   |  j  j | j ƒ  ƒ d S(   s™   Add a single recipient to receive a blind carbon copy of this email.

        :param email: new recipient to be BCCed
        :type email: Email
        N(   R   R"   R!   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   ]   s    c         C   s   |  j  S(   s¾   The subject of your email (within this Personalization).

        Char length requirements, according to the RFC:
        https://stackoverflow.com/a/1592310

        :rtype: string
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   e   s    	c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   p   s    c         C   s   |  j  S(   sT   The headers for emails in this Personalization.

        :rtype: list(dict)
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   headerst   s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR&   |   s    c         C   s   |  j  j | j ƒ  ƒ d S(   sS   Add a single Header to this Personalization.

        :type header: Header
        N(   R   R"   R!   (   R   t   header(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt
   add_header€   s    c         C   s   |  j  S(   s]   Substitutions to be applied within this Personalization.

        :rtype: list(dict)
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   ‡   s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR      s    c         C   s<   t  | t ƒ r" |  j j | ƒ n |  j j | j ƒ  ƒ d S(   sb   Add a new Substitution to this Personalization.

        :type substitution: Substitution
        N(   R   t   dictR   R"   R!   (   R   R#   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR   “   s    c         C   s   |  j  S(   si   The CustomArgs that will be carried along with this Personalization.

        :rtype: list(dict)
        (   R   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   custom_args   s    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR*   ¥   s    c         C   s   |  j  j | j ƒ  ƒ d S(   sV   Add a CustomArg to this Personalization.

        :type custom_arg: CustomArg
        N(   R   R"   R!   (   R   t
   custom_arg(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   add_custom_arg©   s    c         C   s   |  j  S(   sÍ   A unix timestamp allowing you to specify when you want emails from
        this Personalization to be delivered. Scheduling more than 72 hours in
        advance is forbidden.

        :rtype: int
        (   R	   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   send_at°   s    c         C   s   | |  _  d  S(   N(   R	   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR-   º   s    c         C   s   |  j  S(   s   Data for dynamic transactional template.
        Should be JSON-serializeable structure.

        :rtype: JSON-serializeable structure
        (   R
   (   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   dynamic_template_data¾   s    c         C   s   | |  _  d  S(   N(   R
   (   R   R   (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR.   Ç   s    c         C   sæ   i  } x= d d d g D], } t  |  | ƒ } | r | | | d  <q q Wx9 d d d g D]( } t  |  | ƒ } | rV | | | <qV qV Wx] d d	 d
 g D]L } t  |  | ƒ } | r’ i  } x( | D] } | j | ƒ | | | <qº Wq’ q’ W| S(   s©   
        Get a JSON-ready representation of this Personalization.

        :returns: This Personalization, ready for use in a request body.
        :rtype: dict
        R   R$   R%   iÿÿÿÿR   R-   R.   R&   R   R*   (   t   getattrt   update(   R   t   personalizationt   keyR   t	   prop_namet   propt   obj(    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR!   Ë   s"    (   R   t
   __module__t   __doc__R   R   t   propertyR   t   setterR   R$   R   R%   R   R   R&   R(   R   R   R*   R,   R-   R.   R!   (    (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyR       s8   							
	
	N(   t   objectR    (    (    (    sG   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/mail/personalization.pyt   <module>   t    