use super::urls::builders;
use crate::client::YahooClient;
use crate::error::Result;
use crate::models::industries::IndustryData;
pub async fn fetch(client: &YahooClient, industry_key: &str) -> Result<IndustryData> {
let url = builders::industry(industry_key);
let response = client.request_with_crumb(&url).await?;
let json: serde_json::Value = response.json().await?;
parse_industry_response(&json)
}
fn parse_industry_response(json: &serde_json::Value) -> Result<IndustryData> {
IndustryData::from_response(json).map_err(|e| {
crate::error::FinanceError::ResponseStructureError {
field: "industry".to_string(),
context: e,
}
})
}