
    xh                     "     G d  de           ZdS )c                   p   e Zd Zd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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d!S )"PersonalizationzsA Personalization defines who should receive an individual message and
    how that message should be handled.
    c                     g | _         d| _        g | _        g | _        d| _        g | _        g | _        g | _        d| _        d| _	        dS )z@Create an empty Personalization and initialize member variables.N)
_tos_from_email_ccs_bccs_subject_headers_substitutions_custom_args_send_at_dynamic_template_dataselfs    X/var/www/html/what/lib/python3.11/site-packages/sendgrid/helpers/mail/personalization.py__init__zPersonalization.__init__   sR    		
 &*###    c                 2   t          |          }|j        dk    r|                     |           d S |j        dk    r|                     |           d S |j        dk    r|                     |           d S |j        dk    r	|| _        d S t          d          )NToCcBccFromz(Please use a To, From, Cc or Bcc object.)type__name__add_toadd_ccadd_bcc
from_email
ValueError)r   email
email_types      r   	add_emailzPersonalization.add_email   s    %[[
$&&KKF$&&KKF%''LLF&((#DOFCDDDr   c                 \   g }|D ]}t          |t                    r|d                                         n|j                                        t	          fd|D                       r@t          |t                    r|n|                                }|                    |           |S )Nr    c              3   T   K   | ]"}|d                                           k    V  #dS )r    N)lower).0unique_recipientrecipient_emails     r   	<genexpr>z9Personalization._get_unique_recipients.<locals>.<genexpr>(   sK        IY )//11_D     r   )
isinstancedictr%   r    allgetappend)r   
recipientsunique_recipients	recipientnew_unique_recipientr(   s        @r   _get_unique_recipientsz&Personalization._get_unique_recipients#   s    # 	? 	?I<FyRV<W<Wti066888]f]l]r]r]t]tO    ]n     ? 5?y$4O4O'dyyU^UbUbUdUd$!(()=>>>  r   c                 6    |                      | j                  S )zSA list of recipients for this Personalization.

        :rtype: list(dict)
        )r3   r   r   s    r   toszPersonalization.tos1        **49555r   c                     || _         d S N)r   r   values     r   r5   zPersonalization.tos9       			r   c                    |j         rTt          |j         t                    r |j         D ]}|                     |           n|                     |j                    |j        r|j        | _        |j        rEt          |j        t                    r|j        | _        n|j                                        | _        | j        	                    |                                           dS )zTAdd a single recipient to this Personalization.

        :type email: Email
        N)
substitutionsr*   listadd_substitutiondynamic_template_datasubjectstrr-   r   r.   )r   r    substitutions      r   r   zPersonalization.add_to=   s    
  	;%-t44 ;$)$7 8 8L)),77778 %%e&9:::& 	E).)DD&= 	3%--- 3$}$}0022	%%%%%r   c                     | j         S r8   r   r   s    r   r   zPersonalization.from_emailT   s    r   c                     || _         d S r8   rE   r9   s     r   r   zPersonalization.from_emailX   s     r   c                 8    |                                 | _        d S r8   )r-   r   r   r    s     r   set_fromzPersonalization.set_from\   s     99;;r   c                 6    |                      | j                  S )z`A list of recipients who will receive copies of this email.

        :rtype: list(dict)
        )r3   r   r   s    r   ccszPersonalization.ccs_   r6   r   c                     || _         d S r8   )r   r9   s     r   rK   zPersonalization.ccsg   r;   r   c                 ^    | j                             |                                           dS )zAdd a single recipient to receive a copy of this email.

        :param email: new recipient to be CCed
        :type email: Email
        N)r   r.   r-   rH   s     r   r   zPersonalization.add_cck   s(     		%%%%%r   c                 6    |                      | j                  S )zmA list of recipients who will receive blind carbon copies of this email.

        :rtype: list(dict)
        )r3   r   r   s    r   bccszPersonalization.bccss   s     **4:666r   c                     || _         d S r8   )r   r9   s     r   rO   zPersonalization.bccs{   s    


r   c                 ^    | j                             |                                           dS )zAdd 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-   rH   s     r   r   zPersonalization.add_bcc   s(     	
%))++&&&&&r   c                     | j         S )zThe subject of your email (within this Personalization).

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

        :rtype: string
        r	   r   s    r   rA   zPersonalization.subject   s     }r   c                     || _         d S r8   rS   r9   s     r   rA   zPersonalization.subject       r   c                     | j         S )zTThe headers for emails in this Personalization.

        :rtype: list(dict)
        r
   r   s    r   headerszPersonalization.headers   s     }r   c                     || _         d S r8   rW   r9   s     r   rX   zPersonalization.headers   rU   r   c                 ^    | j                             |                                           dS )zSAdd a single Header to this Personalization.

        :type header: Header
        N)r
   r.   r-   )r   headers     r   
add_headerzPersonalization.add_header   s(    
 	VZZ\\*****r   c                     | j         S )z]Substitutions to be applied within this Personalization.

        :rtype: list(dict)
        r   r   s    r   r=   zPersonalization.substitutions   s     ""r   c                     || _         d S r8   r^   r9   s     r   r=   zPersonalization.substitutions   s    #r   c                     t          |t                    s|                                }| j                            |           dS )zbAdd a new Substitution to this Personalization.

        :type substitution: Substitution
        N)r*   r+   r-   r   r.   )r   rC   s     r   r?   z Personalization.add_substitution   sD    
 ,-- 	.'++--L""<00000r   c                     | j         S )ziThe CustomArgs that will be carried along with this Personalization.

        :rtype: list(dict)
        r   r   s    r   custom_argszPersonalization.custom_args   s       r   c                     || _         d S r8   rb   r9   s     r   rc   zPersonalization.custom_args   s    !r   c                 ^    | j                             |                                           dS )zVAdd a CustomArg to this Personalization.

        :type custom_arg: CustomArg
        N)r   r.   r-   )r   
custom_args     r   add_custom_argzPersonalization.add_custom_arg   s+    
 	  !1!122222r   c                     | j         S )zA 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   s    r   send_atzPersonalization.send_at   s     }r   c                     || _         d S r8   ri   r9   s     r   rj   zPersonalization.send_at   rU   r   c                     | j         S )zData for dynamic transactional template.
        Should be JSON-serializable structure.

        :rtype: JSON-serializable structure
        )r   r   s    r   r@   z%Personalization.dynamic_template_data   s     **r   c                 f    t          |t                    s|                                }|| _        d S r8   )r*   r+   r-   r   r9   s     r   r@   z%Personalization.dynamic_template_data   s/    %&& 	 IIKKE&+###r   c                 (   i }dD ]!}t          | |          }|r|||dd         <   "t          | d          }|r||d<   dD ]}t          | |          }|r|||<   dD ]5}t          | |          }|r!i }|D ]}|                    |           |||<   6|S )z
        Get a JSON-ready representation of this Personalization.

        :returns: This Personalization, ready for use in a request body.
        :rtype: dict
        )r5   rK   rO   Nr   from)rA   rj   r@   )rX   r=   rc   )getattrupdate)r   personalizationkeyr:   
from_value	prop_namepropobjs           r   r-   zPersonalization.get   s     ) 	2 	2CD#&&E 2,1CRC)T<00
 	1&0OF#B 	- 	-CD#&&E -',$D 	5 	5I4++D 5 5 5CJJsOOO14OI..r   N)r   
__module____qualname____doc__r   r"   r3   propertyr5   setterr   r   rI   rK   r   rO   r   rA   rX   r\   r=   r?   rc   rg   rj   r@   r-    r   r   r   r      s        + + +E E E ! ! ! 6 6 X6 	Z  Z& & &.     X  ! ! !' ' ' 6 6 X6 	Z  Z& & & 7 7 X7 
[  [' ' '   X ^  ^   X ^  ^+ + + # # X# $ $ $1 1 1 ! ! X! " " "3 3 3   X ^  ^ + + X+ !, , "!,    r   r   N)objectr   r~   r   r   <module>r      sC   N N N N Nf N N N N Nr   