from __future__ import annotations
import datetime
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

@dataclass
class WithFormPatchResponse_weather_hourlyWeather(Parsable):
    # Date when weather was first fetched.
    created_at: Optional[datetime.datetime] = None
    # Date when weather was fetched from weather API.
    fetched_at: Optional[datetime.datetime] = None
    # Hour of the day for this forecast.
    hour: Optional[str] = None
    # A percentage value indicating the humidity.
    humidity: Optional[float] = None
    # Unique identifier.
    id: Optional[int] = None
    # Temperature during specified hour.
    temp: Optional[float] = None
    # When the weather was last updated.
    updated_at: Optional[datetime.datetime] = None
    # Direction of the wind, in degrees.
    wind_bearing: Optional[int] = None
    # Average wind speed.
    wind_speed: Optional[float] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithFormPatchResponse_weather_hourlyWeather:
        """
        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: WithFormPatchResponse_weather_hourlyWeather
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithFormPatchResponse_weather_hourlyWeather()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "createdAt": lambda n : setattr(self, 'created_at', n.get_datetime_value()),
            "fetchedAt": lambda n : setattr(self, 'fetched_at', n.get_datetime_value()),
            "hour": lambda n : setattr(self, 'hour', n.get_str_value()),
            "humidity": lambda n : setattr(self, 'humidity', n.get_float_value()),
            "id": lambda n : setattr(self, 'id', n.get_int_value()),
            "temp": lambda n : setattr(self, 'temp', n.get_float_value()),
            "updatedAt": lambda n : setattr(self, 'updated_at', n.get_datetime_value()),
            "windBearing": lambda n : setattr(self, 'wind_bearing', n.get_int_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_datetime_value("createdAt", self.created_at)
        writer.write_datetime_value("fetchedAt", self.fetched_at)
        writer.write_str_value("hour", self.hour)
        writer.write_float_value("humidity", self.humidity)
        writer.write_int_value("id", self.id)
        writer.write_float_value("temp", self.temp)
        writer.write_datetime_value("updatedAt", self.updated_at)
        writer.write_int_value("windBearing", self.wind_bearing)
        writer.write_float_value("windSpeed", self.wind_speed)
    

