L iSdZddlmZddlmZmZmZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZmZmZmZdd lmZmZd dlmZd dlm Z er ddl!Z"ddlm#Z#GddeZ$Gdde$Z%Gdde$Z&Gdde$Z'Gdde$Z(Gdde$Z)Gdde$Z*Gd d!e$Z+y)"zIThis module contains the classes for Telegram Stars transaction partners.)Sequence) TYPE_CHECKINGFinalOptional) constants)Chat)Gift) PaidMedia)TelegramObject)User)enum)de_json_optionalde_list_optionalparse_sequence_arg to_timedelta)JSONDict TimePeriod) AffiliateInfo)RevenueWithdrawalStateN)BotceZdZUdZdZej jZee e d< ej jZ ee e d< ej jZ ee e d< ej jZ ee e d< ej jZee e d< ej jZee e d< ej j Zee e d < d d d e d eedd ffdZeddededddffd ZxZS)TransactionPartneraGThis 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. )typeAFFILIATE_PROGRAMCHATFRAGMENTOTHER TELEGRAM_ADS TELEGRAM_APIUSERN api_kwargsrr#returnct||tjtj |||_|j f|_|jy)Nr") super__init__r get_memberrTransactionPartnerTyper _id_attrs_freeze)selfrr# __class__s p/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/_payment/stars/transactionpartner.pyr'zTransactionPartner.__init__csD J/)I)I4QUV )) databotrc|j|}|jt|jt|j t |jt|jt|jt|jti}|tur8|j!d|vr%||j#dj%||St&|I||S)aWConverts 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. rr0r1) _parse_datar"TransactionPartnerAffiliateProgramrTransactionPartnerChatrTransactionPartnerFragmentr!TransactionPartnerUserrTransactionPartnerTelegramAdsr TransactionPartnerTelegramApirTransactionPartnerOtherrgetpopde_jsonr&)clsr0r1_class_mappingr-s r.r>zTransactionPartner.de_jsonjst$  ! !#E HH, LL4 HH,   ;   ; II.?  $ $&)9^)K!$((6"23;;3;O OwDc22r/N)__name__ __module__ __qualname____doc__ __slots__rr)rrstr__annotations__rrrrr r!rrr' classmethodr> __classcell__r-s@r.rr1s34I$-$D$D$V$VuSzV!77<>E5:>B(??LLL%*LI(??LLL%*LI 77<r?r0r1r-s r.r>z*TransactionPartnerAffiliateProgram.de_jsonsC t$/0H$PST^wDc22r/rA) rBrCrDrErFintrrr'rIr>rJrKs@r.r5r5s.9I *. *. !v& X&   "4833"*5/3 -33r/r5c xeZdZdZdZ ddddedeedeeddffd Z e dd ed ed ddffd Z xZ S)r6aDescribes 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. )chatgiftNr"rXrYr#r$ct|tj||j 5||_||_|j|j f|_dddy#1swYyxYwrP) r&r'rrrQrXrYrr*)r,rXrYr#r-s r.r'zTransactionPartnerChat.__init__sd 055*M ^^  "DI(,DI  DN    rRr0r1rc|j|}t|jdt||d<t|jdt||d<t |||S)rTrXrYr3)r4rr<rr r&r>rUs r.r>zTransactionPartnerChat.de_jsons\t$'(8$DV '(8$DV wDc22r/rA) rBrCrDrErFrrr rr'rIr>rJrKs@r.r6r6s&I $ *. tn X&   $383(5/3E]33r/r6cteZdZdZdZ ddddeddeeddffd Zedd ed ed ddffd Z xZ S)r7aDescribes 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]rr#r$ct|tj||j 5||_dddy#1swYyxYwrP)r&r'rrrQr])r,r]r#r-s r.r'z#TransactionPartnerFragment.__init__sI 099jQ ^^  WFVD ! W W Ws AA r0r1rc|j|}t|jdt||d<t|||S)rTr]r3)r4rr<rr&r>rUs r.r>z"TransactionPartnerFragment.de_jsonsJt$#3 HH' (*@#$   wDc22r/rA) rBrCrDrErFrrr'rIr>rJrKs@r.r7r7s &I@D W*. W"#;< WX& W  W383(5/3Ea33r/r7ceZdZdZdZ ddddedddeed eeed eed ee d ee d ee dee dee ddffdZedde dedddffd ZxZS)r8aDescribes 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 (:obj:`int` | :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 .. versionchanged:: v22.2 Accepts :obj:`int` objects as well as :class:`datetime.timedelta`. 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 ) affiliaterYinvoice_payload paid_mediapaid_media_payloadpremium_subscription_durationsubscription_periodtransaction_typeuserNr"rgrhr rbrcrdrfrYrarer#r$c t |tj| |j 5||_||_||_t||_ ||_ t||_ ||_ | |_||_|j |j |jf|_dddy#1swYyxYwrP)r&r'rr!rQrhrarbrrcrdrrfrYrergrr*) r,rgrhrbrcrdrfrYrarer#r-s r.r'zTransactionPartnerUser.__init__s 055*M ^^  "DI6?DN2AD ?QR\?]DO5GD #@LM`@aD $(,DI@]D .)9D !  %%DN   s A:B44B=r0r1rc`|j|}t|jdt||d<t|jdt||d<t |jdt ||d<t|jdt||d<t|%||S)rTrhrarcrYr3) r4rr<r rrr r r&r>rUs r.r>zTransactionPartnerUser.de_jsonst$'(8$DV ,TXXk-BMSVW[-dhh|.DiQTU\'(8$DV wDc22r/)NNNNNNNrA)rBrCrDrErFrGrrr rr rrVrr'rIr>rJrKs@r.r8r8stl I *.48,048#-17;*."#  Xi01  %SM &j1tnM*(0}X& B 38 3(5/ 3E] 3 3r/r8c<eZdZdZdZdddeeddffdZxZS)r;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$cdt|tj||j yrP)r&r'rrr+r,r#r-s r.r'z TransactionPartnerOther.__init__s% 066:N r/ rBrCrDrErFrrr'rJrKs@r.r;r;/I;?hx&8Dr/r;c<eZdZdZdZdddeeddffdZxZS)r9zDescribes 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`. rlNr"r#r$cdt|tj||j yrP)r&r'rrr+rns r.r'z&TransactionPartnerTelegramAds.__init__s% 0==*U r/rorKs@r.r9r9rpr/r9c@eZdZdZdZdddedeeddffdZxZ S) r:aDescribes a transaction with payment for `paid broadcasting `_. 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"rtr#r$ct|tj||j 5||_|j f|_dddy#1swYyxYwrP)r&r'rr rQrtr*)r,rtr#r-s r.r'z&TransactionPartnerTelegramApi.__init__sS 0==*U ^^  3&3D "002DN 3 3 3s AA) rBrCrDrErFrVrrr'rJrKs@r.r:r:s7&#IOS3c3(8:L3X\33r/r:),rEcollections.abcrtypingrrrtelegramrtelegram._chatrtelegram._giftsr telegram._paidmediar telegram._telegramobjectr telegram._userr telegram._utilsr telegram._utils.argumentparsingrrrrtelegram._utils.typesrr affiliateinforrevenuewithdrawalstaterdatetimedtmrrr5r6r7r8r;r9r:rlr/r.rs(P$11 )3  7(:U3U3p43);43n33/33l&3!3&3Rn3/n3b0"$6"3$63r/