use std::fmt::Display; use log::debug; use serde::{Deserialize, Serialize}; #[derive(Debug)] pub struct URI { protocol: String, base_url: String, } impl URI { pub fn new_protocol(base_url: impl Into, protocol: impl Into) -> Self { Self { protocol: protocol.into(), base_url: base_url.into(), } } pub fn new(base_url: impl Into) -> Self { Self::new_protocol(base_url, "https") } pub fn get_endpoint(&self, endpoint: impl Display) -> String { let uri = format!("{}://{}/api/v2/{}", self.protocol, self.base_url, endpoint); debug!("uri: {:?}", uri); uri } } #[derive(Serialize)] #[allow(non_snake_case)] pub struct NewShareRequest { name: Option, validity: u32, description: String, maxViews: u32, password: Option, } impl NewShareRequest { pub fn new( name: Option>, description: impl Into, max_views: u32, ) -> Self { Self { name: name.map(Into::into), validity: 0, description: description.into(), maxViews: max_views, password: None, } } } #[derive(Deserialize, Debug)] pub struct NewShareResponse { pub success: bool, pub message: String, pub id: String, } #[derive(Deserialize, Debug)] #[allow(dead_code)] pub struct NotifyShareResponse { pub success: bool, pub message: String, }