U
    gR                     @   s   d Z ddlmZmZmZ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 erlddlmZmZ G d	d
 d
eZdS )zRContains information about Telegram Passport data shared with the bot by the user.    )TYPE_CHECKINGOptionalSequenceTuple)EncryptedCredentials)EncryptedPassportElement)TelegramObject)parse_sequence_arg)JSONDict)BotCredentialsc                       s   e Zd ZdZdZddee eee	 d fddZ
edee	 ed ed  d	 fd
dZeeedf dddZeddddZ  ZS )PassportDataa  Contains information about Telegram Passport data shared with the bot by the user.

    Note:
        To be able to decrypt this object, you must pass your ``private_key`` to either
        :class:`telegram.ext.Updater` or :class:`telegram.Bot`. Decrypted data is then found in
        :attr:`decrypted_data` and the payload can be found in :attr:`decrypted_credentials`'s
        attribute :attr:`telegram.Credentials.nonce`.

    Args:
        data (Sequence[:class:`telegram.EncryptedPassportElement`]): Array with encrypted
            information about documents and other Telegram Passport elements that was shared with
            the bot.

            .. versionchanged:: 20.0
                |sequenceclassargs|

        credentials (:class:`telegram.EncryptedCredentials`)): Encrypted credentials.

    Attributes:
        data (Tuple[:class:`telegram.EncryptedPassportElement`]): Array with encrypted
            information about documents and other Telegram Passport elements that was shared with
            the bot.

            .. versionchanged:: 20.0
                |tupleclassattrs|

        credentials (:class:`telegram.EncryptedCredentials`): Encrypted credentials.


    )_decrypted_datacredentialsdataN
api_kwargs)r   r   r   c                   sL   t  j|d t|| _|| _d | _tdd |D |jg | _| 	  d S )Nr   c                 S   s   g | ]
}|j qS  )type).0xr   r   C/tmp/pip-unpacked-wheel-swnnwir2/telegram/_passport/passportdata.py
<listcomp>O   s     z)PassportData.__init__.<locals>.<listcomp>)
super__init__r	   r   r   r   tuplehashZ	_id_attrsZ_freeze)selfr   r   r   	__class__r   r   r   B   s    
zPassportData.__init__r   )r   botreturnc                    sN   |  |}|sdS t|d||d< t|d||d< t j||dS )z,See :meth:`telegram.TelegramObject.de_json`.Nr   r   )r   r    )Z_parse_datar   Zde_listgetr   de_jsonr   )clsr   r    r   r   r   r#   S   s    
zPassportData.de_json.)r!   c                    s*    j dkr$t fdd jD  _  j S )a  
        Tuple[:class:`telegram.EncryptedPassportElement`]: Lazily decrypt and return information
            about documents and other Telegram Passport elements which were shared with the bot.

        .. versionchanged:: 20.0
            Returns a tuple instead of a list.

        Raises:
            telegram.error.PassportDecryptionError: Decryption failed. Usually due to bad
                private/public key but can also suggest malformed/tampered data.
        Nc                 3   s&   | ]}t |    jV  qd S )N)r   Zde_json_decryptedZto_dictZget_botdecrypted_credentials)r   elementr   r   r   	<genexpr>p   s     z.PassportData.decrypted_data.<locals>.<genexpr>)r   r   r   r'   r   r'   r   decrypted_datab   s
    

zPassportData.decrypted_datar   c                 C   s   | j jS )a  
        :class:`telegram.Credentials`: Lazily decrypt and return credentials that were used
            to decrypt the data. This object also contains the user specified payload as
            `decrypted_data.payload`.

        Raises:
            telegram.error.PassportDecryptionError: Decryption failed. Usually due to bad
                private/public key but can also suggest malformed/tampered data.
        )r   r)   r'   r   r   r   r%   x   s    z"PassportData.decrypted_credentials)N)__name__
__module____qualname____doc__	__slots__r   r   r   r   r
   r   classmethodr#   propertyr   r)   r%   __classcell__r   r   r   r   r       s&     r   N)r-   typingr   r   r   r   Ztelegram._passport.credentialsr   Z+telegram._passport.encryptedpassportelementr   Ztelegram._telegramobjectr   Ztelegram._utils.argumentparsingr	   Ztelegram._utils.typesr
   Ztelegramr   r   r   r   r   r   r   <module>   s   