
    ThE                        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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)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      W/opt/server/standalone/crm/venv/lib/python3.12/site-packages/telegram/_payment/stars.pyr!   zRevenueWithdrawalState.__init__B   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 )Nr   r+   r,   )_parse_datar   RevenueWithdrawalStatePendingr   RevenueWithdrawalStateSucceededr   RevenueWithdrawalStateFailedr   getpopde_jsonr    clsr+   r,   _class_mappingr(   s       r)   r5   zRevenueWithdrawalState.de_jsonI   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!   classmethodr5   __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 )r0   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__j   s%    4<<Tr*   	r:   r;   r<   r=   r>   r   r   r!   rB   rC   s   @r)   r0   r0   ^   /     I;? hx&8 D  r*   r0   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 )r1   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   rL   rM   r   r   c                    t         |   t        j                  |       | j	                         5  || _        || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrG   )	r    r!   r   r   	_unfrozenrL   rM   r   r$   )r'   rL   rM   r   r(   s       r)   r!   z(RevenueWithdrawalStateSucceeded.__init__   sb     	4>>:V^^ 	"&DIDH				DN	 	 	   ,A&&A/r+   r,   r   c                     | j                  |      }|sy t        |      }t        |j                  dd       |      |d<   t        |   ||      S )NrL   tzinfor.   )r/   r   r   r3   r    r5   r7   r+   r,   
loc_tzinfor(   s       r)   r5   z'RevenueWithdrawalStateSucceeded.de_json   sS     t$ 2#6
%dhhvt&<ZPVwDc22r*   r9   )r:   r;   r<   r=   r>   r   r?   r   r   r!   rA   r5   rB   rC   s   @r)   r1   r1   o   s    $  I *. 
 X& 
" >B3H%3,4UO3	3	43 3r*   r1   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )r2   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`.
    rE   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rG   )r    r!   r   r   r%   rH   s     r)   r!   z%RevenueWithdrawalStateFailed.__init__   s%    4;;
Sr*   rI   rC   s   @r)   r2   r2      rJ   r*   r2   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.   )r/   rY   rZ   TransactionPartnerFragmentr[   TransactionPartnerUserr\   TransactionPartnerOtherr]   TransactionPartnerTelegramAdsr3   r4   r5   r    r6   s       r)   r5   zTransactionPartner.de_json   s     t$<11 LL4HH,II.;	?
 $$&)9^)K!$((6"23;;3;OOwDc22r*   r9   )r:   r;   r<   r=   r>   r   r_   rZ   r   r?   r@   r[   r\   r]   r   r   r!   rA   r5   rB   rC   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 (:obj:`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 (:obj:`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rG   )r    r!   rY   rZ   rO   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 )Nrf   r.   )r/   r   r5   r3   r    r7   r+   r,   r(   s      r)   r5   z"TransactionPartnerFragment.de_json  sS     t$#9#A#AHH'(#$
  wDc22r*   r9   )r:   r;   r<   r=   r>   r   r   r!   rA   r5   rB   rC   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   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.

    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.
    )invoice_payloaduserNr   rl   r   rk   r   r   c                    t         |   t        j                  |       | j	                         5  || _        || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrG   )	r    r!   rY   r[   rO   rl   rk   r   r$   )r'   rl   rk   r   r(   s       r)   r!   zTransactionPartnerUser.__init__C  sc     	055*M^^ 	"DI2AD 				DN	 	 	rP   r+   r,   r   c                     | j                  |      }|sy t        j                  |j                  d      |      |d<   t        | 	  ||      S )Nrl   r.   )r/   r   r5   r3   r    ri   s      r)   r5   zTransactionPartnerUser.de_jsonT  sI     t$||DHHV$4c:VwDc22r*   r9   )r:   r;   r<   r=   r>   r   r?   r   r!   rA   r5   rB   rC   s   @r)   rb   rb   .  s    $ ,I
 *.
 *. "#
 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`.
    rE   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rG   )r    r!   rY   r\   r%   rH   s     r)   r!   z TransactionPartnerOther.__init__n  s%    066:Nr*   rI   rC   s   @r)   rc   rc   b  rJ   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`.
    rE   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rG   )r    r!   rY   r]   r%   rH   s     r)   r!   z&TransactionPartnerTelegramAds.__init__  s%    0==*Ur*   rI   rC   s   @r)   rd   rd   s  rJ   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.
    )amountrL   idreceiversourceNr   rv   ru   rL   rx   rw   r   r   c                    t         |   |       || _        || _        || _        || _        || _        | j                  | j
                  | j                  f| _        | j                          y r   )	r    r!   rv   ru   rL   rx   rw   r$   r%   )r'   rv   ru   rL   rx   rw   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 )NrL   rR   rx   rw   r.   )r/   r   r   r3   rY   r5   r    rT   s       r)   r5   zStarTransaction.de_json  s     t$ 2#6
%dhhvt&<ZPV+33DHHX4FLX-55dhhz6JCPZwDc22r*   )NNr9   )r:   r;   r<   r=   r>   r?   intr   r   rY   r   r!   rA   r5   rB   rC   s   @r)   rt   rt     s    "H ?I 0415 *.  	
 +, -. X& 
0 >B3H%3,4UO3	#	$3 3r*   rt   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 )Nr~   r.   )r/   rt   de_listr3   r    r5   ri   s      r)   r5   zStarTransactions.de_json  sO     t$<.66txx7OQTU^wDc22r*   r9   )r:   r;   r<   r=   r>   r   rt   r   r   r!   rA   r5   rB   rC   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._telegramobjectr   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.datetimer   r   telegram._utils.typesr   r   r   r0   r1   r2   rY   ra   rb   rc   rd   rt   r}   rE   r*   r)   <module>r      s   ( H  N N N  3    > Q *63^ 63r$: "33&< 33l#9 "H3 H3V*3!3 *3Z13/ 13h0 "$6 "O3n O3d%3~ %3r*   