
    ՟fL                        d Z ddlmZ ddlmZmZmZ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 dd	lmZ dd
lmZmZ ddlmZ erddl
mZ  G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z  G d de       Z! G d de       Z" G d de       Z# G d de       Z$ G d d e      Z% G d! d"e      Z&y#)$zAThis module contains the classes for Telegram Stars transactions.    )datetime)TYPE_CHECKINGDictFinalOptionalSequenceTupleType)	constants)	PaidMedia)TelegramObject)User)enum)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)JSONDict)Botc            	       4    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Ze	 ddee   ded   d
ed    f fd       Z x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                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y Nr   )	super__init__r   
get_memberr   RevenueWithdrawalStateTyper   	_id_attrs_freezeselfr   r   	__class__s      R/var/www/cvtools/html/venv/lib/python3.12/site-packages/telegram/_payment/stars.pyr"   zRevenueWithdrawalState.__init__C   sD    J/)M)MtUYZ	))    databotr   c                 2   | j                  |      }|sy| j                  t        | j                  t        | j
                  t        i}| t        u r8|j                  d      |v r%||j                  d         j                  ||      S t        | )  ||      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)   s       r*   r6   zRevenueWithdrawalState.de_jsonJ   s     t$ KK6MM:JJ4C
 ((TXXf-=-O!$((6"23;;3;OOwDc22r+   N)__name__
__module____qualname____doc__	__slots__r   r$   r   r   str__annotations__r   r   r   r   r"   classmethodr6   __classcell__r)   s   @r*   r   r   &   s    & I#>>FFGU3ZFH%@@JJIuSzJJ"==DDFE#JDGFJ S (1C t  >B3H%3,4UO3	*	+3 3r+   r   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )r1   zThe withdrawal is in progress.

    .. versionadded:: 21.4

    Attributes:
        type (:obj:`str`): The type of the state, always
            :tg-const:`telegram.RevenueWithdrawalState.PENDING`.
     Nr   r   r   c                d    t         |   t        j                  |       | j	                          y N)r   r   )r!   r"   r   r   r&   r(   r   r)   s     r*   r"   z&RevenueWithdrawalStatePending.__init__v   s%    4<<Tr+   	r;   r<   r=   r>   r?   r   r   r"   rC   rD   s   @r*   r1   r1   j   /     I;? hx&8 D  r+   r1   c            	       |     e Zd ZdZdZdddededee   ddf fd	Z	e
	 dd
ee   ded   ded    f fd       Z xZS )r2   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   rM   rN   r   r   c                    t         |   t        j                  |       | j	                         5  || _        || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrH   )	r!   r"   r   r   	_unfrozenrM   rN   r   r%   )r(   rM   rN   r   r)   s       r*   r"   z(RevenueWithdrawalStateSucceeded.__init__   sb     	4>>:V^^ 	"&DIDH				DN	 	 	s   ,A&&A/r,   r-   r   c                     | j                  |      }|syt        |      }t        |j                  dd      |      |d<   t        |   ||      S )z4See :meth:`telegram.RevenueWithdrawalState.de_json`.NrM   tzinfor/   )r0   r   r   r4   r!   r6   r8   r,   r-   
loc_tzinfor)   s       r*   r6   z'RevenueWithdrawalStateSucceeded.de_json   sS    
 t$ 2#6
%dhhvt&<ZPVwDc22r+   r:   )r;   r<   r=   r>   r?   r   r@   r   r   r"   rB   r6   rC   rD   s   @r*   r2   r2   {   s    $  I *. 
 X& 
" >B3H%3,4UO3	3	43 3r+   r2   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )r3   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`.
    rF   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rH   )r!   r"   r   r   r&   rI   s     r*   r"   z%RevenueWithdrawalStateFailed.__init__   s%    4;;
Sr+   rJ   rD   s   @r*   r3   r3      rK   r+   r3   c            	       r    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<   	 ddd	e	d
ee   ddf fdZe	 ddee   ded   ded    f fd       Z x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USEROTHERTELEGRAM_ADSNr   r   r   r   c                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y r    )	r!   r"   r   r#   r   TransactionPartnerTyper   r%   r&   r'   s      r*   r"   zTransactionPartner.__init__   sD    J/)I)I4QUV	))r+   r,   r-   r   c                 h   | j                  |      }|y|s	| t        u ry| j                  t        | j                  t
        | j                  t        | j                  t        i}| t        u r8|j                  d      |v r%||j                  d         j                  ||      S t        | 1  ||      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/   )r0   rY   rZ   TransactionPartnerFragmentr[   TransactionPartnerUserr\   TransactionPartnerOtherr]   TransactionPartnerTelegramAdsr4   r5   r6   r!   r7   s       r*   r6   zTransactionPartner.de_json   s     t$<11 LL4HH,II.;	?
 $$&)9^)K!$((6"23;;3;OOwDc22r+   r:   )r;   r<   r=   r>   r?   r   r_   rZ   r   r@   rA   r[   r\   r]   r   r   r"   rB   r6   rC   rD   s   @r*   rY   rY      s    ( I$;;DDHeCjDE 77<<D%*<A!88>>E5:>B(??LLL%*LIFJ S (1C t  >B 3H% 3,4UO 3	&	' 3  3r+   rY   c            	            e Zd ZdZdZ	 dddded   dee   ddf fd	Ze	 dd
ee   ded   ded    f fd       Z	 xZ
S )ra   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   rf   r   r   r   c                    t         |   t        j                  |       | j	                         5  || _        d d d        y # 1 sw Y   y xY wrH   )r!   r"   rY   rZ   rP   rf   )r(   rf   r   r)   s      r*   r"   z#TransactionPartnerFragment.__init__   sI     	099jQ^^ 	WFVD!	W 	W 	Ws   AAr,   r-   r   c                     | j                  |      }|syt        j                  |j                  d      |      |d<   t        | 	  ||      S )0See :meth:`telegram.TransactionPartner.de_json`.Nrf   r/   )r0   r   r6   r4   r!   r8   r,   r-   r)   s      r*   r6   z"TransactionPartnerFragment.de_json+  sS    
 t$#9#A#AHH'(#$
  wDc22r+   r:   )r;   r<   r=   r>   r?   r   r   r"   rB   r6   rC   rD   s   @r*   ra   ra     s     &I @D	W *.		W"#;<	W X&		W
 
	W >B3H%3,4UO3	.	/3 3r+   ra   c                        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Z
e	 ddee	   ded   ded    f fd       Z xZS )rb   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   ro   r   rl   rm   rn   r   r   c                   t         |   t        j                  |       | j	                         5  || _        || _        t        |      | _        || _	        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrH   )r!   r"   rY   r[   rP   ro   rl   r   rm   rn   r   r%   )r(   ro   rl   rm   rn   r   r)   s         r*   r"   zTransactionPartnerUser.__init__`  sx     	055*M^^ 	"DI2AD ?QR\?]DO5GD#				DN	 	 	s   AA==Br,   r-   r   c                     | j                  |      }|syt        j                  |j                  d      |      |d<   t	        j
                  |j                  d      |      |d<   t        | 	  ||      S )ri   Nro   rm   )r-   r/   )r0   r   r6   r4   r   de_listr!   rj   s      r*   r6   zTransactionPartnerUser.de_jsonu  si    
 t$||DHHV$4c:V&..txx/E3O\wDc22r+   )NNNr:   )r;   r<   r=   r>   r?   r   r@   r   r   r   r"   rB   r6   rC   rD   s   @r*   rb   rb   <  s    B PI
 *.48,0 *. "# Xi01	
 %SM X& 
* >B3H%3,4UO3	*	+3 3r+   rb   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )rc   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`.
    rF   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rH   )r!   r"   rY   r\   r&   rI   s     r*   r"   z TransactionPartnerOther.__init__  s%    066:Nr+   rJ   rD   s   @r*   rc   rc     rK   r+   rc   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )rd   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`.
    rF   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rH   )r!   r"   rY   r]   r&   rI   s     r*   r"   z&TransactionPartnerTelegramAds.__init__  s%    0==*Ur+   rJ   rD   s   @r*   rd   rd     rK   r+   rd   c                        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Ze	 ddee
   ded   ded    f fd       Z x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.
    )amountrM   idreceiversourceNr   rz   ry   rM   r|   r{   r   r   c                    t         |   |       || _        || _        || _        || _        || _        | j                  | j
                  | j                  f| _        | j                          y r    )	r!   r"   rz   ry   rM   r|   r{   r%   r&   )r(   rz   ry   rM   r|   r{   r   r)   s          r*   r"   zStarTransaction.__init__  sc     	J/!"	4:6> GGKKMM

 	r+   r,   r-   r   c                 D   | j                  |      }|syt        |      }t        |j                  dd      |      |d<   t        j                  |j                  d      |      |d<   t        j                  |j                  d      |      |d<   t        |   ||      S ),See :meth:`telegram.TelegramObject.de_json`.NrM   rR   r|   r{   r/   )r0   r   r   r4   rY   r6   r!   rT   s       r*   r6   zStarTransaction.de_json  s    
 t$ 2#6
%dhhvt&<ZPV+33DHHX4FLX-55dhhz6JCPZwDc22r+   )NNr:   )r;   r<   r=   r>   r?   r@   intr   r   rY   r   r"   rB   r6   rC   rD   s   @r*   rx   rx     s    "H ?I 0415 *.  	
 +, -. X& 
0 >B3H%3,4UO3	#	$3 3r+   rx   c            	       z     e Zd ZdZdZdddee   dee   f fdZ	e
	 ddee   d	ed
   ded    f fd       Z x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   r   r   c                    t         |   |       t        |      | _        | j                  f| _        | j                          y r    )r!   r"   r   r   r%   r&   )r(   r   r   r)   s      r*   r"   zStarTransactions.__init__  s;     	J/9KL9Y++-r+   r,   r-   r   r   c                     | j                  |      }|yt        j                  |j                  d      |      |d<   t        |   ||      S )r   Nr   r/   )r0   rx   rr   r4   r!   r6   rj   s      r*   r6   zStarTransactions.de_json  sO    
 t$<.66txx7OQTU^wDc22r+   r:   )r;   r<   r=   r>   r?   r   rx   r   r   r"   rB   r6   rC   rD   s   @r*   r   r     ss     "I \`$_5FNxFX >B
3H%
3,4UO
3	$	%
3 
3r+   r   N)'r>   r   typingr   r   r   r   r   r	   r
   telegramr   telegram._paidmediar   telegram._telegramobjectr   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.datetimer   r   telegram._utils.typesr   r   r   r1   r2   r3   rY   ra   rb   rc   rd   rx   r   rF   r+   r*   <module>r      s   ( H  N N N  ) 3    > Q *A3^ A3H$: "43&< 43n#9 "H3 H3V+3!3 +3\F3/ F3R0 "$6 "P3n P3f&3~ &3r+   