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
68
69
70
71
72
73
use crate::api::prelude::*;
/// Remove one or more shows from the Spotify user's library.
#[derive(Debug, Clone)]
pub struct RemoveUserSavedShows {
/// A list of [Spotify IDs](https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids) for the shows.
pub ids: Vec<String>,
/// An [ISO 3166-1 alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
/// If a country code is specified, only content that is available in that market will be returned.
/// If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter.
///
/// # Notes
/// If neither market or user country are provided, the content is considered unavailable for the client.
/// Users can view the country that is associated with their account in the [account settings](https://www.spotify.com/account/overview/).
pub market: Option<Market>,
}
impl<T, I> From<I> for RemoveUserSavedShows
where
I: IntoIterator<Item = T>,
T: Into<String>,
{
fn from(ids: I) -> Self {
Self {
ids: ids.into_iter().map(Into::into).collect(),
market: None,
}
}
}
impl Endpoint for RemoveUserSavedShows {
fn method(&self) -> Method {
Method::DELETE
}
fn endpoint(&self) -> Cow<'static, str> {
"me/shows".into()
}
fn parameters(&self) -> QueryParams<'_> {
let mut params = QueryParams::default();
params.push("ids", &self.ids.join(","));
params.push_opt("market", self.market.as_ref());
params
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{
api::{self, Query as _},
test::client::{ExpectedUrl, SingleTestClient},
};
use http::Method;
#[test]
fn test_remove_user_saved_shows_endpoint() {
let endpoint = ExpectedUrl::builder()
.method(Method::DELETE)
.endpoint("me/shows")
.add_query_params(&[("ids", "5CfCWKI5pZ28U0uOzXkDHe,5as3aKmN2k11yfDDDSrvaZ")])
.build();
let client = SingleTestClient::new_raw(endpoint, "");
let endpoint =
RemoveUserSavedShows::from(["5CfCWKI5pZ28U0uOzXkDHe", "5as3aKmN2k11yfDDDSrvaZ"]);
api::ignore(endpoint).query(&client).unwrap();
}
}