spotify_rs/model/
user.rs

1use serde::{Deserialize, Serialize};
2use spotify_rs_macros::docs;
3
4use super::*;
5
6/// Information about the current user, which can only be obtained when
7/// authorised by the user.
8#[derive(Clone, Debug, Deserialize, PartialEq)]
9#[docs(name = "user")]
10pub struct PrivateUser {
11    /// An [ISO 3661-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
12    /// code that represents the user's country, as set in the user's account.
13    ///
14    /// Note: this field is only available if the user is authorised with the
15    /// `user-read-private` scope.
16    pub country: String,
17    /// The name that is displayed on the user's profile.
18    pub display_name: Option<String>,
19    /// The user's email address.
20    ///
21    /// Note: this email address is *unverified*, meaning that there is no proof
22    /// that it actually belongs to the user; this field is only available if the
23    /// user is authorised with the `user-read-email` scope.
24    pub email: String,
25    /// The user's explicit content settings.
26    ///
27    /// Note: This field is only available if the user is authorised with the
28    /// `user-read-private` scope.
29    pub explicit_content: Option<ExplicitContent>,
30    pub external_urls: ExternalUrls,
31    /// The followers of a user.
32    pub followers: Followers,
33    pub href: String,
34    pub id: String,
35    pub images: Vec<Image>,
36    /// The user's Spotify subscription tier. The value `open` can be considered
37    /// the same as `free`.
38    ///
39    /// Note: This field is only available if the user is authorised with the
40    /// `user-read-private` scope.
41    pub product: Option<String>,
42    pub r#type: String,
43    pub uri: String,
44}
45
46/// A user.
47#[derive(Clone, Debug, Deserialize, PartialEq)]
48#[docs]
49pub struct User {
50    /// The name that is displayed on the user's profile.
51    pub display_name: Option<String>,
52    pub external_urls: ExternalUrls,
53    /// The followers of a user.
54    pub followers: Followers,
55    pub href: String,
56    pub id: String,
57    pub images: Vec<Image>,
58    pub r#type: String,
59    pub uri: String,
60}
61
62// Returned by the get/playlist/{id} endpoint; also called "PlaylistUserObject" in the schema
63// It is missing the followers and images field from the regular User struct.
64/// A user, returned usually as a playlist's owner.
65#[derive(Clone, Debug, Deserialize, PartialEq)]
66#[docs(name = "user")]
67pub struct ReferenceUser {
68    pub external_urls: ExternalUrls,
69    pub href: String,
70    pub id: String,
71    pub r#type: String,
72    pub uri: String,
73    /// The name that is displayed on the user's profile.
74    pub display_name: Option<String>,
75}
76
77/// A user's explicit content settings.
78#[derive(Clone, Debug, Deserialize, PartialEq)]
79pub struct ExplicitContent {
80    /// Whether or not explicit content should be played.
81    pub filter_enabled: bool,
82    /// Whether or not the explicit content setting is locked and
83    /// can't be modified by the user.
84    pub filter_locked: bool,
85}
86
87/// Over what timespan the top items are calculated.
88#[derive(Clone, Debug, Default, Serialize)]
89#[serde(rename_all = "snake_case")]
90pub enum TimeRange {
91    /// Calculated from the last ~1 year of data.
92    LongTerm,
93    /// Calculated from the last ~6 months of data.
94    #[default]
95    MediumTerm,
96    /// Calculated from the last ~4 weeks of data.
97    ShortTerm,
98}