
    Qi                         d Z ddlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ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y)zAThis module contains the classes for Telegram Stars transactions.    N)Sequence)TYPE_CHECKINGOptional)TelegramObject)parse_sequence_arg)extract_tzinfo_from_defaultsfrom_timestamp)JSONDict   )TransactionPartner)Botc                        e Zd ZdZdZ	 	 	 ddddededej                  de	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 )StarTransactiona*  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`): Integer amount of Telegram Stars transferred by the transaction.
        nanostar_amount (:obj:`int`, optional): The number of
            :tg-const:`~telegram.constants.StarTransactions.NANOSTAR_VALUE` shares of Telegram
            Stars transferred by the transaction; from 0 to
            :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT`

            .. versionadded:: 21.9
        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`): Integer amount of Telegram Stars transferred by the transaction.
        nanostar_amount (:obj:`int`): Optional. The number of
            :tg-const:`~telegram.constants.StarTransactions.NANOSTAR_VALUE` shares of Telegram
            Stars transferred by the transaction; from 0 to
            :tg-const:`~telegram.constants.StarTransactionsLimit.NANOSTAR_MAX_AMOUNT`

            .. versionadded:: 21.9
        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.
    )amountdateidnanostar_amountreceiversourceN
api_kwargsr   r   r   r   r   r   r   returnc                    t         |   |       || _        || _        || _        || _        || _        || _        | j                  | j
                  | j                  f| _        | j                          y Nr   )
super__init__r   r   r   r   r   r   	_id_attrs_freeze)	selfr   r   r   r   r   r   r   	__class__s	           S/app/.venv/lib/python3.12/site-packages/telegram/_payment/stars/startransactions.pyr   zStarTransaction.__init__X   sk     	J/!"&	4:6>.= GGKKMM

 	    databotr   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`.Nr   )tzinfor   r   r#   r$   )_parse_datar   r	   getr   de_jsonr   )clsr#   r$   
loc_tzinfor    s       r!   r+   zStarTransaction.de_jsonr   s    
 t$ 2#6
%dhhvt&<ZPV+33DHHX4FLX-55dhhz6JCPZwDc22r"   )NNNN)__name__
__module____qualname____doc__	__slots__strintdtmdatetimer   r   r
   r   classmethodr+   __classcell__r    s   @r!   r   r   %   s    .` RI 0415)- *.  ll	
 +, -. "# X& 
4 >B3H%3,4UO3	#	$3 3r"   r   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(   )r)   r   de_listr*   r   r+   )r,   r#   r$   r    s      r!   r+   zStarTransactions.de_json   sO    
 t$<.66txx7OQTU^wDc22r"   r.   )r/   r0   r1   r2   r3   r   r   r   r
   r   r8   r+   r9   r:   s   @r!   r<   r<      ss     "I \`$_5FNxFX >B
3H%
3,4UO
3	$	%
3 
3r"   r<   )r2   r7   r6   collections.abcr   typingr   r   telegram._telegramobjectr   telegram._utils.argumentparsingr   telegram._utils.datetimer   r	   telegram._utils.typesr
   transactionpartnerr   telegramr   r   r<    r"   r!   <module>rJ      sD   ( H  $ * 3 > Q * 2^3n ^3B&3~ &3r"   