# coding: utf-8

"""
    api

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

    The version of the OpenAPI document: 0.1.1
    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 datetime import date
from pydantic import BaseModel, Field, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class StatsByTimeHistoryPoint(BaseModel):
    """
    StatsByTimeHistoryPoint
    """ # noqa: E501
    var_date: Optional[date] = Field(default=None, alias="date")
    win_rate: Optional[Union[StrictFloat, StrictInt]] = None
    win_rate_by_match_length: Dict[str, Optional[Union[StrictFloat, StrictInt]]]
    pick_rate: Optional[Union[StrictFloat, StrictInt]] = None
    players_count: Optional[StrictInt] = None
    matches_count: Optional[StrictInt] = None
    wins_count: Optional[StrictInt] = None
    losses_count: Optional[StrictInt] = None
    matches_count_with_mirror: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["date", "win_rate", "win_rate_by_match_length", "pick_rate", "players_count", "matches_count", "wins_count", "losses_count", "matches_count_with_mirror"]

    model_config = {
        "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 StatsByTimeHistoryPoint 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,
        )
        # set to None if var_date (nullable) is None
        # and model_fields_set contains the field
        if self.var_date is None and "var_date" in self.model_fields_set:
            _dict['date'] = None

        # set to None if win_rate (nullable) is None
        # and model_fields_set contains the field
        if self.win_rate is None and "win_rate" in self.model_fields_set:
            _dict['win_rate'] = None

        # set to None if pick_rate (nullable) is None
        # and model_fields_set contains the field
        if self.pick_rate is None and "pick_rate" in self.model_fields_set:
            _dict['pick_rate'] = None

        # set to None if players_count (nullable) is None
        # and model_fields_set contains the field
        if self.players_count is None and "players_count" in self.model_fields_set:
            _dict['players_count'] = None

        # set to None if matches_count (nullable) is None
        # and model_fields_set contains the field
        if self.matches_count is None and "matches_count" in self.model_fields_set:
            _dict['matches_count'] = None

        # set to None if wins_count (nullable) is None
        # and model_fields_set contains the field
        if self.wins_count is None and "wins_count" in self.model_fields_set:
            _dict['wins_count'] = None

        # set to None if losses_count (nullable) is None
        # and model_fields_set contains the field
        if self.losses_count is None and "losses_count" in self.model_fields_set:
            _dict['losses_count'] = None

        # set to None if matches_count_with_mirror (nullable) is None
        # and model_fields_set contains the field
        if self.matches_count_with_mirror is None and "matches_count_with_mirror" in self.model_fields_set:
            _dict['matches_count_with_mirror'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "date": obj.get("date"),
            "win_rate": obj.get("win_rate"),
            "win_rate_by_match_length": obj.get("win_rate_by_match_length"),
            "pick_rate": obj.get("pick_rate"),
            "players_count": obj.get("players_count"),
            "matches_count": obj.get("matches_count"),
            "wins_count": obj.get("wins_count"),
            "losses_count": obj.get("losses_count"),
            "matches_count_with_mirror": obj.get("matches_count_with_mirror")
        })
        return _obj


