use crate::api::prelude::*;
#[derive(Debug, Clone)]
pub struct GetShowEpisodes {
pub id: String,
pub market: Option<Market>,
}
impl Pageable for GetShowEpisodes {}
impl<T: Into<String>> From<T> for GetShowEpisodes {
fn from(id: T) -> Self {
Self {
id: id.into(),
market: None,
}
}
}
impl Endpoint for GetShowEpisodes {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
format!("shows/{}/episodes", self.id).into()
}
fn parameters(&self) -> QueryParams<'_> {
let mut params = QueryParams::default();
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},
};
#[test]
fn test_get_show_episodes_endpoint() {
let endpoint = ExpectedUrl::builder()
.endpoint("shows/38bS44xjbVVZ3No3ByF1dJ/episodes")
.build();
let client = SingleTestClient::new_raw(endpoint, "");
let endpoint = GetShowEpisodes::from("38bS44xjbVVZ3No3ByF1dJ");
api::ignore(endpoint).query(&client).unwrap();
}
}