spotifyio/crates/model/src/show.rs

119 lines
3.4 KiB
Rust

use serde::{Deserialize, Serialize};
use crate::{CopyrightType, DatePrecision, EpisodeId, Image, Page, ShowId};
/// Copyright object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Copyright {
pub text: String,
#[serde(rename = "type")]
pub _type: CopyrightType,
}
/// Simplified show object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct SimplifiedShow {
pub available_markets: Vec<String>,
pub copyrights: Vec<Copyright>,
pub description: String,
pub explicit: bool,
pub href: String,
pub id: ShowId<'static>,
pub images: Vec<Image>,
pub is_externally_hosted: Option<bool>,
pub languages: Vec<String>,
pub media_type: String,
pub name: String,
pub publisher: String,
}
/// [`SimplifiedShow`] wrapped by [`Vec`]
#[derive(Deserialize)]
pub struct SimplifiedShows {
pub shows: Vec<SimplifiedShow>,
}
/// Saved show object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Show {
pub added_at: String,
pub show: SimplifiedShow,
}
/// Full show object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct FullShow {
pub available_markets: Vec<String>,
pub copyrights: Vec<Copyright>,
pub description: String,
pub explicit: bool,
pub episodes: Page<SimplifiedEpisode>,
pub href: String,
pub id: ShowId<'static>,
pub images: Vec<Image>,
pub is_externally_hosted: Option<bool>,
pub languages: Vec<String>,
pub media_type: String,
pub name: String,
pub publisher: String,
}
/// Simplified episode object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct SimplifiedEpisode {
pub audio_preview_url: Option<String>,
pub description: String,
pub duration_ms: u32,
pub explicit: bool,
pub href: String,
pub id: EpisodeId<'static>,
pub images: Vec<Image>,
pub is_externally_hosted: bool,
pub is_playable: bool,
#[deprecated(note = "This `language` field is deprecated and might be \
removed in the future by Spotify. Please use the languages field \
instead")]
pub language: String,
pub languages: Vec<String>,
pub name: String,
pub release_date: String,
pub release_date_precision: DatePrecision,
pub resume_point: Option<ResumePoint>,
}
/// Full episode object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct FullEpisode {
pub audio_preview_url: Option<String>,
pub description: String,
pub duration_ms: u32,
pub explicit: bool,
pub href: String,
pub id: EpisodeId<'static>,
pub images: Vec<Image>,
pub is_externally_hosted: bool,
pub is_playable: bool,
#[deprecated(note = "This `language` field is deprecated and might be \
removed in the future by Spotify. Please use the languages field \
instead")]
pub language: String,
pub languages: Vec<String>,
pub name: String,
pub release_date: String,
pub release_date_precision: DatePrecision,
pub resume_point: Option<ResumePoint>,
pub show: SimplifiedShow,
}
/// Intermediate episodes feature object wrapped by `Vec`
#[derive(Deserialize)]
pub struct EpisodesPayload {
pub episodes: Vec<FullEpisode>,
}
/// Resume point object
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct ResumePoint {
pub fully_played: bool,
pub resume_position_ms: u32,
}