use serde::{Deserialize, Serialize}; // --- Auth --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct OAuthDto { pub token_type: Option, pub access_token: Option, pub refresh_token: Option, pub expires_in: Option, } #[derive(Debug, Deserialize, Serialize)] pub struct OAuthLoginResponse { pub status: Option, pub user: Option, pub oauth2: Option, pub user_auth_token: Option, } // --- User --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct UserDto { pub id: Option, pub login: Option, pub firstname: Option, pub lastname: Option, pub email: Option, pub display_name: Option, pub country_code: Option, pub subscription: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct SubscriptionDto { pub description: Option, pub end_date: Option, pub is_recurring: Option, pub offer: Option, } // --- Track --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct TrackDto { pub id: i64, pub title: Option, pub version: Option, pub duration: Option, pub track_number: Option, pub playlist_track_id: Option, pub album: Option, pub performer: Option, pub composer: Option, pub work: Option, pub media_number: Option, pub streamable: Option, pub purchasable: Option, pub hires: Option, pub hires_streamable: Option, pub audio_info: Option, pub maximum_bit_depth: Option, pub maximum_sampling_rate: Option, pub maximum_channel_count: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct AudioInfoDto { pub replaygain_track_gain: Option, pub replaygain_track_peak: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct TrackFileUrlDto { pub track_id: Option, pub duration: Option, pub url: Option, pub format_id: Option, pub mime_type: Option, pub sampling_rate: Option, pub bit_depth: Option, } // --- Album --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct AlbumDto { pub id: Option, pub title: Option, pub artist: Option, pub tracks_count: Option, pub duration: Option, pub genre: Option, pub image: Option, pub label: Option, pub release_date_original: Option, pub maximum_bit_depth: Option, pub maximum_sampling_rate: Option, pub hires_streamable: Option, pub streamable: Option, pub release_type: Option, pub tracks: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct TracksWrapper { pub items: Option>, pub total: Option, pub offset: Option, pub limit: Option, } // --- Artist --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct ArtistDto { pub id: Option, pub name: Option, pub albums_count: Option, pub image: Option, pub biography: Option, pub albums: Option>, #[serde(rename = "epSingles")] pub ep_singles: Option>, #[serde(rename = "liveAlbums")] pub live_albums: Option>, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct BiographyDto { pub content: Option, pub summary: Option, } // --- Genre --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct GenreDto { pub id: Option, pub name: Option, pub slug: Option, } // --- Image --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct ImageDto { pub small: Option, pub thumbnail: Option, pub large: Option, pub back: Option, } // --- Label --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct LabelDto { pub id: Option, pub name: Option, } // --- Search --- #[derive(Debug, Deserialize, Serialize)] pub struct SearchCatalogDto { pub query: Option, pub albums: Option>, pub tracks: Option>, pub artists: Option>, pub playlists: Option>, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct SearchResultItems { pub items: Option>, pub total: Option, pub offset: Option, pub limit: Option, } // --- Playlist --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct PlaylistDto { pub id: Option, pub name: Option, pub tracks_count: Option, pub duration: Option, pub description: Option, pub owner: Option, /// 4-cover mosaic at 300 px (preferred) pub images300: Option>, /// 4-cover mosaic at 150 px (fallback) pub images150: Option>, /// 4-cover mosaic at 50 px (last resort) pub images: Option>, pub tracks: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct PlaylistOwnerDto { pub id: Option, pub name: Option, } // --- User library --- #[derive(Debug, Deserialize, Serialize)] pub struct UserPlaylistsDto { pub playlists: Option>, } #[derive(Debug, Deserialize, Serialize)] pub struct FavArtistDto { pub id: Option, pub name: Option, pub albums_count: Option, pub image: Option, } // --- Format --- #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Format { Mp3 = 5, Cd = 6, HiRes96 = 7, HiRes192 = 27, } impl Format { pub fn id(self) -> i32 { self as i32 } pub fn from_id(id: i32) -> Self { match id { 5 => Format::Mp3, 6 => Format::Cd, 7 => Format::HiRes96, 27 => Format::HiRes192, _ => Format::Cd, } } pub fn label(self) -> &'static str { match self { Format::Mp3 => "MP3 320", Format::Cd => "CD 16-bit", Format::HiRes96 => "Hi-Res 24-bit/96kHz", Format::HiRes192 => "Hi-Res 24-bit/192kHz", } } pub fn all() -> &'static [Format] { &[Format::HiRes192, Format::HiRes96, Format::Cd, Format::Mp3] } } // --- QWS --- #[derive(Debug, Deserialize, Clone, Serialize)] pub struct QwsTokenResponse { pub jwt_qws: Option, } #[derive(Debug, Deserialize, Clone, Serialize)] pub struct QwsToken { pub exp: Option, pub jwt: Option, pub endpoint: Option, }