
    xh                         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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                      e Zd ZdZ	 	 	 	 	 	 	 	 dLdZd ZdMdZd Zd	 Zd
 Z		 dNdZ
ed             ZdMdZed             Zej        dNd            Z	 dNdZed             Zej        dNd            Z	 dNdZed             Zej        	 	 	 dNd            Z	 	 	 dNd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"j        d-             Z"ed.             Z#ed/             Z$e$j        d0             Z$dOd1Z%ed2             Z&ed3             Z'e'j        d4             Z'd5 Z(ed6             Z)e)j        d7             Z)ed8             Z*ed9             Z+e+j        d:             Z+d; Z,ed<             Z-ed=             Z.e.j        d>             Z.d? Z/ed@             Z0e0j        dA             Z0edB             Z1e1j        dC             Z1edD             Z2e2j        dE             Z2edF             Z3e3j        dG             Z3edH             Z4e4j        dI             Z4dJ Z5e6dK             Z7dS )PMailz*Creates the response body for v3/mail/sendNFc	                 (   d| _         d| _        d| _        d| _        d| _        g | _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        d| _        d| _        d| _        d| _        d| _        ||| _        ||                     |||           ||| _        | |                     |t,          j                   | |                     |t,          j                   |"|                     |t,          j                   dS 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_reply_to_list_send_at_subject_template_id_tracking_settings
from_emailadd_tosubjectadd_contentr   textamphtml)	selfr(   	to_emailsr*   plain_text_contenthtml_contentamp_html_contentglobal_substitutionsis_multiples	            M/var/www/html/what/lib/python3.11/site-packages/sendgrid/helpers/mail/mail.py__init__zMail.__init__   s/   6 ! !#	!"" "& !(DO KK	#7EEE"DL)/???'-x|<<<#\8=99999 $#    c                 D    t          |                                           S )zA JSON-ready string representation of this Mail object.

        :returns: A JSON-ready string representation of this Mail object.
        :rtype: string
        )strgetr/   s    r6   __str__zMail.__str__S   s     488::r8       c                 :    |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_items	append_toindexs       r6   _ensure_appendzMail._ensure_append[   s)     O		***r8   c                 :    |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()
        r>   r@   )r/   rB   	insert_tos      r6   _ensure_insertzMail._ensure_inserti   s)     O	I&&&r8   c                 R    t                      }d |pg D             }d |D             S )z]Flatten a dict

        :param dicts: Flatten a dict
        :type dicts: list(dict)
        c                 6    g | ]}|                                 S  r;   ).0ds     r6   
<listcomp>z'Mail._flatten_dicts.<locals>.<listcomp>|   s     666Q666r8   c                 H    i | ]}|                                 D ]\  }}||	 S rK   )items)rM   rN   kvs       r6   
<dictcomp>z'Mail._flatten_dicts.<locals>.<dictcomp>}   s3    BBB		BB11BBBBr8   )dict)r/   dictsrN   list_of_dictss       r6   _flatten_dictszMail._flatten_dictsu   s8     FF66%+2666BBmBBBBr8   c                 2    ||                                 ndS )zGet 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
        NrL   )r/   from_objs     r6   _get_or_nonezMail._get_or_none   s     "*!5x||~~~4?r8   c                    |du rt          |t                    r>|D ]:}t                      }|                    |           |                     |           ;n8t                      }|                    |           |                     |           |Zt          |t                    r&|D ]!}| j        D ]}|                    |           "dS | j        D ]}|                    |           dS dS 	 | j        |         }d}n # t          $ r t                      }d}Y nw xY wt          |t                    r|D ]}|                    |           n|                    |           |Et          |t                    r|D ]}|                    |           n|                    |           |s|                     ||           dS 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rD   )	
isinstancelistr   	add_emailadd_personalizationpersonalizationsadd_substitutionr   
IndexError)	r/   emailsr4   r5   pemailpersonalizationsubstitutionhas_internal_personalizations	            r6   _set_emailszMail._set_emails   sx    $&$'' :# > >E&5&7&7O#--e444,,_====>
 #2"3"3))&111((999#/2D99 A(< = =!%!6 = =A..|<<<<== = "2 A A**+?@@@@ 0/A A5"&"8";/3,, 5 5 5"1"3"3/4,,,5 &$'' 2# 5 5E#--e44445  ))&111#/2D99 K(< G G'88FFFFG $445IJJJ/ C(((BBBBBC Cs   1D DDc                     | j         S )z]A list of one or more Personalization objects

        :rtype: list(Personalization)
        )r   r<   s    r6   rb   zMail.personalizations   s     %%r8   c                 H    |                      || j        |          | _        dS )zAdd 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)rE   r   )r/   rh   rD   s      r6   ra   zMail.add_personalization   s,     "&!4!4T3U"< "<r8   c                     d S NrK   r<   s    r6   tozMail.to       r8   c                    t          |t                    ru|D ]p}t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }|                     ||||           qdS t          |t                    rt          |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
        Nr>   r   )r^   r_   r:   r   tupler)   )r/   r0   r4   r5   rf   rg   s         r6   rp   zMail.to       i&& 	I" I IeS)) ,udOOEeU++ 3uQxq22EE#7aHHHHI I )S)) 0y$//	)U++ ;y|Yq\::	KK	#7aHHHHHr8   c                 z   t          |t                    r|D ]}t          |t                    rt          |d          }nVt          |t                    rt          |d         |d                   }n$t          |t
                    st          d          |                     ||||           dS t          |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
        Nr>   r   z<Please use a To/Cc/Bcc, tuple, or a str for a to_email list.)	r^   r_   r:   r   rs   r   
ValueErrorrk   rh   )r/   to_emailr4   r5   rf   rg   s         r6   r)   zMail.add_to   sN    h%% 	M! 	N 	NeS)) udOOEEu-- uQxq22EE#E511 $V     (<k1MMMM	N 	N (C(( .h--(E** 8hqk8A;77(E** -,X';[!LLLLLr8   c                     d S ro   rK   r<   s    r6   cczMail.cc  rq   r8   c                    t          |t                    ru|D ]p}t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }|                     ||||           qdS t          |t                    rt          |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
        Nr>   r   )r^   r_   r:   r   rs   add_ccr   )r/   	cc_emailsr4   r5   rf   rg   s         r6   ry   zMail.cc  rt   r8   c                    t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }t          |t                    r|j        }|                     ||||           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
        Nr>   r   r5   rf   )r^   r:   r   rs   r   rh   rk   )r/   cc_emailr4   r5   rf   s        r6   r{   zMail.add_cc7  s     h$$ 	*(D))Hh&& 	4(1+x{33Hh&& 	)(A*q 	 	J 	J 	J 	J 	Jr8   c                     d S ro   rK   r<   s    r6   bcczMail.bccN  rq   r8   c                    t          |t                    ru|D ]p}t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }|                     ||||           qdS t          |t                    rt          |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
        Nr>   r   )r^   r_   r:   r   rs   add_bcc)r/   
bcc_emailsr4   r5   rf   rg   s         r6   r   zMail.bccR  s   & j$'' 	K# J JeS)) -t,,EeU++ 4a%(33EU$8+qIIIIJ J *c** 3 T22
*e,, ? A
1>>
LL%9;JJJJJr8   c                    t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }t          |t                    r|j        }|                     ||||           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
        Nr>   r   r~   )r^   r:   r   rs   r   rh   rk   )r/   	bcc_emailr4   r5   rf   s        r6   r   zMail.add_bccs  s    $ i%% 	-It,,Ii'' 	8IaL)A,77Ii'' 	*)A #	 	 	 	 	 	 	r8   c                     | j         S )z;The global Subject object

        :rtype: Subject
        )r%   r<   s    r6   r*   zMail.subject       }r8   c                 @   t          |t                    rt|j        d	 | j        |j                 }d}n # t          $ r t                      }d}Y nw xY w|j        |_        |s|                     ||j                   dS dS || _        dS t          |          | _        dS )z|The subject of the email(s)

        :param value: The subject of the email(s)
        :type value: Subject, string
        NTFr]   )	r^   r   rh   r   rd   r   r*   ra   r%   r/   valuerh   rj   s       r6   r*   zMail.subject  s     eW%% 	+$09.u/DE $3700! 9 9 9&5&7&7O380009 +0-'3 5,,'#3 - 5 5 5 5 55 5
 !&#ENNDMMM   3 AAc                     | j         S )zFA list of global Header objects

        :rtype: list(Header)
        )r   r<   s    r6   headerszMail.headers  r   r8   c                     d S ro   rK   r<   s    r6   headerzMail.header  rq   r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zAdd 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)r^   r_   
add_header)r/   r   hs      r6   r   zMail.header  s^     gt$$ 	% # #""""# # OOG$$$$$r8   c                    |j         	 | j        |j                  }d}n # t          $ r t                      }d}Y nw xY wt	          |t
                    rNt          |                                          d         \  }}|                    t          ||                     n|                    |           |s| 
                    ||j                    dS dS t	          |t
                    rZt          |                                          d         \  }}|                     t          ||          | j                  | _        dS |                     || j                  | _        dS )zAdd 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
        NTFr>   r]   )rh   r   rd   r   r^   rU   r_   rQ   r   r
   ra   rE   r   )r/   r   rh   rj   rR   rS   s         r6   r   zMail.add_header  s    !-5*6+AB  /3,, 5 5 5"1"3"3/4,,,5 &$'' 3fllnn--a0A**6!Q<<8888**6222/ 2((# 0 ) 2 2 2 2 22 2
 &$'' Kfllnn--a0A $ 3 31aLL$-!1 !1 !% 3 3FDM J J    ;;c                     d S ro   rK   r<   s    r6   ri   zMail.substitution  rq   r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zAdd substitutions to the email

        :param value: Add substitutions to the email
        :type value: Substitution, list(Substitution)
        N)r^   r_   rc   )r/   ri   ss      r6   ri   zMail.substitution  sb     lD)) 	0! ) )%%a(((() ) !!,/////r8   c                    |j         rm	 | j        |j                  }d}n # t          $ r t                      }d}Y nw xY w|                    |           |s|                     ||j                    dS dS t          |t                    r&|D ]!}| j        D ]}|                    |           "dS | j        D ]}|                    |           dS )zAdd a substitution to the email

        :param value: Add a substitution to the email
        :type value: Substitution
        TFr]   N)	rh   r   rd   r   rc   ra   r^   r_   rb   )r/   ri   rh   rj   r   rf   s         r6   rc   zMail.add_substitution  sQ    ' 	55*<+GH  /3,, 5 5 5"1"3"3/4,,,5 ,,\:::/ I((#<+G ) I I I I II I ,-- 5% . .A!2 . .**1----.. . . 5 5A&&|44445 5r   c                     | j         S )zLA list of global CustomArg objects

        :rtype: list(CustomArg)
        r   r<   s    r6   custom_argszMail.custom_args         r8   c                     | j         S ro   r   r<   s    r6   
custom_argzMail.custom_arg"  s      r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zAdd 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)r^   r_   add_custom_arg)r/   r   cs      r6   r   zMail.custom_arg&  sb     j$'' 	, ' '##A&&&&' ' 
+++++r8   c                    |j         	 | j        |j                  }d}n # t          $ r t                      }d}Y nw xY wt	          |t
                    rNt          |                                          d         \  }}|                    t          ||                     n|                    |           |s| 
                    ||j                    dS dS t	          |t
                    rZt          |                                          d         \  }}|                     t          ||          | j                  | _        dS |                     || j                  | _        dS )zAdd 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
        NTFr>   r]   )rh   r   rd   r   r^   rU   r_   rQ   r   r   ra   rE   r   )r/   r   rh   rj   rR   rS   s         r6   r   zMail.add_custom_arg4  s    %15*:+EF  /3,, 5 5 5"1"3"3/4,,,5 *d++ ;j..0011!4A..yA????..z:::/ G((#:+E ) G G G G GG G *d++ 3j..0011!4A$($7$7aOOT%6%8 %8!!! %)$7$7 1%3 %3!!!r   c                     | j         S )z9The global SendAt object

        :rtype: SendAt
        )r$   r<   s    r6   send_atzMail.send_atT  r   r8   c                 @   t          |t                    rt|j        d	 | j        |j                 }d}n # t          $ r t                      }d}Y nw xY w|j        |_        |s|                     ||j                   dS dS || _        dS t          |          | _        dS )zA 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
        NTFr]   )	r^   r   rh   r   rd   r   r   ra   r$   r   s       r6   r   zMail.send_at\  s     eV$$ 	*$09.u/DE $3700! 9 9 9&5&7&7O380009 +0-'3 F,,'u/D - F F F F FF F !&"5MMDMMMr   c                     d S ro   rK   r<   s    r6   dynamic_template_datazMail.dynamic_template_datax  rq   r8   c                    t          |t                    st          |          }	 | j        |j                 }d}n # t          $ r t                      }d}Y nw xY w|j        |_        |s|                     ||j                   dS dS )zData for a transactional template

        :param value: Data for a transactional template
        :type value: DynamicTemplateData, a JSON-serializable structure
        TFr]   N)r^   r   r   rh   rd   r   r   ra   r   s       r6   r   zMail.dynamic_template_data|  s     %!455 	/'..E	1"4U5JKO+/(( 	1 	1 	1-//O+0(((	1 160K-+ 	>$$u'< % > > > > >	> 	>s   ; AAc                     | j         S )z>The email address of the sender

        :rtype: From
        )r   r<   s    r6   r(   zMail.from_email       r8   c                     t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }|| _        dS )zThe email address of the sender

        :param value: The email address of the sender
        :type value: From, str, tuple
        Nr>   r   )r^   r:   r	   rs   r   r/   r   s     r6   r(   zMail.from_email  s\     eS!! 	&%%EeU## 	-q58,,E r8   c                     | j         S )z<The reply to email address

        :rtype: ReplyTo
        )r"   r<   s    r6   reply_tozMail.reply_to       ~r8   c                     t          |t                    rt          |d          }t          |t                    rt          |d         |d                   }|| _        dS )z~The reply to email address

        :param value: The reply to email address
        :type value: ReplyTo, str, tuple
        Nr>   r   )r^   r:   r   rs   r"   r   s     r6   r   zMail.reply_to  sY     eS!! 	)E4((EeU## 	0E!HeAh//Er8   c                     | j         S )zPA list of ReplyTo email addresses

        :rtype: list(ReplyTo), tuple
        )r#   r<   s    r6   reply_to_listzMail.reply_to_list       ""r8   c                     t          |t                    r[|D ]O}t          |t                    r*t          |j        t                    st          d          At          d          || _        dS dS )zA list of ReplyTo email addresses

        :param value: A list of ReplyTo email addresses
        :type value: list(ReplyTo), tuple
        z;You must provide an email for each entry in a reply_to_listz2Please use a list of ReplyTos for a reply_to_list.N)r^   r_   r   rg   r:   rv   r#   )r/   r   replys      r6   r   zMail.reply_to_list  s     eT"" 		(  eW-- %ek377 h()fgggh %L   #(D		( 		(r8   c                     | j         S )zAThe contents of the email

        :rtype: list(Content)
        )r   r<   s    r6   contentszMail.contents  r   r8   c                     d S ro   rK   r<   s    r6   contentzMail.content  rq   r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zThe content(s) of the email

        :param contents: The content(s) of the email
        :type contents: Content, list(Content)
        N)r^   r_   r+   )r/   r   r   s      r6   r   zMail.content  sb     h%% 	' $ $  ####$ $ X&&&&&r8   c                 <   t          |t                    rt          ||          }|j        t          j        k    r"|                     || j                  | _        dS |j        t          j        k    rj| j        r=| j        D ]4}|j        t          j        k    rd} n|j        t          j	        k    rd} n5nd}| 
                    || j        |          | _        dS | j        rt          | j                  }nd}| 
                    || j        |          | _        dS )zAdd 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   r>   r]   N)r^   r:   r   	mime_typer   r,   rH   r   r-   r.   rE   len)r/   r   r   _contentrD   s        r6   r+   zMail.add_content  s2    gs## 	2i11G--!00$.IIDNNN(,..~ 
 $  H)X]:: !!+x}<< ! = !00u 1 6 6DNNN ~ DN++!00u 1 6 6DNNNr8   c                     | j         S )zHThe attachments to this email

        :rtype: list(Attachment)
        )r   r<   s    r6   attachmentszMail.attachments  r   r8   c                     d S ro   rK   r<   s    r6   
attachmentzMail.attachment  rq   r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zAdd attachment(s) to this email

        :param attachment: Add attachment(s) to this email
        :type attachment: Attachment, list(Attachment)
        N)r^   r_   add_attachment)r/   r   as      r6   r   zMail.attachment  sb     j$'' 	, ' '##A&&&&' ' 
+++++r8   c                 F    |                      || j                  | _        dS )zAdd an attachment to this email

        :param attachment: Add an attachment to this email
        :type attachment: Attachment
        N)rE   r   )r/   r   s     r6   r   zMail.add_attachment*  s%     !//
D<MNNr8   c                     | j         S )zQThe transactional template id for this email

        :rtype: TemplateId
        )r&   r<   s    r6   template_idzMail.template_id2  r   r8   c                 j    t          |t                    r	|| _        dS t          |          | _        dS )zThe transactional template id for this email

        :param value: The transactional template id for this email
        :type value: TemplateId
        N)r^   r   r&   r   s     r6   r   zMail.template_id:  s:     eZ(( 	2 %D *5 1 1Dr8   c                     | j         S )zXThe block sections of code to be used as substitutions

        :rtype: Section
        )r   r<   s    r6   sectionszMail.sectionsF  r   r8   c                     d S ro   rK   r<   s    r6   sectionzMail.sectionN  rq   r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zgThe block sections of code to be used as substitutions

        :rtype: Section, list(Section)
        N)r^   r_   add_section)r/   r   r   s      r6   r   zMail.sectionR  sb     gt$$ 	& $ $  ####$ $ W%%%%%r8   c                 F    |                      || j                  | _        dS )zA 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)rE   r   )r/   r   s     r6   r   zMail.add_section^  s!     ,,WdnEEr8   c                     | j         S )zPThe categories assigned to this message

        :rtype: list(Category)
        )r   r<   s    r6   
categorieszMail.categoriesf  r   r8   c                     d S ro   rK   r<   s    r6   categoryzMail.categoryn  rq   r8   c                     t          |t                    r|D ]}|                     |           dS |                     |           dS )zPAdd categories assigned to this message

        :rtype: list(Category)
        N)r^   r_   add_category)r/   r   r   s      r6   r   zMail.categoryr  sb     j$'' 	* % %!!!$$$$% % j)))))r8   c                 F    |                      || j                  | _        dS )zJAdd a category assigned to this message

        :rtype: Category
        N)rE   r   )r/   r   s     r6   r   zMail.add_category~  s%    
  ..x9IJJr8   c                     | j         S )z=The batch id for this email

        :rtype: BatchId
        r   r<   s    r6   batch_idzMail.batch_id  r   r8   c                     || _         dS )ztThe batch id for this email

        :param value: The batch id for this email
        :type value: BatchId
        Nr   r   s     r6   r   zMail.batch_id  s     r8   c                     | j         S )zHAn object specifying unsubscribe behavior.

        :rtype: Asm
        r   r<   s    r6   asmzMail.asm  s     yr8   c                     || _         dS )zAn object specifying unsubscribe behavior.

        :param value: An object specifying unsubscribe behavior.
        :type value: Asm
        Nr   r   s     r6   r   zMail.asm  s     			r8   c                     | j         S )z\The IP Pool that you would like to send this email from

        :rtype: IpPoolName
        r    r<   s    r6   ip_pool_namezMail.ip_pool_name  s     !!r8   c                     || _         dS )zThe 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   r   s     r6   r   zMail.ip_pool_name  s     #r8   c                     | j         S )zGThe mail settings for this email

        :rtype: MailSettings
        r!   r<   s    r6   mail_settingszMail.mail_settings  r   r8   c                     || _         dS )zThe mail settings for this email

        :param value: The mail settings for this email
        :type value: MailSettings
        Nr   r   s     r6   r   zMail.mail_settings  s     $r8   c                     | j         S )zOThe tracking settings for this email

        :rtype: TrackingSettings
        r'   r<   s    r6   tracking_settingszMail.tracking_settings  s     &&r8   c                     || _         dS )zThe tracking settings for this email

        :param value: The tracking settings for this email
        :type value: TrackingSettings
        Nr   r   s     r6   r   zMail.tracking_settings  s     #(r8   c                    i d|                      | j                  d|                      | j                  dd | j        pg D             dd | j        pg D             dd | j        pg D             d	|                      | j                  d
|                     | j                  d|                     | j	                  dd | j
        pg D             d|                     | j                  d|                      | j                  d|                      | j                  d|                      | j                  d|                      | j                  d|                      | j                  d|                      | j                  d|                      | j                  dd | j        pg D             i}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
        fromr*   rb   c                 6    g | ]}|                                 S rK   rL   )rM   rf   s     r6   rO   zMail.get.<locals>.<listcomp>  s      N N NQ N N Nr8   r   c                 6    g | ]}|                                 S rK   rL   rM   r   s     r6   rO   zMail.get.<locals>.<listcomp>  s     ===A===r8   r   c                 6    g | ]}|                                 S rK   rL   )rM   r   s     r6   rO   zMail.get.<locals>.<listcomp>  s     DDDAEEGGDDDr8   r   r   r   r   c                 6    g | ]}|                                 S rK   rL   r   s     r6   rO   zMail.get.<locals>.<listcomp>  s     BBBq15577BBBr8   r   r   r   r   r   r   r   r   r   c                 6    g | ]}|                                 S rK   rL   )rM   rs     r6   rO   zMail.get.<locals>.<listcomp>  s     HHH!aeeggHHHr8   c                 6    i | ]\  }}||g k    |i k    ||S ro   rK   )rM   keyr   s      r6   rT   zMail.get.<locals>.<dictcomp>  s>     F F FzsE$"" U9Dr8   )r[   r(   r*   rb   r   r   r   rX   r   r   r   r   r   r   r   r   r   r   r   r   rQ   )r/   mails     r6   r;   zMail.get  sV   
D%%do66
t((66
  N N$2G2M2 N N N
 ==)<"===	

 DDT-=-CDDD
 4,,T-=>>
 ++DM::
 t**4<88
 BBDO,ArBBB
 4..t/?@@
 t((66
 ))$-88
 4$$TX..
 D--d.?@@
 T..t/ABB
   !2!243I!J!J!
" ))$-88#
$ HHt/A/GRHHH%
 
*F FTZZ\\ F F F 	Fr8   c           	      D    | t          |                    d                    |                    d          t          |                    d                              }	 |                                }n$# t          $ r |                                }Y nw xY w|                    t          |                                |                                                     |	                                D ](\  }}|
                    t          ||                     )|S )zCreate a Mail object from an instance of
        email.message.EmailMessage.

        :type message: email.message.EmailMessage
        :rtype: Mail
        r	   r   r   )r(   r*   r0   )r   r;   get_contentAttributeErrorget_payloadr+   r   get_content_typestriprQ   r   r
   )clsmessager   bodyrR   rS   s         r6   from_EmailMessagezMail.from_EmailMessage  s    sW[[0011KK	**GKK--..
 
 

	)&&((DD 	) 	) 	)&&((DDD	) 	$$&&JJLL
 
 	 	 	 MMOO 	* 	*DAqOOF1aLL))))s   #A8 8BB)NNNNNNNF)r>   )NFr>   ro   )8__name__
__module____qualname____doc__r7   r=   rE   rH   rX   r[   rk   propertyrb   ra   rp   setterr)   ry   r{   r   r   r*   r   r   r   ri   rc   r   r   r   r   r   r(   r   r   r   r   r+   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   classmethodr  rK   r8   r6   r   r      s       44 #!!%:: :: :: ::x     
 
 
C C C@ @ @ KL7C 7C 7C 7Cr & & X&	< 	< 	< 	<   X YI I I YI8 MN!M !M !M !MF   X YI I I YI8 MNJ J J J.   X 	Z "&K K K ZKF "&   <   X ^+ + ^+4   X   X ]
% 
% ]
%K K K@   X 
0 
0 
05 5 58 ! ! X! ! ! X! , , ,3 3 3@   X ^* * ^*6   X !> > "!>(     X  
! 
! 
!   X _
 
 _
 # # X# ( ( ("   X   X ^
' 
' ^
'!6 !6 !6 !6F ! ! X!   X 
, 
, 
,O O O ! ! X! 	2 	2 	2   X   X ^	& 	& ^	&F F F     X    X _	* 	* _	*K K K   X _  _   X 	Z  Z " " X" # # # # # X# $ $ $ ' ' X' ( ( (F F F>   [  r8   r   N)#r  r   r   r   r   r   r   r   r   r   r   rg   r   r(   r	   r   r
   r   r   rh   r   r   r   r   r   r*   r   ri   r   r   r   rw   r   objectr   rK   r8   r6   <module>r     si   8 8                   ! ! ! ! ! ! 6 6 6 6 6 6                         , , , , , ,                   & & & & & & # # # # # #      } } } } }6 } } } } }r8   