# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ....core.request_options import RequestOptions
from ....types.daily_weather_response import DailyWeatherResponse
from ....types.hourly_weather_response import HourlyWeatherResponse
from ....types.timezone import Timezone
from ....types.units import Units
from .raw_client import AsyncRawForecastClient, RawForecastClient


class ForecastClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawForecastClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawForecastClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawForecastClient
        """
        return self._raw_client

    def daily(
        self,
        *,
        latitude: float,
        longitude: float,
        time: dt.datetime,
        timezone: typing.Optional[Timezone] = None,
        units: typing.Optional[Units] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DailyWeatherResponse:
        """
        Get daily weather forecast for a specific location and time

        Parameters
        ----------
        latitude : float

        longitude : float

        time : dt.datetime

        timezone : typing.Optional[Timezone]

        units : typing.Optional[Units]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DailyWeatherResponse
            Successful Response

        Examples
        --------
        from silurian import Earth
        import datetime
        client = Earth(api_key="YOUR_API_KEY", )
        client.weather.past.forecast.daily(latitude=47.6061, longitude=-122.3328, time=datetime.datetime.fromisoformat("2024-01-01 00:00:00+00:00", ), )
        """
        _response = self._raw_client.daily(
            latitude=latitude,
            longitude=longitude,
            time=time,
            timezone=timezone,
            units=units,
            request_options=request_options,
        )
        return _response.data

    def hourly(
        self,
        *,
        latitude: float,
        longitude: float,
        time: dt.datetime,
        timezone: typing.Optional[Timezone] = None,
        units: typing.Optional[Units] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HourlyWeatherResponse:
        """
        Get hourly weather forecast for a specific location and time

        Parameters
        ----------
        latitude : float

        longitude : float

        time : dt.datetime

        timezone : typing.Optional[Timezone]

        units : typing.Optional[Units]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HourlyWeatherResponse
            Successful Response

        Examples
        --------
        from silurian import Earth
        import datetime
        client = Earth(api_key="YOUR_API_KEY", )
        client.weather.past.forecast.hourly(latitude=47.6061, longitude=-122.3328, time=datetime.datetime.fromisoformat("2024-01-01 00:00:00+00:00", ), )
        """
        _response = self._raw_client.hourly(
            latitude=latitude,
            longitude=longitude,
            time=time,
            timezone=timezone,
            units=units,
            request_options=request_options,
        )
        return _response.data


class AsyncForecastClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawForecastClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawForecastClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawForecastClient
        """
        return self._raw_client

    async def daily(
        self,
        *,
        latitude: float,
        longitude: float,
        time: dt.datetime,
        timezone: typing.Optional[Timezone] = None,
        units: typing.Optional[Units] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DailyWeatherResponse:
        """
        Get daily weather forecast for a specific location and time

        Parameters
        ----------
        latitude : float

        longitude : float

        time : dt.datetime

        timezone : typing.Optional[Timezone]

        units : typing.Optional[Units]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DailyWeatherResponse
            Successful Response

        Examples
        --------
        from silurian import AsyncEarth
        import datetime
        import asyncio
        client = AsyncEarth(api_key="YOUR_API_KEY", )
        async def main() -> None:
            await client.weather.past.forecast.daily(latitude=47.6061, longitude=-122.3328, time=datetime.datetime.fromisoformat("2024-01-01 00:00:00+00:00", ), )
        asyncio.run(main())
        """
        _response = await self._raw_client.daily(
            latitude=latitude,
            longitude=longitude,
            time=time,
            timezone=timezone,
            units=units,
            request_options=request_options,
        )
        return _response.data

    async def hourly(
        self,
        *,
        latitude: float,
        longitude: float,
        time: dt.datetime,
        timezone: typing.Optional[Timezone] = None,
        units: typing.Optional[Units] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HourlyWeatherResponse:
        """
        Get hourly weather forecast for a specific location and time

        Parameters
        ----------
        latitude : float

        longitude : float

        time : dt.datetime

        timezone : typing.Optional[Timezone]

        units : typing.Optional[Units]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HourlyWeatherResponse
            Successful Response

        Examples
        --------
        from silurian import AsyncEarth
        import datetime
        import asyncio
        client = AsyncEarth(api_key="YOUR_API_KEY", )
        async def main() -> None:
            await client.weather.past.forecast.hourly(latitude=47.6061, longitude=-122.3328, time=datetime.datetime.fromisoformat("2024-01-01 00:00:00+00:00", ), )
        asyncio.run(main())
        """
        _response = await self._raw_client.hourly(
            latitude=latitude,
            longitude=longitude,
            time=time,
            timezone=timezone,
            units=units,
            request_options=request_options,
        )
        return _response.data
