# coding: utf-8

"""
    Intervals.icu API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from intervals_icu_client.models.wind_rose import WindRose
from typing import Optional, Set
from typing_extensions import Self

class ActivityWeatherSummary(BaseModel):
    """
    ActivityWeatherSummary
    """ # noqa: E501
    start_index: Optional[StrictInt] = None
    end_index: Optional[StrictInt] = None
    start_secs: Optional[StrictInt] = None
    end_secs: Optional[StrictInt] = None
    moving_time: Optional[StrictInt] = None
    whole_activity: Optional[StrictBool] = None
    wind_speed: Optional[WindRose] = None
    wind_gust: Optional[WindRose] = None
    apparent_wind_speed: Optional[WindRose] = None
    apparent_wind_gust: Optional[WindRose] = None
    average_temp: Optional[Union[StrictFloat, StrictInt]] = None
    min_temp: Optional[StrictInt] = None
    max_temp: Optional[StrictInt] = None
    average_weather_temp: Optional[Union[StrictFloat, StrictInt]] = None
    min_weather_temp: Optional[Union[StrictFloat, StrictInt]] = None
    max_weather_temp: Optional[Union[StrictFloat, StrictInt]] = None
    average_feels_like: Optional[Union[StrictFloat, StrictInt]] = None
    min_feels_like: Optional[Union[StrictFloat, StrictInt]] = None
    max_feels_like: Optional[Union[StrictFloat, StrictInt]] = None
    average_wind_speed: Optional[Union[StrictFloat, StrictInt]] = None
    min_wind_speed: Optional[Union[StrictFloat, StrictInt]] = None
    max_wind_speed: Optional[Union[StrictFloat, StrictInt]] = None
    average_wind_gust: Optional[Union[StrictFloat, StrictInt]] = None
    min_wind_gust: Optional[Union[StrictFloat, StrictInt]] = None
    max_wind_gust: Optional[Union[StrictFloat, StrictInt]] = None
    prevailing_wind_deg: Optional[StrictInt] = None
    average_yaw: Optional[Union[StrictFloat, StrictInt]] = None
    headwind_percent: Optional[Union[StrictFloat, StrictInt]] = None
    tailwind_percent: Optional[Union[StrictFloat, StrictInt]] = None
    max_rain: Optional[Union[StrictFloat, StrictInt]] = None
    max_showers: Optional[Union[StrictFloat, StrictInt]] = None
    max_snow: Optional[Union[StrictFloat, StrictInt]] = None
    average_clouds: Optional[StrictInt] = None
    description: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["start_index", "end_index", "start_secs", "end_secs", "moving_time", "whole_activity", "wind_speed", "wind_gust", "apparent_wind_speed", "apparent_wind_gust", "average_temp", "min_temp", "max_temp", "average_weather_temp", "min_weather_temp", "max_weather_temp", "average_feels_like", "min_feels_like", "max_feels_like", "average_wind_speed", "min_wind_speed", "max_wind_speed", "average_wind_gust", "min_wind_gust", "max_wind_gust", "prevailing_wind_deg", "average_yaw", "headwind_percent", "tailwind_percent", "max_rain", "max_showers", "max_snow", "average_clouds", "description"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of ActivityWeatherSummary from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of wind_speed
        if self.wind_speed:
            _dict['wind_speed'] = self.wind_speed.to_dict()
        # override the default output from pydantic by calling `to_dict()` of wind_gust
        if self.wind_gust:
            _dict['wind_gust'] = self.wind_gust.to_dict()
        # override the default output from pydantic by calling `to_dict()` of apparent_wind_speed
        if self.apparent_wind_speed:
            _dict['apparent_wind_speed'] = self.apparent_wind_speed.to_dict()
        # override the default output from pydantic by calling `to_dict()` of apparent_wind_gust
        if self.apparent_wind_gust:
            _dict['apparent_wind_gust'] = self.apparent_wind_gust.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ActivityWeatherSummary from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "start_index": obj.get("start_index"),
            "end_index": obj.get("end_index"),
            "start_secs": obj.get("start_secs"),
            "end_secs": obj.get("end_secs"),
            "moving_time": obj.get("moving_time"),
            "whole_activity": obj.get("whole_activity"),
            "wind_speed": WindRose.from_dict(obj["wind_speed"]) if obj.get("wind_speed") is not None else None,
            "wind_gust": WindRose.from_dict(obj["wind_gust"]) if obj.get("wind_gust") is not None else None,
            "apparent_wind_speed": WindRose.from_dict(obj["apparent_wind_speed"]) if obj.get("apparent_wind_speed") is not None else None,
            "apparent_wind_gust": WindRose.from_dict(obj["apparent_wind_gust"]) if obj.get("apparent_wind_gust") is not None else None,
            "average_temp": obj.get("average_temp"),
            "min_temp": obj.get("min_temp"),
            "max_temp": obj.get("max_temp"),
            "average_weather_temp": obj.get("average_weather_temp"),
            "min_weather_temp": obj.get("min_weather_temp"),
            "max_weather_temp": obj.get("max_weather_temp"),
            "average_feels_like": obj.get("average_feels_like"),
            "min_feels_like": obj.get("min_feels_like"),
            "max_feels_like": obj.get("max_feels_like"),
            "average_wind_speed": obj.get("average_wind_speed"),
            "min_wind_speed": obj.get("min_wind_speed"),
            "max_wind_speed": obj.get("max_wind_speed"),
            "average_wind_gust": obj.get("average_wind_gust"),
            "min_wind_gust": obj.get("min_wind_gust"),
            "max_wind_gust": obj.get("max_wind_gust"),
            "prevailing_wind_deg": obj.get("prevailing_wind_deg"),
            "average_yaw": obj.get("average_yaw"),
            "headwind_percent": obj.get("headwind_percent"),
            "tailwind_percent": obj.get("tailwind_percent"),
            "max_rain": obj.get("max_rain"),
            "max_showers": obj.get("max_showers"),
            "max_snow": obj.get("max_snow"),
            "average_clouds": obj.get("average_clouds"),
            "description": obj.get("description")
        })
        return _obj


