use crate::adapters::yahoo::client::YahooClient;
use crate::adapters::yahoo::endpoints::api;
use crate::error::Result;
use crate::models::quote::QuoteSummaryResponse;
use tracing::info;
pub(crate) async fn fetch_summary(
client: &YahooClient,
symbol: &str,
) -> Result<QuoteSummaryResponse> {
info!("Fetching quote summary for: {}", symbol);
let base_url = api::quote_summary(symbol);
let modules = crate::models::quote::Module::all()
.iter()
.map(|m| m.as_str())
.collect::<Vec<_>>()
.join(",");
let url = format!("{base_url}?modules={modules}");
let resp = client.request_with_crumb(&url).await?;
let json: serde_json::Value = resp.json().await?;
QuoteSummaryResponse::from_json(json, symbol)
}