use crate::adapters::yahoo::client::YahooClient;
use crate::constants::{Frequency, StatementType};
use crate::error::Result;
use crate::models::fundamentals::FinancialStatement;
pub async fn fetch(
client: &YahooClient,
symbol: &str,
statement_type: StatementType,
frequency: Frequency,
) -> Result<FinancialStatement> {
client
.get_financials(symbol, statement_type, frequency)
.await
}
#[cfg(test)]
mod tests {
use super::*;
use crate::adapters::yahoo::client::ClientConfig;
#[tokio::test]
#[ignore] async fn test_fetch_financials() {
let client = YahooClient::new(ClientConfig::default()).await.unwrap();
let result = fetch(&client, "AAPL", StatementType::Income, Frequency::Annual).await;
assert!(result.is_ok());
let statement = result.unwrap();
assert_eq!(statement.symbol, "AAPL");
assert!(statement.statement.contains_key("TotalRevenue"));
}
}