use crate::types::FormatType;
use serde::Serialize;
#[derive(Debug, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct WebdownloadRequestLinkQuery {
#[cfg_attr(feature = "specta", specta(skip))]
pub(crate) token: String,
pub web_id: u32,
pub files_id: Option<Vec<u32>>,
pub zip_link: bool,
pub user_ip: Option<String>,
pub redirect: bool,
}
impl Default for WebdownloadRequestLinkQuery {
fn default() -> Self {
Self {
token: String::new(),
web_id: 0,
files_id: None,
zip_link: false,
user_ip: None,
redirect: false,
}
}
}
#[derive(Debug, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct WebdownloadControlQuery {
pub bypass_cache: bool,
}
impl Default for WebdownloadControlQuery {
fn default() -> Self {
Self {
bypass_cache: false,
}
}
}
#[derive(Debug, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct ListWebdownloadsQuery {
id: Option<u32>,
pub bypass_cache: Option<bool>,
pub offset: Option<u32>,
pub limit: Option<u32>,
}
impl Default for ListWebdownloadsQuery {
fn default() -> Self {
Self {
id: None,
bypass_cache: None,
offset: None,
limit: None,
}
}
}
#[derive(Debug, Serialize)]
#[cfg_attr(feature = "specta", derive(specta::Type))]
pub struct WebdownloadCachedAvailabilityQuery {
#[serde(serialize_with = "serialize_comma_separated")]
pub hash: Vec<String>,
pub format: FormatType,
}
fn serialize_comma_separated<S>(vec: &[String], serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&vec.join(","))
}
impl Default for WebdownloadCachedAvailabilityQuery {
fn default() -> Self {
Self {
hash: Vec::new(),
format: FormatType::List,
}
}
}