1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::model::*;
macro_rules! inherit_user_simplified {
($(#[$attr:meta])* $name:ident { $($(#[$f_attr:meta])* $f_name:ident : $f_ty:ty,)* }) => {
to_struct!($(#[$attr])* $name {
$(
$(#[$f_attr])*
$f_name: $f_ty,
)*
/// The name of the user; can be not available.
display_name: Option<String>,
/// Known public external URLs for this user.
external_urls: HashMap<String, String>,
/// The [Spotify user
/// ID](https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids) for the
/// user.
id: String,
});
}
}
macro_rules! inherit_user_public {
($(#[$attr:meta])* $name:ident { $($(#[$f_attr:meta])* $f_name:ident : $f_ty:ty,)* }) => {
inherit_user_simplified!($(#[$attr])* $name {
$(
$(#[$f_attr])*
$f_name: $f_ty,
)*
/// Information about the followers of the user.
followers: Followers,
/// The user's profile image.
images: Vec<Image>,
});
}
}
inherit_user_simplified!(
/// A user object that contains less fields than UserPubic and is not documented anywhere, but
/// is returned by some endpoints.
UserSimplified {}
);
inherit_user_public!(
/// A user object that is accessible to everyone.
UserPublic {}
);
inherit_user_public!(
/// A user object only accessible to the user themselves; does not work with Client Credentials
/// flow.
UserPrivate {
/// The country of the user, as set in their account profile. Requires `user-read-private`.
country: Option<CountryCode>,
/// The user's email address, which is not necessarily a real email address. Requires
/// `user-read-email`.
email: Option<String>,
/// The user's Spotify subscription level. Requires `user-read-private`.
product: Option<Subscription>,
}
);
/// The subscription level; premium or free.
#[derive(Debug, Clone, PartialEq, Eq, Copy, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Subscription {
Premium,
#[serde(alias = "open")]
Free,
}