use crate::data::{CompanyOverview, GlobalQuote};
use super::traits::{FundamentalsProvider, QuoteProvider};
use std::io::Error;
pub use alpha_vantage::AlphaVantageSource;
pub enum DataProvider {
AlphaVantage(AlphaVantageSource),
}
mod alpha_vantage;
impl DataProvider {
pub fn alpha_vantage(user_key: &str) -> Self {
Self::AlphaVantage(AlphaVantageSource::new(user_key))
}
pub async fn get_stock_quote(&self, symbol: &str) -> Result<GlobalQuote, Error> {
match self {
DataProvider::AlphaVantage(source) => source.get_stock_quote(symbol).await,
}
}
pub async fn get_company_overview(&self, symbol: &str) -> Result<CompanyOverview, Error> {
match self {
DataProvider::AlphaVantage(source) => source.get_company_overview(symbol).await,
}
}
}