2025-05-22 17:34:44 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
2025-05-26 23:56:31 +00:00
|
|
|
pub struct Uri {
|
2025-05-22 17:34:44 +00:00
|
|
|
protocol: String,
|
|
|
|
|
base_url: String,
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-26 23:56:31 +00:00
|
|
|
impl Uri {
|
2025-05-24 00:22:24 +00:00
|
|
|
pub fn with_protocol(protocol: impl Into<String>, base_url: impl Into<String>) -> Self {
|
2025-05-22 17:34:44 +00:00
|
|
|
Self {
|
2025-05-22 21:07:49 +00:00
|
|
|
protocol: protocol.into(),
|
2025-05-22 17:34:44 +00:00
|
|
|
base_url: base_url.into(),
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-24 00:22:24 +00:00
|
|
|
}
|
2025-05-22 17:34:44 +00:00
|
|
|
|
2025-05-26 23:56:31 +00:00
|
|
|
impl From<&str> for Uri {
|
2025-05-24 00:22:24 +00:00
|
|
|
fn from(value: &str) -> Self {
|
|
|
|
|
Self::with_protocol("https", value)
|
2025-05-22 21:07:49 +00:00
|
|
|
}
|
2025-05-24 00:22:24 +00:00
|
|
|
}
|
2025-05-22 21:07:49 +00:00
|
|
|
|
2025-05-26 23:56:31 +00:00
|
|
|
impl From<Uri> for String {
|
|
|
|
|
fn from(val: Uri) -> Self {
|
|
|
|
|
format!("{}://{}/api/v2", val.protocol, val.base_url)
|
2025-05-22 17:34:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
|
#[allow(non_snake_case)]
|
2025-05-23 01:11:11 +00:00
|
|
|
pub struct NewShareRequest {
|
2025-05-27 14:01:09 +00:00
|
|
|
name: String,
|
2025-05-22 17:34:44 +00:00
|
|
|
validity: u32,
|
2025-05-27 14:01:09 +00:00
|
|
|
description: Option<String>,
|
2025-05-22 17:34:44 +00:00
|
|
|
maxViews: u32,
|
2025-05-23 01:11:11 +00:00
|
|
|
password: Option<String>,
|
2025-05-22 17:34:44 +00:00
|
|
|
}
|
|
|
|
|
|
2025-05-23 01:11:11 +00:00
|
|
|
impl NewShareRequest {
|
|
|
|
|
pub fn new(
|
2025-05-27 14:01:09 +00:00
|
|
|
name: impl Into<String>,
|
|
|
|
|
description: Option<impl Into<String>>,
|
2025-05-23 01:11:11 +00:00
|
|
|
max_views: u32,
|
|
|
|
|
) -> Self {
|
2025-05-22 17:34:44 +00:00
|
|
|
Self {
|
2025-05-27 14:01:09 +00:00
|
|
|
name: name.into(),
|
2025-05-22 17:34:44 +00:00
|
|
|
validity: 0,
|
2025-05-27 14:01:09 +00:00
|
|
|
description: description.map(Into::into),
|
2025-05-22 17:34:44 +00:00
|
|
|
maxViews: max_views,
|
|
|
|
|
password: None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)]
|
2025-05-23 22:13:17 +00:00
|
|
|
pub(super) struct NewShareResponse {
|
2025-05-22 17:34:44 +00:00
|
|
|
pub success: bool,
|
|
|
|
|
pub message: String,
|
|
|
|
|
pub id: String,
|
|
|
|
|
}
|
2025-05-22 21:07:49 +00:00
|
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
|
|
|
#[allow(dead_code)]
|
2025-05-23 22:13:17 +00:00
|
|
|
pub(super) struct NotifyShareResponse {
|
2025-05-22 21:07:49 +00:00
|
|
|
pub success: bool,
|
|
|
|
|
pub message: String,
|
|
|
|
|
}
|