def from_dict(obj: Any) -> 'User': if not isinstance(obj, dict): return None id = from_str(obj.get("id")) full_name = from_str(obj.get("full_name")) name = from_str(obj.get("name")) discriminator = from_union([from_str, from_none], obj.get("discriminator")) url = from_str(obj.get("url")) avatar = from_union([from_str, from_none], obj.get("avatar")) pronouns = from_union([from_str, from_none], obj.get("pronouns")) flair = from_union([from_str, from_none], obj.get("flair")) twitch_name = from_union([from_str, from_none], obj.get("twitch_name")) twitch_display_name = from_union([from_str, from_none], obj.get("twitch_display_name")) twitch_channel = from_union([from_str, from_none], obj.get("twitch_channel")) can_moderate = from_union([from_bool, from_none], obj.get("can_moderate")) stats = from_union([Stats.from_dict, from_none], obj.get("stats")) return User(id=id, full_name=full_name, name=name, discriminator=discriminator, url=url, avatar=avatar, pronouns=pronouns, flair=flair, twitch_name=twitch_name, twitch_display_name=twitch_display_name, twitch_channel=twitch_channel, can_moderate=can_moderate, stats=stats)
def from_dict(obj: Any) -> 'Status': if not isinstance(obj, dict): return None value = from_str(obj.get("value")) verbose_value = from_str(obj.get("verbose_value")) help_text = from_str(obj.get("help_text")) return Status(value, verbose_value, help_text)
def from_dict(obj: Any) -> 'RaceCategory': if not isinstance(obj, dict): return None name = from_str(obj.get("name")) short_name = from_str(obj.get("short_name")) slug = from_str(obj.get("slug")) url = from_str(obj.get("url")) data_url = from_str(obj.get("data_url")) image = from_union([from_str, from_none], obj.get("image")) return RaceCategory(name, short_name, slug, url, data_url, image)
def from_dict(obj: Any) -> 'Ranking': if not isinstance(obj, dict): return None user = User.from_dict(obj.get("user")) place = from_int(obj.get("place")) place_ordinal = from_str(obj.get("place_ordinal")) score = from_int(obj.get("score")) best_time = from_str(obj.get("best_time")) times_raced = from_int(obj.get("times_raced")) return Ranking( user=user, place=place, place_ordinal=place_ordinal, score=score, best_time=best_time, times_raced=times_raced)
def from_dict(obj: Any) -> 'Standings': if not isinstance(obj, dict): return None RacerName = from_str(obj.get("RacerName")) Season = from_str(obj.get("Season")) Mode = from_str(obj.get("Mode")) Rating = from_int(obj.get("Rating")) Rank = from_int(obj.get("Rank")) Change = from_int(obj.get("Change")) Wins = from_int(obj.get("Wins")) Losses = from_int(obj.get("Losses")) Ties = from_int(obj.get("Ties")) return Standings( RacerName=RacerName, Season=Season, Mode=Mode, Rating=Rating, Rank=Rank, Change=Change, Wins=Wins, Losses=Losses, Ties=Ties)
def from_dict(obj: Any) -> 'Leaderboard': if not isinstance(obj, dict): return None goal = from_str(obj.get("goal")) num_ranked = from_int(obj.get("num_ranked")) rankings = from_list(Ranking.from_dict, obj.get("rankings")) return Leaderboard(goal, num_ranked, rankings)
def from_dict(obj: Any) -> 'Flag': if not isinstance(obj, dict): return None Mode = from_str(obj.get("Mode")) flag_id = from_int(obj.get("flag_id")) HoursToComplete = from_int(obj.get("HoursToComplete")) return Flag( Mode=Mode, flag_id=flag_id, HoursToComplete=HoursToComplete)
def from_dict(obj: Any) -> 'Standings': if not isinstance(obj, dict): return None race_id = from_int(obj.get("race_id")) Season = from_str(obj.get("Season")) Mode = from_str(obj.get("Mode")) StartTime = (pytz.timezone('US/Eastern').localize( from_datetime(obj.get("StartTime")) )) RaceName = from_str(obj.get("RaceName")) HasCompleted = from_bool(obj.get("HasCompleted")) ParticipantCount = from_int(obj.get("ParticipantCount")) return ScheduleItem( race_id=race_id, Season=Season, Mode=Mode, StartTime=StartTime, RaceName=RaceName, HasCompleted=HasCompleted, ParticipantCount=ParticipantCount )
def from_dict(obj: Any) -> 'ChatMessage': if not isinstance(obj, dict): return None id = from_str(obj.get("id")) user = user_from_dict(obj.get("user")) bot = from_str(obj.get("bot")) posted_at = from_datetime(obj.get("posted_at")) message = from_str(obj.get("message")) message_plain = from_str(obj.get("message_plain")) highlight = from_bool(obj.get("highlight")) is_bot = from_bool(obj.get("is_bot")) is_system = from_bool(obj.get("is_system")) return ChatMessage( id=id, user=user, bot=bot, posted_at=posted_at, message=message, message_plain=message_plain, highlight=highlight, is_bot=is_bot, is_system=is_system)
def from_dict(obj: Any) -> 'Season': if not isinstance(obj, dict): return None season_id = from_int(obj.get("season_id")) SeasonName = from_str(obj.get("SeasonName")) IsCurrentSeason = from_bool(obj.get("IsCurrentSeason")) return Season( season_id=season_id, SeasonName=SeasonName, IsCurrentSeason=IsCurrentSeason )
def from_dict(obj: Any) -> 'RacerResult': if not isinstance(obj, dict): return None RacerName = from_str(obj.get("RacerName")) OpponentRacerName = from_str(obj.get("OpponentRacerName")) Mode = from_str(obj.get("Mode")) race_id = from_int(obj.get("race_id")) Season = from_str(obj.get("Season")) Result = from_str(obj.get("Result")) FinishTime = from_str(obj.get("FinishTime")) OpponentFinishTime = from_str(obj.get("OpponentFinishTime")) return RacerResult( RacerName=RacerName, OpponentRacerName=OpponentRacerName, Mode=Mode, race_id=race_id, Season=Season, Result=Result, FinishTime=FinishTime, OpponentFinishTime=OpponentFinishTime )
def from_dict(obj: Any) -> 'Category': assert isinstance(obj, dict) name = from_str(obj.get("name")) short_name = from_str(obj.get("short_name")) slug = from_str(obj.get("slug")) url = from_str(obj.get("url")) data_url = from_str(obj.get("data_url")) image = from_str(obj.get("image")) info = from_str(obj.get("info")) streaming_required = from_bool(obj.get("streaming_required")) owners = from_list(User.from_dict, obj.get("owners")) moderators = from_list(User.from_dict, obj.get("moderators")) goals = from_list(from_str, obj.get("goals")) current_races = from_list( CurrentRace.from_dict, obj.get("current_races")) return Category( name=name, short_name=short_name, slug=slug, url=url, data_url=data_url, image=image, info=info, streaming_required=streaming_required, owners=owners, moderators=moderators, goals=goals, current_races=current_races )
def from_dict(obj: Any) -> 'Race': if not isinstance(obj, dict): return None name = from_str(obj.get("name")) slug = from_str(obj.get("slug")) status = Status.from_dict(obj.get("status")) url = from_str(obj.get("url")) data_url = from_str(obj.get("data_url")) websocket_url = from_union([from_str, from_none], obj.get("websocket_url")) websocket_bot_url = from_union([from_str, from_none], obj.get("websocket_bot_url")) websocket_oauth_url = from_union([from_str, from_none], obj.get("websocket_oauth_url")) category = RaceCategory.from_dict(obj.get("category")) goal = Goal.from_dict(obj.get("goal")) info = from_str(obj.get("info")) entrants_count = from_int(obj.get("entrants_count")) entrants_count_inactive = from_int(obj.get("entrants_count_inactive")) entrants = from_union( [lambda x: from_list(Entrant.from_dict, x), from_none], obj.get("entrants")) opened_at = from_datetime(obj.get("opened_at")) start_delay = from_union([from_timedelta, from_none], obj.get("start_delay")) started_at = from_union([from_datetime, from_none], (obj.get("started_at"))) ended_at = from_union([from_datetime, from_none], (obj.get("ended_at"))) cancelled_at = from_union([from_datetime, from_none], (obj.get("cancelled_at"))) unlisted = from_union([from_bool, from_none], obj.get("unlisted")) time_limit = from_timedelta(obj.get("time_limit")) streaming_required = from_union([from_bool, from_none], obj.get("streaming_required")) auto_start = from_union([from_bool, from_none], obj.get("auto_start")) opened_by = from_union([lambda x: User.from_dict(x), from_none], obj.get("opened_by")) monitors = from_union( [lambda x: from_list(User.from_dict, x), from_none], obj.get("monitors")) recordable = from_union([from_bool, from_none], obj.get("recordable")) recorded = from_union([from_bool, from_none], obj.get("recorded")) recorded_by = from_union([lambda x: User.from_dict(x), from_none], obj.get("recorded_by")) allow_comments = from_union([from_bool, from_none], obj.get("allow_comments")) hide_comments = from_union([from_bool, from_none], obj.get("hide_comments")) allow_midrace_chat = from_union([from_bool, from_none], obj.get("allow_midrace_chat")) allow_non_entrant_chat = from_union([from_bool, from_none], obj.get("allow_non_entrant_chat")) chat_message_delay = from_union([from_str, from_none], obj.get("chat_message_delay")) version = from_union([from_int, from_none], obj.get("version")) entrants_count_finished = from_union( [from_int, from_none], obj.get("entrants_count_finished")) return Race(name=name, status=status, url=url, data_url=data_url, websocket_url=websocket_url, websocket_bot_url=websocket_bot_url, websocket_oauth_url=websocket_oauth_url, category=category, goal=goal, info=info, entrants_count=entrants_count, entrants_count_inactive=entrants_count_inactive, opened_at=opened_at, time_limit=time_limit, entrants=entrants, version=version, started_at=started_at, ended_at=ended_at, cancelled_at=cancelled_at, unlisted=unlisted, streaming_required=streaming_required, auto_start=auto_start, opened_by=opened_by, monitors=monitors, recordable=recordable, recorded=recorded, recorded_by=recorded_by, allow_comments=allow_comments, hide_comments=hide_comments, allow_midrace_chat=allow_midrace_chat, allow_non_entrant_chat=allow_non_entrant_chat, chat_message_delay=chat_message_delay, start_delay=start_delay, entrants_count_finished=entrants_count_finished, slug=slug)
def from_dict(obj: Any) -> 'Goal': if not isinstance(obj, dict): return None name = from_str(obj.get("name")) custom = from_bool(obj.get("custom")) return Goal(name, custom)
def from_dict(obj: Any) -> 'Racer': if not isinstance(obj, dict): return None racer_id = from_int(obj.get("racer_id")) RacerName = from_str(obj.get("RacerName")) return Racer(racer_id=racer_id, RacerName=RacerName)