add service to delete a path
This commit is contained in:
parent
418ca68745
commit
b00266a93e
@ -3,3 +3,4 @@ pub mod list_folders;
|
||||
pub mod download_files;
|
||||
pub mod req_props;
|
||||
pub mod upload_file;
|
||||
pub mod delete_path;
|
||||
|
33
src/services/delete_path.rs
Normal file
33
src/services/delete_path.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use crate::services::api::{ApiBuilder, ApiError};
|
||||
use reqwest::{Method, Response, Error};
|
||||
|
||||
pub struct DeletePath {
|
||||
api_builder: ApiBuilder,
|
||||
}
|
||||
|
||||
impl DeletePath {
|
||||
pub fn new() -> Self {
|
||||
DeletePath {
|
||||
api_builder: ApiBuilder::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_url(&mut self, url: &str) -> &mut DeletePath {
|
||||
self.api_builder.build_request(Method::DELETE, url);
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn send(&mut self) -> Result<Response, Error> {
|
||||
self.api_builder.send().await
|
||||
}
|
||||
|
||||
pub async fn send_with_err(&mut self) -> Result<String, ApiError> {
|
||||
let res = self.send().await.map_err(ApiError::RequestError)?;
|
||||
if res.status().is_success() {
|
||||
let body = res.text().await.map_err(ApiError::EmptyError)?;
|
||||
Ok(body)
|
||||
} else {
|
||||
Err(ApiError::IncorrectRequest(res))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user