Skip to content

Commit dc22d32

Browse files
committed
Add CCL model and fetch methods
1 parent 2f70d53 commit dc22d32

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

twitchio/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,18 @@ async def fetch_global_chat_badges(self):
826826
data = await self._http.get_global_chat_badges()
827827
return [models.ChatBadge(x) for x in data]
828828

829+
async def fetch_content_classification_labels(self, locale: Optional[str] = None):
830+
"""|coro|
831+
832+
Fetches information about Twitch content classification labels.
833+
834+
Returns:
835+
List[:class:`twitchio.ContentClassificationLabel`]
836+
"""
837+
838+
data = await self._http.get_content_classification_labels(locale)
839+
return [models.ContentClassificationLabel(x) for x in data]
840+
829841
async def get_webhook_subscriptions(self):
830842
"""|coro|
831843

twitchio/http.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,3 +1136,7 @@ async def get_global_chat_badges(self):
11361136

11371137
async def get_channel_chat_badges(self, broadcaster_id: str):
11381138
return await self.request(Route("GET", "chat/badges", "", query=[("broadcaster_id", broadcaster_id)]))
1139+
1140+
async def get_content_classification_labels(self, locale: Optional[str] = None):
1141+
q = [("locale", locale)] if locale is not None else []
1142+
return await self.request(Route("GET", "content_classification_labels", "", query=q))

twitchio/models.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,3 +1910,28 @@ def __init__(self, data: dict):
19101910

19111911
def __repr__(self):
19121912
return f"<ChatBadgeVersions id={self.id} title={self.title}>"
1913+
1914+
1915+
class ContentClassificationLabel:
1916+
"""
1917+
Represents a Content Classification Label.
1918+
1919+
Attributes
1920+
-----------
1921+
id: :class:`str`
1922+
Unique identifier for the CCL.
1923+
description: :class:`str`
1924+
Localized description of the CCL.
1925+
name: :class:`str`
1926+
Localized name of the CCL.
1927+
"""
1928+
1929+
__slots__ = ("id", "description", "name")
1930+
1931+
def __init__(self, data: dict):
1932+
self.id: str = data["id"]
1933+
self.description: str = data["description"]
1934+
self.name: str = data["name"]
1935+
1936+
def __repr__(self):
1937+
return f"<ContentClassificationLabel id={self.id}>"

0 commit comments

Comments
 (0)