//! Normalized result and payload types returned by site providers.

use salvo::oapi::ToSchema;
use serde::{Deserialize, Serialize};

/// A normalized primary resource returned by a site provider.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ResourceCandidate {
    /// Provider name used by the hub and upper layers.
    pub provider: String,
    /// Display title of the candidate.
    pub title: String,
    pub detail_url: Option<String>,
    #[serde(default)]
    pub labels: Vec<String>,
    /// Provider-private payload for follow-up actions.
    pub payload: ResourcePayload,
}

/// Provider-private follow-up data attached to a resource candidate.
#[derive(Debug, Clone, Default, Serialize, Deserialize, ToSchema)]
pub struct ResourcePayload {
    pub resource_key: String,
    /// Direct torrent URL when already known.
    pub torrent_url: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ResolvedSiteDownload {
    /// Suggested torrent file name when known.
    pub file_name: Option<String>,
    pub download_url: String,
    /// Extra headers required to fetch the torrent URL.
    pub headers: Vec<(String, String)>,
}
