use url::Url;
use crate::{
batches::Batch,
errors::OapiError,
rest::get::{Get, GetNoStream},
};
#[derive(Debug, Clone)]
pub struct RetrieveBatchRequest<'a> {
pub batch_id: &'a str,
}
impl Get for RetrieveBatchRequest<'_> {
fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
url.path_segments_mut()
.map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
.push("batches")
.push(self.batch_id);
Ok(url.to_string())
}
}
impl GetNoStream for RetrieveBatchRequest<'_> {
type Response = Batch;
}