use crate::api::prelude::*;
#[derive(Debug, Clone)]
pub struct GetChapter {
pub id: String,
pub market: Option<Market>,
}
impl<T: Into<String>> From<T> for GetChapter {
fn from(id: T) -> Self {
Self {
id: id.into(),
market: None,
}
}
}
impl Endpoint for GetChapter {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
format!("chapters/{}", 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_chapter_endpoint() {
let endpoint = ExpectedUrl::builder()
.endpoint("chapters/0D5wENdkdwbqlrHoaJ9g29")
.build();
let client = SingleTestClient::new_raw(endpoint, "");
let endpoint = GetChapter::from("0D5wENdkdwbqlrHoaJ9g29");
api::ignore(endpoint).query(&client).unwrap();
}
}