use crate::client::{MultipartRequestBuilder, RawRequestBuilder, RequestBuilder, Steel};
use crate::types::*;
pub struct Files<'a> {
client: &'a Steel,
}
impl<'a> Files<'a> {
pub fn new(client: &'a Steel) -> Self {
Self { client }
}
pub fn list(&self) -> RequestBuilder<'_, (), (), FileList> {
let path = "/v1/files".to_string();
self.client
.call(reqwest::Method::GET, path, None::<()>, None::<()>)
}
pub fn upload(
&self,
body: FileUploadParams,
) -> MultipartRequestBuilder<
'_,
impl Fn() -> Result<reqwest::multipart::Form, reqwest::Error>,
(),
File,
> {
let path = "/v1/files".to_string();
self.client
.multipart_call(reqwest::Method::POST, path, None::<()>, move || {
body.to_form()
})
}
pub fn download(&self, path: &str) -> RawRequestBuilder<'_, (), ()> {
let path = format!("/v1/files/{}", crate::client::encode_path(path));
self.client
.raw_call(reqwest::Method::GET, path, None::<()>, None::<()>)
}
pub fn delete(&self, path: &str) -> RequestBuilder<'_, (), (), serde_json::Value> {
let path = format!("/v1/files/{}", crate::client::encode_path(path));
self.client
.call(reqwest::Method::DELETE, path, None::<()>, None::<()>)
}
}