Skip to main content

entrenar/research/archive/
config.rs

1//! Archive provider configuration.
2
3use serde::{Deserialize, Serialize};
4
5/// Zenodo-specific configuration
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ZenodoConfig {
8    /// API access token
9    pub token: String,
10    /// Use sandbox environment
11    pub sandbox: bool,
12    /// Community to submit to (optional)
13    pub community: Option<String>,
14}
15
16impl ZenodoConfig {
17    /// Create a new Zenodo configuration
18    pub fn new(token: impl Into<String>) -> Self {
19        Self { token: token.into(), sandbox: false, community: None }
20    }
21
22    /// Use sandbox environment
23    pub fn with_sandbox(mut self, sandbox: bool) -> Self {
24        self.sandbox = sandbox;
25        self
26    }
27
28    /// Set community
29    pub fn with_community(mut self, community: impl Into<String>) -> Self {
30        self.community = Some(community.into());
31        self
32    }
33
34    /// Get the appropriate base URL
35    pub fn base_url(&self) -> &'static str {
36        if self.sandbox {
37            "https://sandbox.zenodo.org"
38        } else {
39            "https://zenodo.org"
40        }
41    }
42}
43
44/// Figshare-specific configuration
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct FigshareConfig {
47    /// API access token
48    pub token: String,
49    /// Project ID (optional)
50    pub project_id: Option<u64>,
51}
52
53impl FigshareConfig {
54    /// Create a new Figshare configuration
55    pub fn new(token: impl Into<String>) -> Self {
56        Self { token: token.into(), project_id: None }
57    }
58
59    /// Set project ID
60    pub fn with_project(mut self, project_id: u64) -> Self {
61        self.project_id = Some(project_id);
62        self
63    }
64}