//! Shared params for equity price endpoints (used by both FMP and Polygon).
//!
//! Mirrors the server's `src/routes/equity.rs`, whose `HistoricalQuery` /
//! `SymbolQuery` are reused across equity providers.

use serde::Serialize;

/// `?symbol=AAPL` — used by quote and profile.
#[derive(Debug, Clone, Serialize)]
pub struct SymbolParams {
    pub symbol: String,
}

impl SymbolParams {
    pub fn new(symbol: impl Into<String>) -> Self {
        Self { symbol: symbol.into() }
    }
}

/// `?symbol=&start=&end=&interval=&period=` for historical bars.
#[derive(Debug, Clone, Serialize, Default)]
pub struct HistoricalParams {
    pub symbol: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub period: Option<String>,
}

impl HistoricalParams {
    pub fn new(symbol: impl Into<String>) -> Self {
        Self { symbol: symbol.into(), ..Default::default() }
    }
    pub fn start(mut self, d: impl Into<String>) -> Self {
        self.start = Some(d.into());
        self
    }
    pub fn end(mut self, d: impl Into<String>) -> Self {
        self.end = Some(d.into());
        self
    }
    pub fn interval(mut self, i: impl Into<String>) -> Self {
        self.interval = Some(i.into());
        self
    }
    pub fn period(mut self, p: impl Into<String>) -> Self {
        self.period = Some(p.into());
        self
    }
}
