
    iY/                        d 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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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Z" G d d          Z G d d          ZdS )a:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotations)AsyncIteratorOptionalTYPE_CHECKING)datetime   )utils)try_enumSKUTypeEntitlementType)SKUFlags)Object)Subscription)SnowflakeTime	Snowflake)Guild)ConnectionState)SKUEntitlement)Userc                  p    e Zd ZdZdZddZd d
Zed!d            Zed"d            Z	d#dZ
ddddd$dZdS )%r   a  Represents a premium offering as a stock-keeping unit (SKU).

    .. versionadded:: 2.4

    Attributes
    -----------
    id: :class:`int`
        The SKU's ID.
    type: :class:`SKUType`
        The type of the SKU.
    application_id: :class:`int`
        The ID of the application that the SKU belongs to.
    name: :class:`str`
        The consumer-facing name of the premium offering.
    slug: :class:`str`
        A system-generated URL slug based on the SKU name.
    )_stateidtypeapplication_idnameslug_flagsstater   data
SKUPayloadc               
   || _         t          |d                   | _        t          t          |d                   | _        t          |d                   | _        |d         | _        |d         | _        |d         | _	        d S )Nr   r   r   r   r   flags)
r   intr   r
   r   r   r   r   r   r   selfr   r    s      R/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/sku.py__init__zSKU.__init__R   sj    ',4:%gtF|<<	#&t,<'=#>#>f	f	=    returnstrc                8    d| j          d| j        d| j        dS )Nz<SKU id=z name=z slug=>)r   r   r   r&   s    r'   __repr__zSKU.__repr__[   s)    J$'JJJJDIJJJJr)   r   c                4    t          j        | j                  S )z0:class:`SKUFlags`: Returns the flags of the SKU.)r   _from_valuer   r.   s    r'   r#   z	SKU.flags^   s     #DK000r)   r   c                4    t          j        | j                  S )zC:class:`datetime.datetime`: Returns the sku's creation time in UTC.r	   snowflake_timer   r.   s    r'   
created_atzSKU.created_atc        #DG,,,r)   subscription_idr$   r   c                  K   | j         j                            | j        |           d{V }t	          || j                   S )a  |coro|

        Retrieves a :class:`.Subscription` with the specified ID.

        .. versionadded:: 2.5

        Parameters
        -----------
        subscription_id: :class:`int`
            The subscription's ID to fetch from.

        Raises
        -------
        NotFound
            An subscription with this ID does not exist.
        HTTPException
            Fetching the subscription failed.

        Returns
        --------
        :class:`.Subscription`
            The subscription you requested.
        Nr    r   )r   httpget_sku_subscriptionr   r   )r&   r7   r    s      r'   fetch_subscriptionzSKU.fetch_subscriptionh   sK      0 [%::47OTTTTTTTTT[9999r)   2   N)limitbeforeafterr>   Optional[int]r?   Optional[SnowflakeTime]r@   userr   AsyncIterator[Subscription]c              >   K   ||t          d           j        j        j        d fd	}d fd}t	          |t
                    r$t          t          j        |d                    }t	          |t
                    r$t          t          j        |d                    }|r||}}n||}}	 |dnt          |d          }	|	dk     rdS  ||	||           d{V \  }
}}t          |
          dk     rd}|
D ]}t          | j                  W V  g)a  Retrieves an :term:`asynchronous iterator` of the :class:`.Subscription` that SKU has.

        .. versionadded:: 2.5

        Examples
        ---------

        Usage ::

            async for subscription in sku.subscriptions(limit=100, user=user):
                print(subscription.user_id, subscription.current_period_end)

        Flattening into a list ::

            subscriptions = [subscription async for subscription in sku.subscriptions(limit=100, user=user)]
            # subscriptions is now a list of Subscription...

        All parameters are optional.

        Parameters
        -----------
        limit: Optional[:class:`int`]
            The number of subscriptions to retrieve. If ``None``, it retrieves every subscription for this SKU.
            Note, however, that this would make it a slow operation. Defaults to ``100``.
        before: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
            Retrieve subscriptions before this date or entitlement.
            If a datetime is provided, it is recommended to use a UTC aware datetime.
            If the datetime is naive, it is assumed to be local time.
        after: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
            Retrieve subscriptions after this date or entitlement.
            If a datetime is provided, it is recommended to use a UTC aware datetime.
            If the datetime is naive, it is assumed to be local time.
        user: :class:`~discord.abc.Snowflake`
            The user to filter by.

        Raises
        -------
        HTTPException
            Fetching the subscriptions failed.
        TypeError
            Both ``after`` and ``before`` were provided, as Discord does not
            support this type of pagination.

        Yields
        --------
        :class:`.Subscription`
            The subscription with the SKU.
        Nz?subscriptions pagination does not support both before and afterretriever$   r?   Optional[Snowflake]r>   rA   c                   K   |r|j         nd } j         || j                    d {V }|r=||t          |          z  }t          t          |d         d                             }|||fS )N)r?   r>   user_idr   r   r   r   lenr   r$   )rF   r?   r>   	before_idr    endpointr&   rC   s        r'   _before_strategyz+SKU.subscriptions.<locals>._before_strategy   s      %+5		I!$')8UYU\]]]]]]]]]D 7$SYY&E3tAwt}#5#5666&&r)   r@   c                   K   |r|j         nd } j         || j                    d {V }|r=||t          |          z  }t          t          |d         d                             }|||fS )N)r@   r>   rI   r   rJ   rK   )rF   r@   r>   after_idr    rN   r&   rC   s        r'   _after_strategyz*SKU.subscriptions.<locals>._after_strategy   s      #(2uxxdH!	        D  7$SYY&E#d2htn"5"5666%%r)   F)highrJ   Td   r   r   r9   )rF   r$   r?   rG   r>   rA   )rF   r$   r@   rG   r>   rA   )	TypeErrorr   r:   list_sku_subscriptions
isinstancer   r   r	   time_snowflakeminrL   r   )r&   r>   r?   r@   rC   rO   rS   strategyr   rF   r    erN   s   `   `       @r'   subscriptionszSKU.subscriptions   s     r %"3]^^^ ;#:
	' 
	' 
	' 
	' 
	' 
	' 
	' 
	'	& 	& 	& 	& 	& 	& 	& 	&" fh'' 	Iu3FGGGHHHFeX&& 	Fe25tDDDEEEE 	5.eHH-ueH	>#mssUCH!||'/x%'G'G!G!G!G!G!G!GD% 4yy3 > >"========	>r)   )r   r   r    r!   r*   r+   )r*   r   r*   r   )r7   r$   r*   r   )
r>   rA   r?   rB   r@   rB   rC   r   r*   rD   )__name__
__module____qualname____doc__	__slots__r(   r/   propertyr#   r5   r<   r]    r)   r'   r   r   5   s         $I) ) ) )K K K K 1 1 1 X1 - - - X-: : : :<  "*.)-r> r> r> r> r> r> r> r>r)   r   c                      e Zd ZdZdZddZdd
Zedd            Zedd            Z	edd            Z
ddZddZddZdS )r   a  Represents an entitlement from user or guild which has been granted access to a premium offering.

    .. versionadded:: 2.4

    Attributes
    -----------
    id: :class:`int`
        The entitlement's ID.
    sku_id: :class:`int`
        The ID of the SKU that the entitlement belongs to.
    application_id: :class:`int`
        The ID of the application that the entitlement belongs to.
    user_id: Optional[:class:`int`]
        The ID of the user that is granted access to the entitlement.
    type: :class:`EntitlementType`
        The type of the entitlement.
    deleted: :class:`bool`
        Whether the entitlement has been deleted.
    starts_at: Optional[:class:`datetime.datetime`]
        A UTC start date which the entitlement is valid. Not present when using test entitlements.
    ends_at: Optional[:class:`datetime.datetime`]
        A UTC date which entitlement is no longer valid. Not present when using test entitlements.
    guild_id: Optional[:class:`int`]
        The ID of the guild that is granted access to the entitlement
    consumed: :class:`bool`
        For consumable items, whether the entitlement has been consumed.
    )r   r   sku_idr   rI   r   deleted	starts_atends_atguild_idconsumedr   r   r    EntitlementPayloadc                \   || _         t          |d                   | _        t          |d                   | _        t          |d                   | _        t          j        |d          | _        t          t          |d                   | _
        |d         | _        t          j        |                    dd                     | _        t          j        |                    dd                     | _        t          j        |d	          | _        |                    d
d          | _        d S )Nr   rh   r   rI   r   ri   rj   rk   rl   rm   F)r   r$   r   rh   r   r	   _get_as_snowflakerI   r
   r   r   ri   
parse_timegetrj   rk   rl   rm   r%   s      r'   r(   zEntitlement.__init__#  s    ',4:tH~..#&t,<'=#>#>&+&=dI&N&N%-otF|%L%L	!)_-2-=dhh{TX>Y>Y-Z-Z+0+;DHHYPT<U<U+V+V','>tZ'P'P"hhz599r)   r*   r+   c                8    d| j          d| j        d| j         dS )Nz<Entitlement id=z type=z	 user_id=r-   )r   r   rI   r.   s    r'   r/   zEntitlement.__repr__0  s)    V$'VVVVt|VVVVr)   Optional[User]c                R    | j         dS | j                            | j                   S )zLOptional[:class:`User`]: The user that is granted access to the entitlement.N)rI   r   get_userr.   s    r'   rC   zEntitlement.user3  s)     <4{##DL111r)   Optional[Guild]c                @    | j                             | j                  S )zNOptional[:class:`Guild`]: The guild that is granted access to the entitlement.)r   
_get_guildrl   r.   s    r'   guildzEntitlement.guild:  s     {%%dm444r)   r   c                4    t          j        | j                  S )zK:class:`datetime.datetime`: Returns the entitlement's creation time in UTC.r3   r.   s    r'   r5   zEntitlement.created_at?  r6   r)   boolc                L    | j         dS t          j                    | j         k    S )zj:class:`bool`: Returns ``True`` if the entitlement is expired. Will be always False for test entitlements.NF)rk   r	   utcnowr.   s    r'   
is_expiredzEntitlement.is_expiredD  s"    <5|~~--r)   Nonec                j   K   | j         j                            | j        | j                   d{V  dS )z|coro|

        Marks a one-time purchase entitlement as consumed.

        Raises
        -------
        NotFound
            The entitlement could not be found.
        HTTPException
            Consuming the entitlement failed.
        N)r   r:   consume_entitlementr   r   r.   s    r'   consumezEntitlement.consumeJ  s@       k2243FPPPPPPPPPPPr)   c                j   K   | j         j                            | j        | j                   d{V  dS )z|coro|

        Deletes the entitlement.

        Raises
        -------
        NotFound
            The entitlement could not be found.
        HTTPException
            Deleting the entitlement failed.
        N)r   r:   delete_entitlementr   r   r.   s    r'   deletezEntitlement.deleteY  s@       k11$2EtwOOOOOOOOOOOr)   N)r   r   r    rn   r^   )r*   rt   )r*   rw   r_   )r*   r|   )r*   r   )r`   ra   rb   rc   rd   r(   r/   re   rC   rz   r5   r   r   r   rf   r)   r'   r   r      s         8I: : : :W W W W 2 2 2 X2 5 5 5 X5 - - - X-. . . .Q Q Q QP P P P P Pr)   r   N)#rc   
__future__r   typingr   r   r   r    r	   enumsr
   r   r   r#   r   objectr   subscriptionr   abcr   r   rz   r   r   r   	types.skur   r!   r   rn   rC   r   __all__rf   r)   r'   <module>r      s   0 # " " " " " 9 9 9 9 9 9 9 9 9 9             5 5 5 5 5 5 5 5 5 5             & & & & & & --------&&&&&&        @> @> @> @> @> @> @> @>FnP nP nP nP nP nP nP nP nP nPr)   