79 lines
2.4 KiB
Rust
79 lines
2.4 KiB
Rust
//! All objects related to album defined by Spotify API
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use time::OffsetDateTime;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use crate::{
|
|
AlbumId, AlbumType, Copyright, DatePrecision, Image, Page, RestrictionReason, SimplifiedArtist,
|
|
SimplifiedTrack,
|
|
};
|
|
|
|
/// Simplified Album Object
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
|
|
pub struct SimplifiedAlbum {
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub album_group: Option<String>,
|
|
pub album_type: Option<AlbumType>,
|
|
pub artists: Vec<SimplifiedArtist>,
|
|
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
|
pub available_markets: Vec<String>,
|
|
pub href: Option<String>,
|
|
pub id: Option<AlbumId<'static>>,
|
|
pub images: Vec<Image>,
|
|
pub name: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub release_date: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub release_date_precision: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub restrictions: Option<Restriction>,
|
|
}
|
|
|
|
/// Full Album Object
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
pub struct FullAlbum {
|
|
pub artists: Vec<SimplifiedArtist>,
|
|
pub album_type: AlbumType,
|
|
pub available_markets: Option<Vec<String>>,
|
|
pub copyrights: Vec<Copyright>,
|
|
pub external_ids: HashMap<String, String>,
|
|
pub genres: Vec<String>,
|
|
pub href: String,
|
|
pub id: AlbumId<'static>,
|
|
pub images: Vec<Image>,
|
|
pub name: String,
|
|
pub popularity: u32,
|
|
pub release_date: String,
|
|
pub release_date_precision: DatePrecision,
|
|
pub tracks: Page<SimplifiedTrack>,
|
|
/// Not documented in official Spotify docs, however most albums do contain this field
|
|
pub label: Option<String>,
|
|
}
|
|
|
|
/// Intermediate full Albums wrapped by Vec object
|
|
#[derive(Deserialize)]
|
|
pub struct FullAlbums {
|
|
pub albums: Vec<FullAlbum>,
|
|
}
|
|
|
|
/// Intermediate simplified Albums wrapped by Page object
|
|
#[derive(Deserialize)]
|
|
pub struct PageSimplifiedAlbums {
|
|
pub albums: Page<SimplifiedAlbum>,
|
|
}
|
|
|
|
/// Saved Album object
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
pub struct SavedAlbum {
|
|
#[serde(with = "time::serde::iso8601")]
|
|
pub added_at: OffsetDateTime,
|
|
pub album: FullAlbum,
|
|
}
|
|
|
|
/// Album restriction object
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
pub struct Restriction {
|
|
pub reason: RestrictionReason,
|
|
}
|