shrupl/src/sharry/mod.rs

51 lines
964 B
Rust
Raw Normal View History

2025-05-22 17:34:44 +00:00
pub mod api;
use api::{NewShareRequest, NewShareResponse, SharryAPI};
use log::debug;
use ureq;
#[derive(Debug)]
pub struct Alias<'t> {
api: &'t SharryAPI,
id: String,
}
impl<'t> Alias<'t> {
pub fn new(api: &'t SharryAPI, id: &str) -> Self {
Self {
api: api,
id: id.into(),
}
}
pub fn create_share(
&self,
http: &ureq::Agent,
data: &NewShareRequest,
) -> Result<Share, ureq::Error> {
let foo = http
.post(self.api.get_uri("alias/upload/new"))
.header("Sharry-Alias", &self.id)
.send_json(data)?
.body_mut()
.read_json::<NewShareResponse>()?;
debug!("foo: {:?}", foo);
Ok(Share {
alias: self,
id: foo.id,
})
}
}
#[derive(Debug)]
pub struct Share<'t> {
alias: &'t Alias<'t>,
id: String,
}
impl<'t> Share<'t> {
pub fn add_file(&self) {}
}