"""
Macro API namespace.

AUTO-GENERATED by scripts/generate_sdk.py - DO NOT EDIT MANUALLY!
Regenerate with: python scripts/generate_sdk.py --category macro
"""
from __future__ import annotations

from typing import Any, Dict, Optional

from ._base import AsyncBaseAPI, BaseAPI


class MacroAPI(BaseAPI):
    """Macro namespace: calendar, countries, history, indicators, latest, search."""

    def calendar(
        self,
        *,
        country: Optional[str] = None,
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Economic calendar

        Upcoming economic events.

        Args:
        country: Filter by country
        from_date: From date
        to_date: To date
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if country is not None:
            params["country"] = country
        if from_date is not None:
            params["from_date"] = from_date
        if to_date is not None:
            params["to_date"] = to_date
        if limit is not None:
            params["limit"] = limit
        return self._call("macro.calendar", params=params, options=options, context=context, response_format=response_format)

    def countries(
        self,
        *,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List countries

        List available countries."""
        params: Dict[str, Any] = {}
        return self._call("macro.countries", params=params, options=options, context=context, response_format=response_format)

    def history(
        self,
        *,
        identifier: str,
        start_date: Optional[str] = None,
        end_date: Optional[str] = None,
        limit: Optional[int] = 1000,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get indicator history

        Historical data for macro indicator.

        Args:
        identifier: TepiloraCode or ISIN
        start_date: Start date (YYYY-MM-DD)
        end_date: End date (YYYY-MM-DD)
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        params["identifier"] = identifier
        if start_date is not None:
            params["start_date"] = start_date
        if end_date is not None:
            params["end_date"] = end_date
        if limit is not None:
            params["limit"] = limit
        return self._call("macro.history", params=params, options=options, context=context, response_format=response_format)

    def indicators(
        self,
        *,
        country: Optional[str] = None,
        macro_area: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List indicators

        List available macro indicators.

        Args:
        country: Filter by country
        macro_area: Filter by area
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if country is not None:
            params["country"] = country
        if macro_area is not None:
            params["macro_area"] = macro_area
        if limit is not None:
            params["limit"] = limit
        return self._call("macro.indicators", params=params, options=options, context=context, response_format=response_format)

    def latest(
        self,
        *,
        identifier: Optional[str] = None,
        country: Optional[str] = None,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get latest values

        Most recent indicator values.

        Args:
        identifier: TepiloraCode or ISIN
        country: Filter by country
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if identifier is not None:
            params["identifier"] = identifier
        if country is not None:
            params["country"] = country
        if limit is not None:
            params["limit"] = limit
        return self._call("macro.latest", params=params, options=options, context=context, response_format=response_format)

    def search(
        self,
        *,
        query: str,
        country: Optional[str] = None,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Search indicators

        Search macro indicators by name.

        Args:
        query: Search query
        country: Filter by country
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        params["query"] = query
        if country is not None:
            params["country"] = country
        if limit is not None:
            params["limit"] = limit
        return self._call("macro.search", params=params, options=options, context=context, response_format=response_format)



class AsyncMacroAPI(AsyncBaseAPI):
    """Macro namespace: calendar, countries, history, indicators, latest, search."""

    async def calendar(
        self,
        *,
        country: Optional[str] = None,
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Economic calendar

        Upcoming economic events.

        Args:
        country: Filter by country
        from_date: From date
        to_date: To date
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if country is not None:
            params["country"] = country
        if from_date is not None:
            params["from_date"] = from_date
        if to_date is not None:
            params["to_date"] = to_date
        if limit is not None:
            params["limit"] = limit
        return await self._call("macro.calendar", params=params, options=options, context=context, response_format=response_format)

    async def countries(
        self,
        *,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List countries

        List available countries."""
        params: Dict[str, Any] = {}
        return await self._call("macro.countries", params=params, options=options, context=context, response_format=response_format)

    async def history(
        self,
        *,
        identifier: str,
        start_date: Optional[str] = None,
        end_date: Optional[str] = None,
        limit: Optional[int] = 1000,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get indicator history

        Historical data for macro indicator.

        Args:
        identifier: TepiloraCode or ISIN
        start_date: Start date (YYYY-MM-DD)
        end_date: End date (YYYY-MM-DD)
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        params["identifier"] = identifier
        if start_date is not None:
            params["start_date"] = start_date
        if end_date is not None:
            params["end_date"] = end_date
        if limit is not None:
            params["limit"] = limit
        return await self._call("macro.history", params=params, options=options, context=context, response_format=response_format)

    async def indicators(
        self,
        *,
        country: Optional[str] = None,
        macro_area: Optional[str] = None,
        limit: Optional[int] = 100,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """List indicators

        List available macro indicators.

        Args:
        country: Filter by country
        macro_area: Filter by area
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if country is not None:
            params["country"] = country
        if macro_area is not None:
            params["macro_area"] = macro_area
        if limit is not None:
            params["limit"] = limit
        return await self._call("macro.indicators", params=params, options=options, context=context, response_format=response_format)

    async def latest(
        self,
        *,
        identifier: Optional[str] = None,
        country: Optional[str] = None,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Get latest values

        Most recent indicator values.

        Args:
        identifier: TepiloraCode or ISIN
        country: Filter by country
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        if identifier is not None:
            params["identifier"] = identifier
        if country is not None:
            params["country"] = country
        if limit is not None:
            params["limit"] = limit
        return await self._call("macro.latest", params=params, options=options, context=context, response_format=response_format)

    async def search(
        self,
        *,
        query: str,
        country: Optional[str] = None,
        limit: Optional[int] = 50,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
        response_format: Optional[str] = None,
    ) -> Any:
        """Search indicators

        Search macro indicators by name.

        Args:
        query: Search query
        country: Filter by country
        limit: Maximum results"""
        params: Dict[str, Any] = {}
        params["query"] = query
        if country is not None:
            params["country"] = country
        if limit is not None:
            params["limit"] = limit
        return await self._call("macro.search", params=params, options=options, context=context, response_format=response_format)


