def serialize(obj): """JSON serializer for team objects""" if isinstance(obj, Team): return { "name": obj.name, "id": obj.id, "owner": obj.owner, "is_my_team": obj.is_my_team, "waiver_priority": obj.waiver_priority, "move_count": obj.move_count, "trade_count": obj.trade_count, "matchups": None if not obj.matchups else [Matchup.serialize(x) for x in obj.matchups], "average_stats": None if not obj.average_stats else Stats.serialize( obj.average_stats) } else: raise TypeError(obj)
def serialize(obj): """JSON serializer for matchup objects""" if isinstance(obj, Matchup): return { "week": obj.week, "week_start": str(obj.week_start), "week_end": str(obj.week_end), "has_started": obj.has_started, "is_complete": obj.is_complete, "is_tied": obj.is_tied, "won": obj.won, "stats": Stats.serialize(obj.stats) } else: raise TypeError(obj)