o
    wÔ+f8  ã                   @   s`   zd dl Z W n ey   d dlmZ  Y nw zeZW n ey%   eZY nw G dd„ deƒZdS )é    Nc                   @   sÒ   e Zd ZdZ						ddd„Zedd„ ƒZejdd„ ƒZed	d
„ ƒZejdd
„ ƒZedd„ ƒZ	e	jdd„ ƒZ	edd„ ƒZ
e
jdd„ ƒZ
edd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZdd„ Zdd„ ZdS )ÚEmailz'An email address with an optional name.Nr   c                 C   sX   d| _ d| _|| _|r|s|  |¡ n|dur|| _|dur!|| _|| _|| _|| _dS )aÅ  Create an Email with the given address and name.

        Either fill the separate name and email fields, or pass all information
        in the email parameter (e.g. email="dude Fella <example@example.com>").
        :param email: Email address, or name and address in standard format.
        :type email: string, optional
        :param name: Name for this sender or recipient.
        :type name: string, optional
        :param substitutions: String substitutions to be applied to the email.
        :type substitutions: list(Substitution), optional
        :param subject: Subject for this sender or recipient.
        :type subject: string, optional
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional
        :param dynamic_template_data: Data for a dynamic transactional template.
        :type dynamic_template_data: DynamicTemplateData, optional
        N)	Ú_nameÚ_emailÚ_personalizationÚparse_emailÚemailÚnameÚ_substitutionsÚ_dynamic_template_dataÚ_subject)Úselfr   r   ÚsubstitutionsÚsubjectÚpÚdynamic_template_data© r   úN/var/www/html/venv/lib/python3.10/site-packages/sendgrid/helpers/mail/email.pyÚ__init__   s   
zEmail.__init__c                 C   ó   | j S )zAName associated with this email.

        :rtype: string
        )r   ©r   r   r   r   r   >   ó   z
Email.namec                 C   s$   |du st |tƒstdƒ‚|| _dS )z}Name associated with this email.

        :param value: Name associated with this email.
        :type value: string
        Nzname must be of type string.)Ú
isinstanceÚ
basestringÚ	TypeErrorr   ©r   Úvaluer   r   r   r   F   s   
c                 C   r   )zçEmail address.

        See http://tools.ietf.org/html/rfc3696#section-3 and its errata
        http://www.rfc-editor.org/errata_search.php?rfc=3696 for information
        on valid email addresses.

        :rtype: string
        ©r   r   r   r   r   r   R   ó   
zEmail.emailc                 C   ó
   || _ dS )aÈ  Email address.

        See http://tools.ietf.org/html/rfc3696#section-3 and its errata
        http://www.rfc-editor.org/errata_search.php?rfc=3696 for information
        on valid email addresses.

        :param value: Email address.
        See http://tools.ietf.org/html/rfc3696#section-3 and its errata
        http://www.rfc-editor.org/errata_search.php?rfc=3696 for information
        on valid email addresses.
        :type value: string
        Nr   r   r   r   r   r   ^   s   
c                 C   r   )ak  A list of Substitution objects. These substitutions will apply to
           the text and html content of the body of your email, in addition
           to the subject and reply-to parameters. The total collective size
           of your substitutions may not exceed 10,000 bytes per
           personalization object.

        :rtype: list(Substitution)
        ©r	   r   r   r   r   r   n   r   zEmail.substitutionsc                 C   r   )a­  A list of Substitution objects. These substitutions will apply to
        the text and html content of the body of your email, in addition to
        the subject and reply-to parameters. The total collective size of
        your substitutions may not exceed 10,000 bytes per personalization
        object.

        :param value: A list of Substitution objects. These substitutions will
        apply to the text and html content of the body of your email, in
        addition to the subject and reply-to parameters. The total collective
        size of your substitutions may not exceed 10,000 bytes per
        personalization object.
        :type value: list(Substitution)
        Nr   r   r   r   r   r   z   s   
c                 C   r   )zXData for a dynamic transactional template.

        :rtype: DynamicTemplateData
        ©r
   r   r   r   r   r   ‹   r   zEmail.dynamic_template_datac                 C   r   )z‡Data for a dynamic transactional template.

        :param value: DynamicTemplateData
        :type value: DynamicTemplateData
        Nr    r   r   r   r   r   “   ó   
c                 C   r   )zFSubject for this sender or recipient.

        :rtype: string
        ©r   r   r   r   r   r   œ   r   zEmail.subjectc                 C   r   )z‘Subject for this sender or recipient.

        :param value: Subject for this sender or recipient.
        :type value: string, optional
        Nr"   r   r   r   r   r   ¤   r!   c                 C   r   )zmThe Personalization object or Personalization object index

        :rtype: Personalization, integer
        ©r   r   r   r   r   Úpersonalization­   r   zEmail.personalizationc                 C   r   )zÙThe Personalization object or Personalization object index

        :param value: The Personalization object or Personalization object
                      index
        :type value: Personalization, integer
        Nr#   r   r   r   r   r$   µ   s   
c                 C   sB   t  |¡\}}d|vr|}d}|sd}|sd}|| _|| _||fS )zÜAllows passing emails as "Example Name <example@example.com>"

        :param email_info: Allows passing emails as
                           "Example Name <example@example.com>"
        :type email_info: string
        ú@N)Úrfc822Ú	parseaddrr   r   )r   Ú
email_infor   r   r   r   r   r   ¿   s   zEmail.parse_emailc                 C   s0   i }| j dur| j |d< | jdur| j|d< |S )z•
        Get a JSON-ready representation of this Email.

        :returns: This Email, ready for use in a request body.
        :rtype: dict
        Nr   r   )r   r   )r   r   r   r   r   Úget×   s   



z	Email.get)NNNNr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   Úsetterr   r   r   r   r$   r   r)   r   r   r   r   r      sF    
ú.











	r   )	r&   ÚImportErrorÚemail.utilsÚutilsr   Ú	NameErrorÚstrÚobjectr   r   r   r   r   Ú<module>   s    ÿþ