use crate::api::prelude::*;
#[derive(Debug, Clone)]
pub struct GetSeveralArtists {
pub ids: Vec<String>,
}
impl<T, I> From<I> for GetSeveralArtists
where
I: IntoIterator<Item = T>,
T: Into<String>,
{
fn from(ids: I) -> Self {
Self {
ids: ids.into_iter().map(Into::into).collect(),
}
}
}
impl Endpoint for GetSeveralArtists {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
"artists".into()
}
fn parameters(&self) -> QueryParams<'_> {
let mut params = QueryParams::default();
params.push("ids", &self.ids.join(","));
params
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{
api::{self, Query as _},
test::client::{ExpectedUrl, SingleTestClient},
};
#[test]
fn test_get_several_artists_endpoint() {
let endpoint = ExpectedUrl::builder()
.endpoint("artists")
.add_query_params(&[(
"ids",
"2CIMQHirSU0MQqyYHq0eOx,57dN52uHvrHOxijzpIgu3E,1vCWHaC5f2uS3yhpwWbIA6",
)])
.build();
let client = SingleTestClient::new_raw(endpoint, "");
let endpoint = GetSeveralArtists::from([
"2CIMQHirSU0MQqyYHq0eOx",
"57dN52uHvrHOxijzpIgu3E",
"1vCWHaC5f2uS3yhpwWbIA6",
]);
api::ignore(endpoint).query(&client).unwrap();
}
}