This commit is contained in:
477
src/twitchclient/schema.py
Normal file
477
src/twitchclient/schema.py
Normal file
@ -0,0 +1,477 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Literal, TypedDict
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
status_code: int
|
||||
error: str
|
||||
|
||||
def __init__(self, status_code: int, error: str) -> None:
|
||||
self.status_code = status_code
|
||||
self.error = error
|
||||
super().__init__(f'{status_code}: {error}')
|
||||
|
||||
|
||||
class Pagination(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
cursor: str
|
||||
|
||||
|
||||
class StartCommercialData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
length: int
|
||||
message: str
|
||||
retry_after: int
|
||||
|
||||
|
||||
class StartCommercial(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[StartCommercialData]
|
||||
|
||||
|
||||
class AdScheduleData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
next_ad_at: datetime | None
|
||||
last_ad_at: datetime | None
|
||||
duration: int
|
||||
preroll_free_time: int
|
||||
snooze_count: int
|
||||
snooze_refresh_at: datetime
|
||||
|
||||
|
||||
class AdSchedule(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[AdScheduleData]
|
||||
|
||||
|
||||
class SnoozeNextAdData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
snooze_count: int
|
||||
snooze_refresh_at: datetime
|
||||
next_ad_at: datetime
|
||||
|
||||
|
||||
class SnoozeNextAd(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[SnoozeNextAdData]
|
||||
|
||||
|
||||
class DateRange(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
started_at: datetime
|
||||
ended_at: datetime
|
||||
|
||||
|
||||
class ExtensionAnalyticsData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
extension_id: str
|
||||
URL: str
|
||||
type: str
|
||||
date_range: DateRange
|
||||
|
||||
|
||||
class ExtensionAnalytics(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[ExtensionAnalyticsData]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
|
||||
|
||||
class GameAnalyticsData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
game_id: int
|
||||
URL: str
|
||||
type: str
|
||||
date_range: DateRange
|
||||
|
||||
|
||||
class GameAnalytics(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[GameAnalyticsData]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
|
||||
|
||||
class BitsLeaderboardData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
user_id: int
|
||||
user_login: str
|
||||
user_name: str
|
||||
rank: int
|
||||
score: int
|
||||
|
||||
|
||||
class BitsLeaderboard(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[BitsLeaderboardData]
|
||||
date_range: DateRange
|
||||
total: int
|
||||
|
||||
|
||||
class CheermotesImageAnimated(BaseModel):
|
||||
field_1: str = Field(..., alias='1')
|
||||
field_1_5: str = Field(..., alias='1.5')
|
||||
field_2: str = Field(..., alias='2')
|
||||
field_3: str = Field(..., alias='3')
|
||||
field_4: str = Field(..., alias='4')
|
||||
|
||||
|
||||
class CheermotesImageStatic(BaseModel):
|
||||
field_1: str = Field(..., alias='1')
|
||||
field_1_5: str = Field(..., alias='1.5')
|
||||
field_2: str = Field(..., alias='2')
|
||||
field_3: str = Field(..., alias='3')
|
||||
field_4: str = Field(..., alias='4')
|
||||
|
||||
|
||||
class CheermotesImage(BaseModel):
|
||||
animated: CheermotesImageAnimated
|
||||
static: CheermotesImageStatic
|
||||
|
||||
|
||||
class CheermotesImages(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
light: CheermotesImage
|
||||
dark: CheermotesImage
|
||||
|
||||
|
||||
class CheermotesTier(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
min_bits: int
|
||||
id: Literal['1', '100', '500', '1000', '5000', '10000', '100000']
|
||||
color: str
|
||||
can_cheer: bool
|
||||
show_in_bits_card: bool
|
||||
images: CheermotesImages
|
||||
|
||||
|
||||
class CheermotesData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
prefix: str
|
||||
tiers: list[CheermotesTier]
|
||||
type: Literal[
|
||||
'global_first_party',
|
||||
'global_third_party',
|
||||
'channel_custom',
|
||||
'display_only',
|
||||
'sponsored',
|
||||
]
|
||||
order: int
|
||||
last_updated: datetime
|
||||
is_charitable: bool
|
||||
|
||||
|
||||
class Cheermotes(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[CheermotesData]
|
||||
|
||||
|
||||
class ExtensionProductCost(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
amount: int
|
||||
type: Literal['bits']
|
||||
|
||||
|
||||
class ExtensionProductData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
domain: str
|
||||
sku: str
|
||||
cost: ExtensionProductCost
|
||||
inDevelopment: bool
|
||||
displayName: str
|
||||
expiration: str
|
||||
broadcast: bool
|
||||
|
||||
|
||||
class ExtensionTransactionsData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
id: str
|
||||
timestamp: datetime
|
||||
broadcaster_id: int
|
||||
broadcaster_login: str
|
||||
broadcaster_name: str
|
||||
user_id: int
|
||||
user_login: str
|
||||
user_name: str
|
||||
product_type: Literal['BITS_IN_EXTENSION']
|
||||
product_data: ExtensionProductData
|
||||
|
||||
|
||||
class ExtensionTransactions(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[ExtensionTransactionsData]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
|
||||
|
||||
class ContentClassificationLabel(TypedDict):
|
||||
id: Literal[
|
||||
'DebatedSocialIssuesAndPolitics',
|
||||
'DrugsIntoxication',
|
||||
'SexualThemes',
|
||||
'ViolentGraphic',
|
||||
'Gambling',
|
||||
'ProfanityVulgarity',
|
||||
]
|
||||
is_enabled: bool
|
||||
|
||||
|
||||
class ChannelInformation(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
broadcaster_id: int
|
||||
broadcaster_login: str
|
||||
broadcaster_name: str
|
||||
broadcaster_language: str
|
||||
game_name: str
|
||||
game_id: int | str
|
||||
title: str
|
||||
delay: int
|
||||
tags: list[str]
|
||||
content_classification_labels: list[str]
|
||||
is_branded_content: bool
|
||||
|
||||
|
||||
class ChannelsInformation(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[ChannelInformation]
|
||||
|
||||
|
||||
class ChannelEditor(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
user_id: int
|
||||
user_name: str
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class ChannelEditors(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[ChannelEditor]
|
||||
|
||||
|
||||
class FollowedChannel(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
broadcaster_id: int
|
||||
broadcaster_login: str
|
||||
broadcaster_name: str
|
||||
followed_at: datetime
|
||||
|
||||
|
||||
class FollowedChannels(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[FollowedChannel]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
total: int
|
||||
|
||||
|
||||
class ChannelFollower(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
user_id: int
|
||||
user_login: str
|
||||
user_name: str
|
||||
followed_at: datetime
|
||||
|
||||
|
||||
class ChannelFollowers(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[ChannelFollower]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
total: int
|
||||
|
||||
|
||||
class CustomRewardImage(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
url_1x: str
|
||||
url_2x: str
|
||||
url_4x: str
|
||||
|
||||
|
||||
class MaxPerStreamSetting(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
is_enabled: bool
|
||||
max_per_stream: int
|
||||
|
||||
|
||||
class MaxPerUserPerStreamSetting(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
is_enabled: bool
|
||||
max_per_user_per_stream: int
|
||||
|
||||
|
||||
class GlobalCooldownSetting(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
is_enabled: bool
|
||||
global_cooldown_seconds: int
|
||||
|
||||
|
||||
class CustomReward(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
broadcaster_id: int
|
||||
broadcaster_login: str
|
||||
broadcaster_name: str
|
||||
id: int
|
||||
title: str
|
||||
prompt: str
|
||||
cost: int
|
||||
is_paused: bool
|
||||
is_in_stock: bool
|
||||
background_color: str
|
||||
is_enabled: bool
|
||||
is_user_input_required: bool
|
||||
should_redemptions_skip_request_queue: bool
|
||||
redemptions_redeemed_current_stream: int | None
|
||||
cooldown_expires_at: datetime | None
|
||||
image: CustomRewardImage | None
|
||||
default_image: CustomRewardImage
|
||||
max_per_stream_setting: MaxPerStreamSetting
|
||||
max_per_user_per_stream_setting: MaxPerUserPerStreamSetting
|
||||
global_cooldown_setting: GlobalCooldownSetting
|
||||
|
||||
|
||||
class CustomRewards(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[CustomReward]
|
||||
|
||||
|
||||
class CustomRewardRedemptionReward(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
id: str
|
||||
title: str
|
||||
prompt: str
|
||||
cost: int
|
||||
|
||||
|
||||
class CustomRewardRedemption(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
id: int
|
||||
broadcaster_id: int
|
||||
broadcaster_login: str
|
||||
broadcaster_name: str
|
||||
user_id: int
|
||||
user_login: str
|
||||
user_name: str
|
||||
user_input: str
|
||||
status: Literal['CANCELED', 'FULFILLED', 'UNFULFILLED']
|
||||
redeemed_at: datetime
|
||||
reward: CustomRewardRedemptionReward
|
||||
|
||||
|
||||
class CustomRewardRedemptions(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[CustomRewardRedemption]
|
||||
|
||||
|
||||
class CharityCampaignCurrentAmount(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
amount: int
|
||||
decimal_places: int
|
||||
currency: str
|
||||
|
||||
|
||||
class CharityCampaignTargetAmount(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
value: int
|
||||
decimal_places: int
|
||||
currency: str
|
||||
|
||||
|
||||
class CharityCampaignData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
id: str
|
||||
broadcaster_id: int
|
||||
broadcaster_login: str
|
||||
broadcaster_name: str
|
||||
charity_name: str
|
||||
charity_description: str
|
||||
charity_logo: str
|
||||
charity_website: str
|
||||
current_amount: CharityCampaignCurrentAmount
|
||||
target_amount: CharityCampaignTargetAmount
|
||||
|
||||
|
||||
class CharityCampaign(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[CharityCampaignData]
|
||||
|
||||
|
||||
class CharityDonationAmount(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
value: int
|
||||
decimal_places: int
|
||||
currency: str
|
||||
|
||||
|
||||
class CharityDonation(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
id: str
|
||||
campaign_id: str
|
||||
user_id: int
|
||||
user_login: str
|
||||
user_name: str
|
||||
amount: CharityDonationAmount
|
||||
|
||||
|
||||
class CharityDonations(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[CharityDonation]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
|
||||
|
||||
class ChattersData(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
user_id: int
|
||||
user_login: str
|
||||
user_name: str
|
||||
|
||||
|
||||
class Chatters(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid')
|
||||
|
||||
data: list[ChattersData]
|
||||
pagination: Pagination | dict[Any, Any] | None = None
|
||||
total: int
|
||||
Reference in New Issue
Block a user