use url::Url;
use crate::{
errors::OapiError,
rest::delete::{Delete, DeleteNoStream},
};
#[derive(Debug, Clone)]
pub struct DeleteRequest<'a> {
pub response_id: &'a str,
}
impl Delete for DeleteRequest<'_> {
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("responses")
.push(self.response_id);
Ok(url.to_string())
}
}
impl DeleteNoStream for DeleteRequest<'_> {
type Response = ResponseDeleted;
}
#[derive(Debug, Clone, serde::Deserialize)]
pub struct ResponseDeleted {
pub id: String,
pub deleted: bool,
#[serde(default)]
pub object: Option<String>,
}
crate::impl_from_str!(ResponseDeleted);