from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
    from .forms_post_response_weather_hourly_weather import FormsPostResponse_weather_hourlyWeather
    from .forms_post_response_weather_provider import FormsPostResponse_weather_provider

@dataclass
class FormsPostResponse_weather(Parsable):
    # Weather information for specific hours (07:00:00, 12:00:00, 16:00:00).
    hourly_weather: Optional[list[FormsPostResponse_weather_hourlyWeather]] = None
    # A percentage value indicating the humidity over the course of the day.
    humidity: Optional[float] = None
    # Amount of precipitation accumulated throughout the day.
    precipitation_accumulation: Optional[float] = None
    # Indicates the measurement unit of the ``precipitationAccumulation``.
    precipitation_accumulation_unit: Optional[str] = None
    # Indicates the source of the weather data.Possible values: ``darksky``, ``weatherkit``
    provider: Optional[FormsPostResponse_weather_provider] = None
    # Indicates the measurement unit of the ``windSpeed`` and ``windGust``.
    speed_unit: Optional[str] = None
    # A code describing the the weather (e.g. Clear, PartlyCloudy).
    summary_key: Optional[str] = None
    # Maximum temperature during the day.
    temperature_max: Optional[float] = None
    # Minimum temperature during the day.
    temperature_min: Optional[float] = None
    # Indicates the measurement unit of the temperature values e.g. ``temperatureMin``, ``temperatureMax``, ``temp``.
    temperature_unit: Optional[str] = None
    # Direction of the wind, in degrees.
    wind_bearing: Optional[float] = None
    # Maximum wind speed observed throughout the day.
    wind_gust: Optional[float] = None
    # Average wind speed observed throughout the day.
    wind_speed: Optional[float] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> FormsPostResponse_weather:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: FormsPostResponse_weather
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return FormsPostResponse_weather()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .forms_post_response_weather_hourly_weather import FormsPostResponse_weather_hourlyWeather
        from .forms_post_response_weather_provider import FormsPostResponse_weather_provider

        from .forms_post_response_weather_hourly_weather import FormsPostResponse_weather_hourlyWeather
        from .forms_post_response_weather_provider import FormsPostResponse_weather_provider

        fields: dict[str, Callable[[Any], None]] = {
            "hourlyWeather": lambda n : setattr(self, 'hourly_weather', n.get_collection_of_object_values(FormsPostResponse_weather_hourlyWeather)),
            "humidity": lambda n : setattr(self, 'humidity', n.get_float_value()),
            "precipitationAccumulation": lambda n : setattr(self, 'precipitation_accumulation', n.get_float_value()),
            "precipitationAccumulationUnit": lambda n : setattr(self, 'precipitation_accumulation_unit', n.get_str_value()),
            "provider": lambda n : setattr(self, 'provider', n.get_enum_value(FormsPostResponse_weather_provider)),
            "speedUnit": lambda n : setattr(self, 'speed_unit', n.get_str_value()),
            "summaryKey": lambda n : setattr(self, 'summary_key', n.get_str_value()),
            "temperatureMax": lambda n : setattr(self, 'temperature_max', n.get_float_value()),
            "temperatureMin": lambda n : setattr(self, 'temperature_min', n.get_float_value()),
            "temperatureUnit": lambda n : setattr(self, 'temperature_unit', n.get_str_value()),
            "windBearing": lambda n : setattr(self, 'wind_bearing', n.get_float_value()),
            "windGust": lambda n : setattr(self, 'wind_gust', n.get_float_value()),
            "windSpeed": lambda n : setattr(self, 'wind_speed', n.get_float_value()),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_collection_of_object_values("hourlyWeather", self.hourly_weather)
        writer.write_float_value("humidity", self.humidity)
        writer.write_float_value("precipitationAccumulation", self.precipitation_accumulation)
        writer.write_str_value("precipitationAccumulationUnit", self.precipitation_accumulation_unit)
        writer.write_enum_value("provider", self.provider)
        writer.write_str_value("speedUnit", self.speed_unit)
        writer.write_str_value("summaryKey", self.summary_key)
        writer.write_float_value("temperatureMax", self.temperature_max)
        writer.write_float_value("temperatureMin", self.temperature_min)
        writer.write_str_value("temperatureUnit", self.temperature_unit)
        writer.write_float_value("windBearing", self.wind_bearing)
        writer.write_float_value("windGust", self.wind_gust)
        writer.write_float_value("windSpeed", self.wind_speed)
    

