
    ynhT                     |   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mZ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( G d  d!e"      Z)y)"zIThis module contains the classes for Telegram Stars transaction partners.    N)Sequence)TYPE_CHECKINGFinalOptional)	constants)Chat)Gift)	PaidMedia)TelegramObject)User)enum)de_json_optionalde_list_optional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<   	 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ded   dd f fd       Z xZS )TransactionPartneraG  This object describes the source of a transaction, or its recipient for outgoing
    transactions. Currently, it can be one of:

    * :class:`TransactionPartnerUser`
    * :class:`TransactionPartnerChat`
    * :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

    .. versionchanged:: 21.11
        Added :class:`TransactionPartnerChat`

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

    Attributes:
        type (:obj:`str`): The type of the transaction partner.
    )typeAFFILIATE_PROGRAMCHAT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      k/var/www/html/profi_bot/bot/venv/lib/python3.12/site-packages/telegram/_payment/stars/transactionpartner.pyr%   zTransactionPartner.__init__\   sD    J/)I)I4QUV	))    databotr   c                    | j                  |      }| j                  t        | 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&        | I  ||      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.

        r   r.   r/   )_parse_datar   "TransactionPartnerAffiliateProgramr   TransactionPartnerChatr   TransactionPartnerFragmentr   TransactionPartnerUserr   TransactionPartnerTelegramAdsr   TransactionPartnerTelegramApir   TransactionPartnerOtherr   getpopde_jsonr$   )clsr.   r/   _class_mappingr+   s       r,   r<   zTransactionPartner.de_jsonc   s     t$ !!#EHH,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   r%   classmethodr<   __classcell__r+   s   @r,   r   r   *   s3   4 I$-$D$D$V$VuSzV !77<<D%*< %;;DDHeCjDE!88>>E5:>B(??LLL%*LI(??LLL%*LI 77<<D%*<AFJ S (1C t  38 3(5/ 3EY 3 3r-   r   c            
       z     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ded   d	d f fd       Z
 xZS )r3   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    rK   rL   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   	_unfrozenrL   rK   r   r(   )r*   rK   rL   r!   r+   s       r,   r%   z+TransactionPartnerAffiliateProgram.__init__   s]     	0BBzZ^^0<D-AD%		))DN    ,A&&A/r.   r/   r   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )0See :meth:`telegram.TransactionPartner.de_json`.rL   r1   )r2   r   r:   r   r$   r<   r=   r.   r/   r+   s      r,   r<   z*TransactionPartnerAffiliateProgram.de_json   sC    
 t$/0H$PST^wDc22r-   r?   )r@   rA   rB   rC   rD   intr   r   r%   rG   r<   rH   rI   s   @r,   r3   r3      s    . 9I
 *.
 *.! v&
 X& 
" 4833"*5/3	-3 3r-   r3   c            
       x     e Zd ZdZdZ	 ddddedee   dee   ddf fd	Z	e
dd
eded   dd f fd       Z xZS )r4   a  Describes a transaction with a chat.

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

    .. versionadded:: 21.11

    Args:
        chat (:class:`telegram.Chat`): Information about the chat.
        gift (:class:`telegram.Gift`, optional): The gift sent to the chat by the bot.

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.CHAT`.
        chat (:class:`telegram.Chat`): Information about the chat.
        gift (:class:`telegram.Gift`): Optional. The gift sent to the user by the bot.

    )chatgiftNr    rW   rX   r!   r"   c                    t         |   t        j                  |       | j	                         5  || _        || _        | j                  | j
                  f| _        d d d        y # 1 sw Y   y xY wrN   )	r$   r%   r   r   rP   rW   rX   r   r(   )r*   rW   rX   r!   r+   s       r,   r%   zTransactionPartnerChat.__init__   s[     	055*M^^"DI(,DI 				DN	 rQ   r.   r/   r   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |j                  d      t        |      |d<   t
        |   ||      S )rS   rW   rX   r1   )r2   r   r:   r   r	   r$   r<   rT   s      r,   r<   zTransactionPartnerChat.de_json   s\     t$'(8$DV'(8$DVwDc22r-   r?   )r@   rA   rB   rC   rD   r   r   r	   r   r%   rG   r<   rH   rI   s   @r,   r4   r4      s    &I  $
 *. tn
 X& 
$ 38 3(5/ 3E] 3 3r-   r4   c                   t     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ded   dd f fd       Z	 xZ
S )r5   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    r\   r   r!   r"   c                    t         |   t        j                  |       | j	                         5  || _        d d d        y # 1 sw Y   y xY wrN   )r$   r%   r   r   rP   r\   )r*   r\   r!   r+   s      r,   r%   z#TransactionPartnerFragment.__init__  s<     	099jQ^^FVD! s   AAr.   r/   r   c                     | j                  |      }t        |j                  d      t        |      |d<   t        |   ||      S )rS   r\   r1   )r2   r   r:   r   r$   r<   rT   s      r,   r<   z"TransactionPartnerFragment.de_json  sJ     t$#3HH'(*@#$
  wDc22r-   r?   )r@   rA   rB   rC   rD   r   r   r%   rG   r<   rH   rI   s   @r,   r5   r5      s     &I @D	W *.		W"#;<	W X&		W
 
	W 38 3(5/ 3Ea 3 3r-   r5   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ee   dee   ddf fdZeddeded   dd f fd       Z xZS )r6   a8  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` and :attr:`transaction_type` are equal.

    .. versionadded:: 21.4

    .. versionchanged:: 22.1
       Equality comparison now includes the new required argument :paramref:`transaction_type`,
       introduced in Bot API 9.0.

    Args:
        transaction_type (:obj:`str`): Type of the transaction, currently one of
            :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT` for payments via
            invoices, :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT`
            for payments for paid media,
            :tg-const:`telegram.constants.TransactionPartnerUser.GIFT_PURCHASE` for gifts sent by
            the bot, :tg-const:`telegram.constants.TransactionPartnerUser.PREMIUM_PURCHASE`
            for Telegram Premium subscriptions gifted by the bot,
            :tg-const:`telegram.constants.TransactionPartnerUser.BUSINESS_ACCOUNT_TRANSFER` for
            direct transfers from managed business accounts.

            .. versionadded:: 22.1
        user (:class:`telegram.User`): Information about the user.
        affiliate (:class:`telegram.AffiliateInfo`, optional): Information about the affiliate that
            received a commission via this transaction. Can be available only for
            :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT`
            and :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT`
            transactions.

            .. versionadded:: 21.9
        invoice_payload (:obj:`str`, optional): Bot-specified invoice payload. Can be available
            only for :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT`
            transactions.
        subscription_period (:class:`datetime.timedelta`, optional): The duration of the paid
            subscription. Can be available only for
            :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT` transactions.

            .. versionadded:: 21.8
        paid_media (Sequence[:class:`telegram.PaidMedia`], optional): Information about the paid
            media bought by the user. for
            :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT`
            transactions only.

            .. versionadded:: 21.5
        paid_media_payload (:obj:`str`, optional): Bot-specified paid media payload. Can be
            available only for
            :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT` transactions.

            .. versionadded:: 21.6
        gift (:class:`telegram.Gift`, optional): The gift sent to the user by the bot; for
            :tg-const:`telegram.constants.TransactionPartnerUser.GIFT_PURCHASE` transactions only.

            .. versionadded:: 21.8
        premium_subscription_duration (:obj:`int`, optional): Number of months the gifted Telegram
            Premium subscription will be active for; for
            :tg-const:`telegram.constants.TransactionPartnerUser.PREMIUM_PURCHASE`
            transactions only.

            .. versionadded:: 22.1

    Attributes:
        type (:obj:`str`): The type of the transaction partner,
            always :tg-const:`telegram.TransactionPartner.USER`.
        transaction_type (:obj:`str`): Type of the transaction, currently one of
            :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT` for payments via
            invoices, :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT`
            for payments for paid media,
            :tg-const:`telegram.constants.TransactionPartnerUser.GIFT_PURCHASE` for gifts sent by
            the bot, :tg-const:`telegram.constants.TransactionPartnerUser.PREMIUM_PURCHASE`
            for Telegram Premium subscriptions gifted by the bot,
            :tg-const:`telegram.constants.TransactionPartnerUser.BUSINESS_ACCOUNT_TRANSFER` for
            direct transfers from managed business accounts.

            .. versionadded:: 22.1
        user (:class:`telegram.User`): Information about the user.
        affiliate (:class:`telegram.AffiliateInfo`): Optional. Information about the affiliate that
            received a commission via this transaction. Can be available only for
            :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT`
            and :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT`
            transactions.

            .. versionadded:: 21.9
        invoice_payload (:obj:`str`): Optional. Bot-specified invoice payload. Can be available
            only for :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT`
            transactions.
        subscription_period (:class:`datetime.timedelta`): Optional. The duration of the paid
            subscription. Can be available only for
            :tg-const:`telegram.constants.TransactionPartnerUser.INVOICE_PAYMENT` transactions.

            .. versionadded:: 21.8
        paid_media (tuple[:class:`telegram.PaidMedia`]): Optional. Information about the paid
            media bought by the user. for
            :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT`
            transactions only.

            .. versionadded:: 21.5
        paid_media_payload (:obj:`str`): Optional. Bot-specified paid media payload. Can be
            available only for
            :tg-const:`telegram.constants.TransactionPartnerUser.PAID_MEDIA_PAYMENT` transactions.

            .. versionadded:: 21.6
        gift (:class:`telegram.Gift`): Optional. The gift sent to the user by the bot; for
            :tg-const:`telegram.constants.TransactionPartnerUser.GIFT_PURCHASE` transactions only.

            .. versionadded:: 21.8
        premium_subscription_duration (:obj:`int`): Optional. Number of months the gifted Telegram
            Premium subscription will be active for; for
            :tg-const:`telegram.constants.TransactionPartnerUser.PREMIUM_PURCHASE`
            transactions only.

            .. versionadded:: 22.1

    )		affiliaterX   invoice_payload
paid_mediapaid_media_payloadpremium_subscription_durationsubscription_periodtransaction_typeuserNr    rg   r   ra   rb   rc   re   rX   r`   rd   rf   r!   r"   c
                   t         |   t        j                  |
       |	t	        d      | j                         5  || _        || _        || _        t        |      | _
        || _        || _        || _        || _        |	| _        | j                   | j                  | j                  f| _        d d d        y # 1 sw Y   y xY w)NrO   z;`transaction_type` is a required argument since Bot API 9.0)r$   r%   r   r   	TypeErrorrP   rg   r`   ra   r   rb   rc   re   rX   rd   rf   r   r(   )r*   rg   ra   rb   rc   re   rX   r`   rd   rf   r!   r+   s              r,   r%   zTransactionPartnerUser.__init__  s     	055*M #YZZ^^"DI6?DN2AD ?QR\?]DO5GD#@SD$(,DI@]D.)9D! 				%%DN s   A1B88Cr.   r/   r   c                    | j                  |      }t        |j                  d      t        |      |d<   t        |j                  d      t        |      |d<   t        |j                  d      t        |      |d<   |j                  d      x}t        j                  |      nd|d<   t        |j                  d      t        |      |d<   t        | -  ||      S )	rS   rg   r`   rb   re   N)secondsrX   r1   )r2   r   r:   r   r   r   r
   dtm	timedeltar	   r$   r<   )r=   r.   r/   spr+   s       r,   r<   zTransactionPartnerUser.de_json  s     t$'(8$DV,TXXk-BMSVW[-dhh|.DiQTU\ hh455B MM"% 	"#
 ((8$DVwDc22r-   )NNNNNNNNr?   )r@   rA   rB   rC   rD   r   rE   r   r
   rl   rm   r	   r   rU   r   r%   rG   r<   rH   rI   s   @r,   r6   r6     s   qf
I *.48,07;#-17;*.$ *.$$ "#$ Xi01	$
 %SM$ &cmm4$ tn$ M*$ (0}$ #3-$ X&$ 
$L 38 3(5/ 3E] 3 3r-   r6   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )r9   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 rN   )r$   r%   r   r   r)   r*   r!   r+   s     r,   r%   z TransactionPartnerOther.__init__  s%    066:Nr-   	r@   rA   rB   rC   rD   r   r   r%   rH   rI   s   @r,   r9   r9     /     I;? hx&8 D  r-   r9   c                   <     e Zd ZdZdZdddee   ddf fdZ xZS )r7   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`.
    rp   Nr    r!   r"   c                d    t         |   t        j                  |       | j	                          y rN   )r$   r%   r   r   r)   rr   s     r,   r%   z&TransactionPartnerTelegramAds.__init__  s%    0==*Ur-   rs   rI   s   @r,   r7   r7     rt   r-   r7   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 )	r8   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    rx   r!   r"   c                    t         |   t        j                  |       | j	                         5  || _        | j
                  f| _        d d d        y # 1 sw Y   y xY wrN   )r$   r%   r   r   rP   rx   r(   )r*   rx   r!   r+   s      r,   r%   z&TransactionPartnerTelegramApi.__init__  sJ    0==*U^^&3D"002DN s   AA)
r@   rA   rB   rC   rD   rU   r   r   r%   rH   rI   s   @r,   r8   r8     s7    & #IOS 3c 3(8:L 3X\ 3 3r-   r8   )*rC   datetimerl   collections.abcr   typingr   r   r   telegramr   telegram._chatr   telegram._giftsr	   telegram._paidmediar
   telegram._telegramobjectr   telegram._userr   telegram._utilsr   telegram._utils.argumentparsingr   r   r   telegram._utils.typesr   affiliateinfor   revenuewithdrawalstater   r   r   r3   r4   r5   r6   r9   r7   r8   rp   r-   r,   <module>r      s   ( P  $ 1 1     ) 3    b b * ( :U3 U3p43); 43n33/ 33l&3!3 &3Ru3/ u3p0 "$6 "3$6 3r-   