"""Schema for channel metrics endpoint.""" from marshmallow import fields from analytics.schemas.common import BaseSchema, SourceSchema class ChannelTopVideosSubSchema(BaseSchema): """Marshmallow schema for top videos.""" video_id = fields.String(data_key="videoId") views = fields.Integer() premium_views = fields.Integer(data_key="premiumViews") average_view_duration_seconds = fields.Float(data_key="averageViewDurationSeconds") average_view_duration_percentage = fields.Float( data_key="averageViewDurationPercentage" ) watch_time_minutes = fields.Float(data_key="watchTimeMinutes") premium_watch_time_minutes = fields.Float(data_key="premiumWatchTimeMinutes") class ChannelTopVideosSchema(BaseSchema): """Marshmallow schema for channel top videos.""" channel_id = fields.String() top_channel_videos = fields.Nested(nested=ChannelTopVideosSubSchema, many=True) sources = fields.Nested(SourceSchema, many=True)