create folder method

This commit is contained in:
grimhilt
2023-06-08 18:34:51 +02:00
parent 1b63c86c1a
commit 26153219b2
3 changed files with 41 additions and 4 deletions

View File

@@ -0,0 +1,28 @@
use crate::services::api::{ApiBuilder, ApiError};
use reqwest::{Method, IntoUrl, Response, Error};
pub struct CreateFolder {
api_builder: ApiBuilder,
}
impl CreateFolder {
pub fn new<U: IntoUrl>(url: U) -> Self {
ListFolders {
api_builder: ApiBuilder::new()
.set_request(Method::from_bytes(b"MKCOL").unwrap(), url),
}
}
pub async fn send(&mut self) -> Result<Response, Error> {
self.api_builder.send().await
}
pub async fn send_with_err(mut self) -> Result<(), ApiError> {
let res = self.send().await.map_err(ApiError::RequestError)?;
if res.status().is_success() {
Ok()
} else {
Err(ApiError::IncorrectRequest(res))
}
}
}