# coding: utf-8

"""
    Moodle Webservice API

    Auto-generated OpenAPI spec for Moodle's Webservice API.

    The version of the OpenAPI document: 5.0.3 (Build: 20251006)
    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, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from poodle_async_full.models.core_calendar_get_calendar_day_view_response_events_inner import CoreCalendarGetCalendarDayViewResponseEventsInner
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class CoreCalendarGetCalendarMonthlyViewResponseWeeksInnerDaysInner(BaseModel):
    """
    CoreCalendarGetCalendarMonthlyViewResponseWeeksInnerDaysInner
    """ # noqa: E501
    calendareventtypes: List[StrictStr] = Field(description="calendareventtypes")
    daytitle: StrictStr = Field(description="daytitle")
    events: List[CoreCalendarGetCalendarDayViewResponseEventsInner] = Field(description="events")
    hasevents: StrictBool = Field(description="hasevents")
    haslastdayofevent: StrictBool = Field(description="haslastdayofevent")
    hours: StrictInt = Field(description="hours")
    istoday: StrictBool = Field(description="istoday")
    isweekend: StrictBool = Field(description="isweekend")
    mday: StrictInt = Field(description="mday")
    minutes: StrictInt = Field(description="minutes")
    neweventtimestamp: StrictInt = Field(description="neweventtimestamp")
    nextperiod: StrictInt = Field(description="nextperiod")
    popovertitle: StrictStr = Field(description="popovertitle")
    previousperiod: StrictInt = Field(description="previousperiod")
    seconds: StrictInt = Field(description="seconds")
    timestamp: StrictInt = Field(description="timestamp")
    viewdaylink: Optional[StrictStr] = Field(default='', description="viewdaylink")
    viewdaylinktitle: Optional[StrictStr] = Field(default='', description="viewdaylinktitle")
    wday: StrictInt = Field(description="wday")
    yday: StrictInt = Field(description="yday")
    year: StrictInt = Field(description="year")
    __properties: ClassVar[List[str]] = ["calendareventtypes", "daytitle", "events", "hasevents", "haslastdayofevent", "hours", "istoday", "isweekend", "mday", "minutes", "neweventtimestamp", "nextperiod", "popovertitle", "previousperiod", "seconds", "timestamp", "viewdaylink", "viewdaylinktitle", "wday", "yday", "year"]

    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 CoreCalendarGetCalendarMonthlyViewResponseWeeksInnerDaysInner 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 each item in events (list)
        _items = []
        if self.events:
            for _item_events in self.events:
                if _item_events:
                    _items.append(_item_events.to_dict())
            _dict['events'] = _items
        return _dict

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

        relaxed = settings.relaxe_all_models or "CoreCalendarGetCalendarMonthlyViewResponseWeeksInnerDaysInner" in settings.relaxed_models

        if not isinstance(obj, dict):
            return cls.model_construct(**obj) if relaxed else cls.model_validate(obj)

        data = {
            "calendareventtypes": obj.get("calendareventtypes"),
            "daytitle": obj.get("daytitle") if obj.get("daytitle") is not None else '',
            "events": [CoreCalendarGetCalendarDayViewResponseEventsInner.from_dict(_item) for _item in obj["events"]] if obj.get("events") is not None else None,
            "hasevents": obj.get("hasevents") if obj.get("hasevents") is not None else False,
            "haslastdayofevent": obj.get("haslastdayofevent") if obj.get("haslastdayofevent") is not None else False,
            "hours": obj.get("hours") if obj.get("hours") is not None else 0,
            "istoday": obj.get("istoday") if obj.get("istoday") is not None else False,
            "isweekend": obj.get("isweekend") if obj.get("isweekend") is not None else False,
            "mday": obj.get("mday") if obj.get("mday") is not None else 0,
            "minutes": obj.get("minutes") if obj.get("minutes") is not None else 0,
            "neweventtimestamp": obj.get("neweventtimestamp") if obj.get("neweventtimestamp") is not None else 0,
            "nextperiod": obj.get("nextperiod") if obj.get("nextperiod") is not None else 0,
            "popovertitle": obj.get("popovertitle") if obj.get("popovertitle") is not None else '',
            "previousperiod": obj.get("previousperiod") if obj.get("previousperiod") is not None else 0,
            "seconds": obj.get("seconds") if obj.get("seconds") is not None else 0,
            "timestamp": obj.get("timestamp") if obj.get("timestamp") is not None else 0,
            "viewdaylink": obj.get("viewdaylink") if obj.get("viewdaylink") is not None else '',
            "viewdaylinktitle": obj.get("viewdaylinktitle") if obj.get("viewdaylinktitle") is not None else '',
            "wday": obj.get("wday") if obj.get("wday") is not None else 0,
            "yday": obj.get("yday") if obj.get("yday") is not None else 0,
            "year": obj.get("year") if obj.get("year") is not None else 0
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


