Skip to content

Commit

Permalink
More docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chillymosh committed Sep 20, 2024
1 parent 38c0d3c commit 49afb84
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 119 deletions.
130 changes: 130 additions & 0 deletions docs/references/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,135 @@ Models
:members:


.. attributetable:: twitchio.ContentClassificationLabel

.. autoclass:: twitchio.ContentClassificationLabel
:members:

.. attributetable:: twitchio.RewardCooldown

.. autoclass:: twitchio.RewardCooldown

.. attributetable:: twitchio.RewardLimitSettings

.. autoclass:: twitchio.RewardLimitSettings

.. attributetable:: twitchio.CustomReward

.. autoclass:: twitchio.CustomReward
:members:

.. attributetable:: twitchio.CustomRewardRedemption

.. autoclass:: twitchio.CustomRewardRedemption
:members:

.. attributetable:: twitchio.ChannelEditor

.. autoclass:: twitchio.ChannelEditor
:members:

.. attributetable:: twitchio.FollowedChannelsEvent

.. autoclass:: twitchio.FollowedChannelsEvent
:members:

.. attributetable:: twitchio.FollowedChannels

.. autoclass:: twitchio.FollowedChannels
:members:

.. attributetable:: twitchio.ChannelFollowerEvent

.. autoclass:: twitchio.ChannelFollowerEvent
:members:

.. attributetable:: twitchio.ChannelFollowers

.. autoclass:: twitchio.ChannelFollowers
:members:


.. attributetable:: twitchio.ChannelInfo

.. autoclass:: twitchio.ChannelInfo
:members:

.. attributetable:: twitchio.CharityCampaign

.. autoclass:: twitchio.CharityCampaign
:members:

.. attributetable:: twitchio.CharityValues

.. autoclass:: twitchio.CharityValues
:members:

.. attributetable:: twitchio.CharityDonation

.. autoclass:: twitchio.CharityDonation
:members:

.. attributetable:: twitchio.Chatters

.. autoclass:: twitchio.Chatters
:members:

.. attributetable:: twitchio.ChatterColor

.. autoclass:: twitchio.ChatterColor
:members:

.. attributetable:: twitchio.ChatBadge

.. autoclass:: twitchio.ChatBadge
:members:

.. attributetable:: twitchio.ChatBadgeVersions

.. autoclass:: twitchio.ChatBadgeVersions
:members:

.. attributetable:: twitchio.Emote

.. autoclass:: twitchio.Emote
:members:

.. attributetable:: twitchio.GlobalEmote

.. autoclass:: twitchio.GlobalEmote
:members:

.. attributetable:: twitchio.EmoteSet

.. autoclass:: twitchio.EmoteSet
:members:

.. attributetable:: twitchio.ChannelEmote

.. autoclass:: twitchio.ChannelEmote
:members:

.. attributetable:: twitchio.UserEmote

.. autoclass:: twitchio.UserEmote
:members:

.. attributetable:: twitchio.ChatSettings

.. autoclass:: twitchio.ChatSettings
:members:

.. attributetable:: twitchio.SentMessage

.. autoclass:: twitchio.SentMessage
:members:

.. attributetable:: twitchio.SharedChatSession

.. autoclass:: twitchio.SharedChatSession
:members:




3 changes: 1 addition & 2 deletions twitchio/models/ccls.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@


class ContentClassificationLabel:
"""
Represents a Content Classification Label.
"""Represents a Content Classification Label.
Attributes
-----------
Expand Down
62 changes: 26 additions & 36 deletions twitchio/models/channel_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@


class RewardCooldown(NamedTuple):
"""
NamedTuple that represents a custom reward's cooldown settings.
"""NamedTuple that represents a custom reward's cooldown settings.
Attributes
-----------
Expand All @@ -63,8 +62,7 @@ class RewardCooldown(NamedTuple):


class RewardLimitSettings(NamedTuple):
"""
NamedTuple that represents a custom reward's stream limit settings.
"""NamedTuple that represents a custom reward's stream limit settings.
Attributes
-----------
Expand All @@ -79,8 +77,7 @@ class RewardLimitSettings(NamedTuple):


class CustomReward:
"""
Represents a custom reward from a broadcaster's channel.
"""Represents a custom reward from a broadcaster's channel.
Attributes
-----------
Expand Down Expand Up @@ -198,15 +195,15 @@ def image(self) -> dict[str, str] | None:
return None

def get_image(self, size: Literal["1x", "2x", "4x"] = "2x", use_default: bool = False) -> Asset:
"""
Get an image Asset for the reward at a specified size.
"""Get an image Asset for the reward at a specified size.
Falls back to default images if no custom images have been uploaded.
Parameters
----------
size : str
size: str
The size key of the image. Options are "1x", "2x", "4x". Defaults to "2x".
use_default : bool
use_default: bool
Use default images instead of user uploaded images.
Returns
Expand All @@ -222,15 +219,13 @@ def get_image(self, size: Literal["1x", "2x", "4x"] = "2x", use_default: bool =
return Asset(url, http=self._http)

async def delete(self, *, token_for: str) -> None:
"""
Delete the custom reward.
"""Delete the custom reward.
!!! info
The app used to create the reward is the only app that may delete it.
If the reward's redemption status is UNFULFILLED at the time the reward is deleted, its redemption status is marked as FULFILLED.
The app used to create the reward is the only app that may delete it.
If the reward's redemption status is UNFULFILLED at the time the reward is deleted, its redemption status is marked as FULFILLED.
!!! note
Requires a user access token that includes the channel:manage:redemptions scope.
.. note::
Requires a user access token that includes the ``channel:manage:redemptions`` scope.
Parameters
-----------
Expand All @@ -254,14 +249,13 @@ async def update(
global_cooldown: int | None = None,
skip_queue: bool | None = None,
) -> CustomReward:
"""
Update the custom reward.
"""Update the custom reward.
!!! info
The app used to create the reward is the only app that may update the reward.
.. important::
The app / client ID used to create the reward is the only app that may update the reward.
!!! note
Requires a user access token that includes the channel:manage:redemptions scope.
.. note::
Requires a user access token that includes the ``channel:manage:redemptions`` scope.
Parameters
-----------
Expand Down Expand Up @@ -296,7 +290,7 @@ async def update(
Returns
--------
twitchio.CustomReward
CustomReward
Raises
------
Expand Down Expand Up @@ -342,13 +336,11 @@ def fetch_redemptions(
sort: Literal["OLDEST", "NEWEST"] = "OLDEST",
first: int = 20,
) -> HTTPAsyncIterator[CustomRewardRedemption]:
"""
Fetch redemptions from the CustomReward.
"""Fetch redemptions from the CustomReward.
!!! info
Canceled and fulfilled redemptions are returned for only a few days after they're canceled or fulfilled.
Canceled and fulfilled redemptions are returned for only a few days after they're canceled or fulfilled.
!!! note
.. note::
Requires a user access token that includes the ``channel:read:redemptions`` or ``channel:manage:redemptions`` scope.
Parameters
Expand All @@ -367,7 +359,7 @@ def fetch_redemptions(
Returns
--------
twitchio.HTTPAsyncIterator[twitchio.CustomRewardRedemption]
HTTPAsyncIterator[CustomRewardRedemption]
Raises
------
Expand Down Expand Up @@ -429,10 +421,9 @@ def __repr__(self) -> str:
return f"<CustomRewardRedemption id={self.id} status={self.status} redeemed_at={self.redeemed_at}>"

async def fulfill(self, *, token_for: str) -> CustomRewardRedemption:
"""
Updates a redemption's status to FULFILLED.
"""Updates a redemption's status to FULFILLED.
!!! note
.. note::
Requires a user access token that includes the ``channel:manage:redemptions`` scope.
Parameters
Expand All @@ -454,10 +445,9 @@ async def fulfill(self, *, token_for: str) -> CustomRewardRedemption:
return CustomRewardRedemption(data["data"][0], parent_reward=self.reward, http=self._http)

async def refund(self, *, token_for: str) -> CustomRewardRedemption:
"""
Updates a redemption's status to CANCELED.
"""Updates a redemption's status to CANCELED.
!!! note
.. note::
Requires a user access token that includes the ``channel:manage:redemptions`` scope.
Parameters
Expand Down
31 changes: 12 additions & 19 deletions twitchio/models/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@


class ChannelEditor:
"""
Represents an editor of a channel.
"""Represents an editor of a channel.
Attributes
-----------
user: twitchio.PartialUser
user: PartialUser
PartialUser who has editor permissions.
created_at: datetime.datetime
The datetime of when the user became one of the broadcaster's editors.
Expand All @@ -77,12 +76,11 @@ def __repr__(self) -> str:


class FollowedChannelsEvent:
"""
Represents a followed channel event.
"""Represents a followed channel event.
Attributes
-----------
broadcaster: twitchio.PartialUser
broadcaster: PartialUser
PartialUser that identifies the channel that this user is following.
If no results are found it returns an empty list.
followed_at: datetime.datetime
Expand All @@ -100,8 +98,7 @@ def __repr__(self) -> str:


class FollowedChannels:
"""
Represents channels followed.
"""Represents channels followed.
Attributes
-----------
Expand All @@ -123,12 +120,11 @@ def __repr__(self) -> str:


class ChannelFollowerEvent:
"""
Represents a ChannelFollowerEvent
"""Represents a ChannelFollowerEvent
Attributes
-----------
user: twitchio.PartialUser
user: PartialUser
PartialUser that identifies a user that follows this channel.
followed_at: datetime.datetime
The datetime of when the user followed the channel.
Expand All @@ -145,8 +141,7 @@ def __repr__(self) -> str:


class ChannelFollowers:
"""
Represents channel followers
"""Represents channel followers
Attributes
-----------
Expand All @@ -167,12 +162,11 @@ def __repr__(self) -> str:


class ChannelInfo:
"""
Represents a channel's current information
"""Represents a channel's current information
Attributes
-----------
user: twitchio.PartialUser
user: PartialUser
The user whose channel information was requested.
game_id: int
Current game ID being played on the channel.
Expand Down Expand Up @@ -223,12 +217,11 @@ def __repr__(self) -> str:
return f"<ChannelInfo user={self.user} game_id={self.game_id} game_name={self.game_name} title={self.title} language={self.language} delay={self.delay}>"

async def fetch_game(self) -> Game:
"""
Fetches the [`Game`][twitchio.Game] associated with this ChannelInfo.
"""Fetches the :class:~twitchio.Game` associated with this ChannelInfo.
Returns
-------
twitchio.Game
Game
The game associated with this ChannelInfo.
"""
payload: GamesResponse = await self._http.get_games(ids=[self.game_id])
Expand Down
Loading

0 comments on commit 49afb84

Please sign in to comment.