"""Company info Oracle service methods.""" from __future__ import annotations from libs.oracle_client.client import OracleClient from libs.oracle_client.models import CompanyInfo class CompanyService: def __init__(self, client: OracleClient) -> None: self._client = client async def get_company(self, symbol: str) -> CompanyInfo: """Fetch company info via GET /api/v1/company/{symbol}. The newer company endpoint returns the company payload directly. Older Oracle deployments may still only expose the `financial/data` wrapper shape, so accept either structure for compatibility. """ data = await self._client.get(f"/api/v1/company/{symbol}") company = data.get("company", data) return CompanyInfo( ticker=company.get("ticker", symbol), name=company.get("name"), cik=company.get("cik"), exchange=company.get("exchange"), sector=company.get("sector"), industry=company.get("industry"), country=company.get("country"), market_cap=company.get("market_cap"), )