
    Qi:                     R   d Z ddl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 ddlmZ ddl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$y)zIThis module contains the classes for Telegram Stars transaction partners.    N)Sequence)TYPE_CHECKINGFinalOptional)	constants)Gift)	PaidMedia)TelegramObject)User)enum)parse_sequence_arg)JSONDict   )AffiliateInfo)RevenueWithdrawalState)Botc            	           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<   	 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 )TransactionPartnera  This object describes the source of a transaction, or its recipient for outgoing
    transactions. Currently, it can be one of:

    * :class:`TransactionPartnerUser`
    * :class:`TransactionPartnerAffiliateProgram`
    * :class:`TransactionPartnerFragment`
    * :class:`TransactionPartnerTelegramAds`
    * :class:`TransactionPartnerTelegramApi`
    * :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.
    )typeAFFILIATE_PROGRAMFRAGMENTOTHERTELEGRAM_ADSTELEGRAM_APIUSERN
api_kwargsr   r   returnc                    t         |   |       t        j                  t        j
                  ||      | _        | j                  f| _        | j                          y )Nr   )	super__init__r   
get_memberr   TransactionPartnerTyper   	_id_attrs_freeze)selfr   r   	__class__s      U/app/.venv/lib/python3.12/site-packages/telegram/_payment/stars/transactionpartner.pyr!   zTransactionPartner.__init__R   sD    J/)I)I4QUV	))    databotr   c                    | j                  |      }| t        u r|r|y| j                  t        | j                  t
        | j                  t        | j                  t        | j                  t        | j                  t        i}| t        u r8|j                  d      |v r%||j                  d         j!                  ||      S t"        | A  ||      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+   )_parse_datar   r   "TransactionPartnerAffiliateProgramr   TransactionPartnerFragmentr   TransactionPartnerUserr   TransactionPartnerTelegramAdsr   TransactionPartnerTelegramApir   TransactionPartnerOthergetpopde_jsonr    )clsr*   r+   _class_mappingr'   s       r(   r7   zTransactionPartner.de_jsonY   s     t$%%dt| !!#ELL4HH,;;II.?
 $$&)9^)K!$((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   r   r   r!   classmethodr7   __classcell__r'   s   @r(   r   r   )   s"   , I$-$D$D$V$VuSzV %;;DDHeCjDE!88>>E5:>B(??LLL%*LI(??LLL%*LI 77<<D%*<AFJ S (1C t  >B3H%3,4UO3	&	'3 3r)   r   c            
            e Zd ZdZdZ	 dddde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 )r/   a\  Describes the affiliate program that issued the affiliate commission received via this
    transaction.

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

    .. versionadded:: 21.9

    Args:
        sponsor_user (:class:`telegram.User`, optional): Information about the bot that sponsored
            the affiliate program
        commission_per_mille (:obj:`int`): The number of Telegram Stars received by the bot for
            each 1000 Telegram Stars received by the affiliate program sponsor from referred users.

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.AFFILIATE_PROGRAM`.
        sponsor_user (:class:`telegram.User`): Optional. Information about the bot that sponsored
            the affiliate program
        commission_per_mille (:obj:`int`): The number of Telegram Stars received by the bot for
            each 1000 Telegram Stars received by the affiliate program sponsor from referred users.
    )commission_per_millesponsor_userNr   rF   rG   r   r   r   c                    t         |   t        j                  |       | j	                         5  || _        || _        | j                  | j                  f| _        d d d        y # 1 sw Y   y xY wN)r   r   )	r    r!   r   r   	_unfrozenrG   rF   r   r$   )r&   rF   rG   r   r'   s       r(   r!   z+TransactionPartnerAffiliateProgram.__init__   s]     	0BBzZ^^0<D-AD%		))DN s   ,A&&A/r*   r+   r   c                     | j                  |      }|syt        j                  |j                  d      |      |d<   t        | 	  ||      S )0See :meth:`telegram.TransactionPartner.de_json`.NrG   r-   )r.   r   r7   r5   r    r8   r*   r+   r'   s      r(   r7   z*TransactionPartnerAffiliateProgram.de_json   sJ    
 t$#||DHH^,DcJ^wDc22r)   r:   )r;   r<   r=   r>   r?   intr   r   r!   rB   r7   rC   rD   s   @r(   r/   r/   |   s    . 9I
 *.
 *.! v&
 X& 
" >B3H%3,4UO3	6	73 3r)   r/   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 )r0   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   rP   r   r   r   c                    t         |   t        j                  |       | j	                         5  || _        d d d        y # 1 sw Y   y xY wrI   )r    r!   r   r   rJ   rP   )r&   rP   r   r'   s      r(   r!   z#TransactionPartnerFragment.__init__   s<     	099jQ^^FVD! s   AAr*   r+   r   c                     | j                  |      }|yt        j                  |j                  d      |      |d<   t        | 	  ||      S )rL   NrP   r-   )r.   r   r7   r5   r    rM   s      r(   r7   z"TransactionPartnerFragment.de_json   sU    
 t$<#9#A#AHH'(#$
  wDc22r)   r:   )r;   r<   r=   r>   r?   r   r   r!   rB   r7   rC   rD   s   @r(   r0   r0      s     &I @D	W *.		W"#;<	W X&		W
 
	W >B3H%3,4UO3	.	/3 3r)   r0   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	j                     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 )r1   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.
        affiliate (:class:`telegram.AffiliateInfo`, optional): Information about the affiliate that
            received a commission via this transaction

            .. versionadded:: 21.9
        invoice_payload (:obj:`str`, optional): Bot-specified invoice payload.
        subscription_period (:class:`datetime.timedelta`, optional): The duration of the paid
            subscription

            .. versionadded:: 21.8
        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): Bot-specified paid media payload.

            .. versionadded:: 21.6
        gift (:class:`telegram.Gift`, optional): The gift sent to the user by the bot

            .. versionadded:: 21.8

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.USER`.
        user (:class:`telegram.User`): Information about the user.
        affiliate (:class:`telegram.AffiliateInfo`): Optional. Information about the affiliate that
            received a commission via this transaction

            .. versionadded:: 21.9
        invoice_payload (:obj:`str`): Optional. Bot-specified invoice payload.
        subscription_period (:class:`datetime.timedelta`): Optional. The duration of the paid
            subscription

            .. versionadded:: 21.8
        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. Bot-specified paid media payload.

            .. versionadded:: 21.6
        gift (:class:`telegram.Gift`): Optional. The gift sent to the user by the bot

            .. versionadded:: 21.8

    )	affiliategiftinvoice_payload
paid_mediapaid_media_payloadsubscription_perioduserNr   rZ   r   rV   rW   rX   rY   rU   rT   r   r   c                <   t         	|   t        j                  |       | j	                         5  || _        || _        || _        t        |      | _	        || _
        || _        || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrI   )r    r!   r   r   rJ   rZ   rT   rV   r   rW   rX   rY   rU   r   r$   )
r&   rZ   rV   rW   rX   rY   rU   rT   r   r'   s
            r(   r!   zTransactionPartnerUser.__init__&  s     	055*M^^"DI6?DN2AD ?QR\?]DO5GD#@SD$(,DI 				DN s   ABBr*   r+   r   c                    | j                  |      }|syt        j                  |j                  d      |      |d<   t	        j                  |j                  d      |      |d<   t        j                  |j                  d      |      |d<   |j                  d      x}t        j                  |      nd|d<   t        j                  |j                  d      |      |d<   t        | 	  ||	      S )
rL   NrZ   rT   rW   )r+   rY   )secondsrU   r-   )r.   r   r7   r5   r   r	   de_listdtm	timedeltar   r    )r8   r*   r+   spr'   s       r(   r7   zTransactionPartnerUser.de_jsonB  s    
 t$||DHHV$4c:V)11$((;2GM[&..txx/E3O\ hh455B MM"% 	"#
 ||DHHV$4c:VwDc22r)   )NNNNNNr:   )r;   r<   r=   r>   r?   r   r@   r   r	   r_   r`   r   r   r   r!   rB   r7   rC   rD   s   @r(   r1   r1      s    5nI *.48,07;#-1 *. "# Xi01	
 %SM &cmm4 tn M* X& 
8 >B3H%3,4UO3	*	+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 )r4   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`.
     Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rI   )r    r!   r   r   r%   r&   r   r'   s     r(   r!   z TransactionPartnerOther.__init__e  s%    066:Nr)   	r;   r<   r=   r>   r?   r   r   r!   rC   rD   s   @r(   r4   r4   Y  /     I;? hx&8 D  r)   r4   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )r2   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`.
    rc   Nr   r   r   c                d    t         |   t        j                  |       | j	                          y rI   )r    r!   r   r   r%   re   s     r(   r!   z&TransactionPartnerTelegramAds.__init__v  s%    0==*Ur)   rf   rD   s   @r(   r2   r2   j  rg   r)   r2   c                   @     e Zd ZdZdZdddedee   ddf fdZ xZ	S )	r3   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   rk   r   r   c                    t         |   t        j                  |       | j	                         5  || _        | j
                  f| _        d d d        y # 1 sw Y   y xY wrI   )r    r!   r   r   rJ   rk   r$   )r&   rk   r   r'   s      r(   r!   z&TransactionPartnerTelegramApi.__init__  sJ    0==*U^^&3D"002DN s   AA)
r;   r<   r=   r>   r?   rN   r   r   r!   rC   rD   s   @r(   r3   r3   {  s7    & #IOS 3c 3(8:L 3X\ 3 3r)   r3   )%r>   datetimer_   collections.abcr   typingr   r   r   telegramr   telegram._giftsr   telegram._paidmediar	   telegram._telegramobjectr
   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   telegram._utils.typesr   affiliateinfor   revenuewithdrawalstater   r   r   r/   r0   r1   r4   r2   r3   rc   r)   r(   <module>rz      s   ( P  $ 1 1    ) 3    > * ( :P3 P3f73); 73t+3!3 +3\r3/ r3j0 "$6 "3$6 3r)   