use serde::{Deserialize, Serialize}; pub struct URI { protocol: String, base_url: String, } impl URI { pub fn with_protocol(protocol: impl Into, base_url: impl Into) -> Self { Self { protocol: protocol.into(), base_url: base_url.into(), } } } impl From<&str> for URI { fn from(value: &str) -> Self { Self::with_protocol("https", value) } } impl Into for URI { fn into(self) -> String { format!("{}://{}/api/v2", self.protocol, self.base_url) } } #[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(super) struct NewShareResponse { pub success: bool, pub message: String, pub id: String, } #[derive(Deserialize, Debug)] #[allow(dead_code)] pub(super) struct NotifyShareResponse { pub success: bool, pub message: String, }