use super::urls::api;
use crate::client::YahooClient;
use crate::error::Result;
use tracing::info;
#[allow(dead_code)]
pub(crate) async fn fetch(client: &YahooClient, symbol: &str) -> Result<serde_json::Value> {
super::common::validate_symbol(symbol)?;
info!("Fetching quote type for: {}", symbol);
let url = api::quote_type(symbol);
let response = client.request_with_crumb(&url).await?;
Ok(response.json().await?)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::client::ClientConfig;
#[tokio::test]
#[ignore] async fn test_fetch_quote_type() {
let client = YahooClient::new(ClientConfig::default()).await.unwrap();
let result = fetch(&client, "AAPL").await;
assert!(result.is_ok());
let json = result.unwrap();
assert!(json.get("quoteType").is_some());
}
#[tokio::test]
#[ignore = "requires network access - validation tested in common::tests"]
async fn test_empty_symbol() {
let client = YahooClient::new(ClientConfig::default()).await.unwrap();
let result = fetch(&client, "").await;
assert!(result.is_err());
}
}