o
    GChQ                     @   sh  d Z ddlmZ ddlmZ ddl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 dd
lmZ ddlmZmZ ddlmZ erRddlmZ G dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G d d! d!eZ#G d"d# d#eZ$G d$d% d%eZ%d&S )'zAThis module contains the classes for Telegram Stars transactions.    )Sequence)datetime)TYPE_CHECKINGFinalOptional)	constants)	PaidMedia)TelegramObject)User)enum)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)JSONDict)Botc                	       s   e Zd ZU dZdZejjZee	 e
d< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 ddde	d	ee d
df fddZe	ddee ded d
ed  f fddZ  ZS )RevenueWithdrawalStatea;  This object escribes the state of a revenue withdrawal operation. Currently, it can be one
    of:

    * :class:`telegram.RevenueWithdrawalStatePending`
    * :class:`telegram.RevenueWithdrawalStateSucceeded`
    * :class:`telegram.RevenueWithdrawalStateFailed`

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` is equal.

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): The type of the state.

    Attributes:
        type (:obj:`str`): The type of the state.
    typePENDING	SUCCEEDEDFAILEDN
api_kwargsr   r   returnc                   6   t  j|d ttj||| _| jf| _|   d S Nr   )	super__init__r   
get_memberr   RevenueWithdrawalStateTyper   	_id_attrs_freezeselfr   r   	__class__ P/var/www/html/govbot/env/lib/python3.10/site-packages/telegram/_payment/stars.pyr   D      
zRevenueWithdrawalState.__init__databotr   c                    sf   |  |}|s	dS | jt| jt| jti}| tu r+|d|v r+||	d j
||dS t j
||dS )a[  Converts JSON data to the appropriate :class:`RevenueWithdrawalState` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`): The bot associated with this object.

        Returns:
            The Telegram object.

        Nr   r)   r*   )_parse_datar   RevenueWithdrawalStatePendingr   RevenueWithdrawalStateSucceededr   RevenueWithdrawalStateFailedr   getpopde_jsonr   clsr)   r*   _class_mappingr$   r&   r'   r2   K   s   
zRevenueWithdrawalState.de_jsonN)__name__
__module____qualname____doc__	__slots__r   r   r   r   str__annotations__r   r   r   r   r   classmethodr2   __classcell__r&   r&   r$   r'   r   '   s&   
 $r   c                       8   e Zd ZdZdZdddee ddf fddZ  ZS )	r-   zThe withdrawal is in progress.

    .. versionadded:: 21.4

    Attributes:
        type (:obj:`str`): The type of the state, always
            :tg-const:`telegram.RevenueWithdrawalState.PENDING`.
    r&   Nr   r   r   c                      t  jtj|d |   d S N)r   r   )r   r   r   r   r!   r#   r   r$   r&   r'   r   w      z&RevenueWithdrawalStatePending.__init__	r7   r8   r9   r:   r;   r   r   r   r?   r&   r&   r$   r'   r-   k       	(r-   c                	       sn   e Zd ZdZdZdddededee ddf fd	d
Z	e
	ddee ded ded  f fddZ  ZS )r.   a  The withdrawal succeeded.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`date` are equal.

    .. versionadded:: 21.4

    Args:
        date (:obj:`datetime.datetime`): Date the withdrawal was completed as a datetime object.
        url (:obj:`str`): An HTTPS URL that can be used to see transaction details.

    Attributes:
        type (:obj:`str`): The type of the state, always
            :tg-const:`telegram.RevenueWithdrawalState.SUCCEEDED`.
        date (:obj:`datetime.datetime`): Date the withdrawal was completed as a datetime object.
        url (:obj:`str`): An HTTPS URL that can be used to see transaction details.
    )dateurlNr   rG   rH   r   r   c                   sZ   t  jtj|d |   || _|| _| j| jf| _W d    d S 1 s&w   Y  d S rB   )	r   r   r   r   	_unfrozenrG   rH   r   r    )r#   rG   rH   r   r$   r&   r'   r      s   
"z(RevenueWithdrawalStateSucceeded.__init__r)   r*   r   c                    sB   |  |}|s	dS t|}t|dd|d|d< t j||dS )z4See :meth:`telegram.RevenueWithdrawalState.de_json`.NrG   tzinfor+   )r,   r   r   r0   r   r2   r4   r)   r*   
loc_tzinfor$   r&   r'   r2      s   
z'RevenueWithdrawalStateSucceeded.de_jsonr6   )r7   r8   r9   r:   r;   r   r<   r   r   r   r>   r2   r?   r&   r&   r$   r'   r.   |   s,    r.   c                       r@   )	r/   zThe withdrawal failed and the transaction was refunded.

    .. versionadded:: 21.4

    Attributes:
        type (:obj:`str`): The type of the state, always
            :tg-const:`telegram.RevenueWithdrawalState.FAILED`.
    r&   Nr   r   r   c                   rA   rB   )r   r   r   r   r!   rC   r$   r&   r'   r      rD   z%RevenueWithdrawalStateFailed.__init__rE   r&   r&   r$   r'   r/      rF   r/   c                	       s   e Zd ZU dZdZejjZee	 e
d< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 ejjZee	 e
d< 	 dd	d
e	dee ddf fddZe	ddee ded ded  f fddZ  ZS )TransactionPartnerau  This object describes the source of a transaction, or its recipient for outgoing
    transactions. Currently, it can be one of:

    * :class:`TransactionPartnerUser`
    * :class:`TransactionPartnerFragment`
    * :class:`TransactionPartnerTelegramAds`
    * :class:`TransactionPartnerOther`

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` is equal.

    .. versionadded:: 21.4

    Args:
        type (:obj:`str`): The type of the transaction partner.

    Attributes:
        type (:obj:`str`): The type of the transaction partner.
    r   FRAGMENTOTHERTELEGRAM_ADSTELEGRAM_APIUSERNr   r   r   r   c                   r   r   )	r   r   r   r   r   TransactionPartnerTyper   r    r!   r"   r$   r&   r'   r      r(   zTransactionPartner.__init__r)   r*   r   c              
      s   |  |}|du rdS |s| tu rdS | jt| jt| jt| jt	| j
ti}| tu r;|d|v r;||d j||dS t j||dS )aW  Converts JSON data to the appropriate :class:`TransactionPartner` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`): The bot associated with this object.

        Returns:
            The Telegram object.

        Nr   r+   )r,   rN   rO   TransactionPartnerFragmentrS   TransactionPartnerUserrQ   TransactionPartnerTelegramAdsrR   TransactionPartnerTelegramApirP   TransactionPartnerOtherr0   r1   r2   r   r3   r$   r&   r'   r2      s   
zTransactionPartner.de_jsonr6   )r7   r8   r9   r:   r;   r   rT   rO   r   r<   r=   rP   rQ   rR   rS   r   r   r   r>   r2   r?   r&   r&   r$   r'   rN      s.   
 $rN   c                	       sr   e Zd ZdZdZ	dddded dee ddf fd	d
Ze	ddee ded ded  f fddZ	  Z
S )rU   a  Describes a withdrawal transaction with Fragment.

    .. versionadded:: 21.4

    Args:
        withdrawal_state (:class:`telegram.RevenueWithdrawalState`, optional): State of the
            transaction if the transaction is outgoing.

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.FRAGMENT`.
        withdrawal_state (:class:`telegram.RevenueWithdrawalState`): Optional. State of the
            transaction if the transaction is outgoing.
    )withdrawal_stateNr   rZ   r   r   r   c                   sF   t  jtj|d |   || _W d    d S 1 sw   Y  d S rB   )r   r   rN   rO   rI   rZ   )r#   rZ   r   r$   r&   r'   r   $  s   
"z#TransactionPartnerFragment.__init__r)   r*   r   c                    s8   |  |}|s	dS t|d||d< t j||dS )0See :meth:`telegram.TransactionPartner.de_json`.NrZ   r+   )r,   r   r2   r0   r   r4   r)   r*   r$   r&   r'   r2   /  s   

z"TransactionPartnerFragment.de_jsonr6   )r7   r8   r9   r:   r;   r   r   r   r>   r2   r?   r&   r&   r$   r'   rU     s,    rU   c                       s   e Zd ZdZdZ			ddddddee deee  d	ee d
ee	 ddf fddZ
e	ddee	 ded ded  f fddZ  ZS )rV   a  Describes a transaction with a user.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`user` are equal.

    .. versionadded:: 21.4

    Args:
        user (:class:`telegram.User`): Information about the user.
        invoice_payload (:obj:`str`, optional): Bot-specified invoice payload.
        paid_media (Sequence[:class:`telegram.PaidMedia`], optional): Information about the paid
            media bought by the user.

            .. versionadded:: 21.5
        paid_media_payload (:obj:`str`, optional): Optional. Bot-specified paid media payload.

            .. versionadded:: 21.6

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.USER`.
        user (:class:`telegram.User`): Information about the user.
        invoice_payload (:obj:`str`): Optional. Bot-specified invoice payload.
        paid_media (tuple[:class:`telegram.PaidMedia`]): Optional. Information about the paid
            media bought by the user.

            .. versionadded:: 21.5
        paid_media_payload (:obj:`str`): Optional. Optional. Bot-specified paid media payload.

            .. versionadded:: 21.6

    )invoice_payload
paid_mediapaid_media_payloaduserNr   r`   r
   r]   r^   r_   r   r   c                   sj   t  jtj|d |   || _|| _t|| _|| _	| j
| jf| _W d    d S 1 s.w   Y  d S rB   )r   r   rN   rS   rI   r`   r]   r   r^   r_   r   r    )r#   r`   r]   r^   r_   r   r$   r&   r'   r   d  s   	

"zTransactionPartnerUser.__init__r)   r*   r   c                    sP   |  |}|s	dS t|d||d< tj|d|d|d< t j||dS )r[   Nr`   r^   )r*   r+   )r,   r
   r2   r0   r   de_listr   r\   r$   r&   r'   r2   y  s   
zTransactionPartnerUser.de_json)NNNr6   )r7   r8   r9   r:   r;   r   r<   r   r   r   r   r>   r2   r?   r&   r&   r$   r'   rV   @  s<    !
rV   c                       r@   )	rY   zDescribes a transaction with an unknown partner.

    .. versionadded:: 21.4

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.OTHER`.
    r&   Nr   r   r   c                   rA   rB   )r   r   rN   rP   r!   rC   r$   r&   r'   r     rD   z TransactionPartnerOther.__init__rE   r&   r&   r$   r'   rY     rF   rY   c                       r@   )	rW   zDescribes a withdrawal transaction to the Telegram Ads platform.

    .. versionadded:: 21.4

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.TELEGRAM_ADS`.
    r&   Nr   r   r   c                   rA   rB   )r   r   rN   rQ   r!   rC   r$   r&   r'   r     rD   z&TransactionPartnerTelegramAds.__init__rE   r&   r&   r$   r'   rW     rF   rW   c                       s<   e Zd ZdZdZdddedee ddf fdd	Z  Z	S )
rX   a  Describes a transaction with payment for
    `paid broadcasting <https://core.telegram.org/bots/api#paid-broadcasts>`_.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`request_count` is equal.

    .. versionadded:: 21.7

    Args:
        request_count (:obj:`int`): The number of successful requests that exceeded regular limits
            and were therefore billed.

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.TELEGRAM_API`.
        request_count (:obj:`int`): The number of successful requests that exceeded regular limits
            and were therefore billed.
    )request_countNr   rb   r   r   c                   sP   t  jtj|d |   || _| jf| _W d    d S 1 s!w   Y  d S rB   )r   r   rN   rR   rI   rb   r    )r#   rb   r   r$   r&   r'   r     s
   
"z&TransactionPartnerTelegramApi.__init__)
r7   r8   r9   r:   r;   intr   r   r   r?   r&   r&   r$   r'   rX     s    ,rX   c                       s   e Zd ZdZdZ		ddddedededee	 d	ee	 d
ee
 ddf fddZe	ddee
 ded ded  f fddZ  ZS )StarTransactionat  Describes a Telegram Star transaction.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`id`, :attr:`source`, and :attr:`receiver` are equal.

    .. versionadded:: 21.4

    Args:
        id (:obj:`str`): Unique identifier of the transaction. Coincides with the identifer
            of the original transaction for refund transactions.
            Coincides with :attr:`SuccessfulPayment.telegram_payment_charge_id` for
            successful incoming payments from users.
        amount (:obj:`int`): Number of Telegram Stars transferred by the transaction.
        date (:obj:`datetime.datetime`): Date the transaction was created as a datetime object.
        source (:class:`telegram.TransactionPartner`, optional): Source of an incoming transaction
            (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal).
            Only for incoming transactions.
        receiver (:class:`telegram.TransactionPartner`, optional): Receiver of an outgoing
            transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for
            outgoing transactions.

    Attributes:
        id (:obj:`str`): Unique identifier of the transaction. Coincides with the identifer
            of the original transaction for refund transactions.
            Coincides with :attr:`SuccessfulPayment.telegram_payment_charge_id` for
            successful incoming payments from users.
        amount (:obj:`int`): Number of Telegram Stars transferred by the transaction.
        date (:obj:`datetime.datetime`): Date the transaction was created as a datetime object.
        source (:class:`telegram.TransactionPartner`): Optional. Source of an incoming transaction
            (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal).
            Only for incoming transactions.
        receiver (:class:`telegram.TransactionPartner`): Optional. Receiver of an outgoing
            transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for
            outgoing transactions.
    )amountrG   idreceiversourceNr   rf   re   rG   rh   rg   r   r   c                   sJ   t  j|d || _|| _|| _|| _|| _| j| j| jf| _|   d S r   )	r   r   rf   re   rG   rh   rg   r    r!   )r#   rf   re   rG   rh   rg   r   r$   r&   r'   r     s   
zStarTransaction.__init__r)   r*   r   c                    sn   |  |}|s	dS t|}t|dd|d|d< t|d||d< t|d||d< t j||dS ),See :meth:`telegram.TelegramObject.de_json`.NrG   rJ   rh   rg   r+   )r,   r   r   r0   rN   r2   r   rL   r$   r&   r'   r2     s   
zStarTransaction.de_json)NNr6   )r7   r8   r9   r:   r;   r<   rc   r   r   rN   r   r   r>   r2   r?   r&   r&   r$   r'   rd     s>    $	rd   c                	       sj   e Zd ZdZdZdddee dee f fddZ	e
	dd	ee d
ed ded  f fddZ  ZS )StarTransactionsa  
    Contains a list of Telegram Star transactions.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`transactions` are equal.

    .. versionadded:: 21.4

    Args:
        transactions (Sequence[:class:`telegram.StarTransaction`]): The list of transactions.

    Attributes:
        transactions (tuple[:class:`telegram.StarTransaction`]): The list of transactions.
    )transactionsNr   rk   r   c                   s.   t  j|d t|| _| jf| _|   d S r   )r   r   r   rk   r    r!   )r#   rk   r   r$   r&   r'   r   -  s   

zStarTransactions.__init__r)   r*   r   r   c                    s<   |  |}|du rdS t|d||d< t j||dS )ri   Nrk   r+   )r,   rd   ra   r0   r   r2   r\   r$   r&   r'   r2   6  s
   
zStarTransactions.de_jsonr6   )r7   r8   r9   r:   r;   r   rd   r   r   r   r>   r2   r?   r&   r&   r$   r'   rj     s$    	rj   N)&r:   collections.abcr   r   typingr   r   r   telegramr   telegram._paidmediar   telegram._telegramobjectr	   telegram._userr
   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.datetimer   r   telegram._utils.typesr   r   r   r-   r.   r/   rN   rU   rV   rY   rW   rX   rd   rj   r&   r&   r&   r'   <module>   s4   D7N.IS