"""Schema for downloads endpoint.""" from marshmallow import fields from sound_recordings.schemas.common import ( BaseSchema, DownloadBreakdownItemSchema, DownloadBreakdownSchema, DownloadsCountriesSchema, SourceSchema, ) class StoreItemSchema(DownloadBreakdownSchema): """Schema for downloads by store.""" store_id = fields.Integer(attribute="id", data_key="id") name = fields.String() class DownloadsSchema(BaseSchema): """Schema for sound recording downloads.""" isrc = fields.String() aggregate = fields.Nested(DownloadBreakdownSchema, default={}) stores = fields.Nested(StoreItemSchema, many=True) sources = fields.Nested(SourceSchema, many=True) class DownloadsStoreSchema(BaseSchema): """Schema for sound recording downloads aggregate.""" items = fields.Nested(DownloadBreakdownItemSchema, many=True) store_id = fields.Integer(attribute="id", data_key="id") name = fields.String() class DownloadsByStoreSchema(BaseSchema): """Schema for sound recording downloads by store.""" isrc = fields.String() stores = fields.Nested(DownloadsStoreSchema, many=True) class DownloadsByCountrySchema(BaseSchema): """Schema for sound recording downloads by country.""" isrc = fields.String() countries = fields.Nested(DownloadsCountriesSchema, many=True) class DownloadsAllSchema(BaseSchema): """Schema for sound recording downloads all.""" isrc = fields.String() items = fields.Nested(DownloadBreakdownItemSchema, many=True) class DownloadsProductsSchema(BaseSchema): """Schema for downloads by product timeseries.""" product_id = fields.String() items = fields.Nested(DownloadBreakdownItemSchema, many=True) class DownloadsByProductSchema(BaseSchema): """Schema for sound-recording downloads by product.""" isrc = fields.String() products = fields.Nested(DownloadsProductsSchema, many=True)