use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ZenodoConfig {
pub token: String,
pub sandbox: bool,
pub community: Option<String>,
}
impl ZenodoConfig {
pub fn new(token: impl Into<String>) -> Self {
Self { token: token.into(), sandbox: false, community: None }
}
pub fn with_sandbox(mut self, sandbox: bool) -> Self {
self.sandbox = sandbox;
self
}
pub fn with_community(mut self, community: impl Into<String>) -> Self {
self.community = Some(community.into());
self
}
pub fn base_url(&self) -> &'static str {
if self.sandbox {
"https://sandbox.zenodo.org"
} else {
"https://zenodo.org"
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FigshareConfig {
pub token: String,
pub project_id: Option<u64>,
}
impl FigshareConfig {
pub fn new(token: impl Into<String>) -> Self {
Self { token: token.into(), project_id: None }
}
pub fn with_project(mut self, project_id: u64) -> Self {
self.project_id = Some(project_id);
self
}
}