# 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 typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class BlockStarredcoursesGetStarredCoursesResponseInner(BaseModel):
    """
    BlockStarredcoursesGetStarredCoursesResponseInner
    """ # noqa: E501
    coursecategory: StrictStr = Field(description="coursecategory")
    courseimage: StrictStr = Field(description="courseimage")
    enddate: StrictInt = Field(description="enddate")
    fullname: StrictStr = Field(description="fullname")
    fullnamedisplay: StrictStr = Field(description="fullnamedisplay")
    hasprogress: StrictBool = Field(description="hasprogress")
    hidden: StrictBool = Field(description="hidden")
    id: StrictInt = Field(description="id")
    idnumber: StrictStr = Field(description="idnumber")
    isfavourite: StrictBool = Field(description="isfavourite")
    pdfexportfont: Optional[StrictStr] = Field(description="pdfexportfont")
    progress: Optional[StrictInt] = Field(default=0, description="progress")
    shortname: StrictStr = Field(description="shortname")
    showactivitydates: Optional[StrictBool] = Field(description="showactivitydates")
    showcompletionconditions: Optional[StrictBool] = Field(description="showcompletionconditions")
    showshortname: StrictBool = Field(description="showshortname")
    startdate: StrictInt = Field(description="startdate")
    summary: Optional[StrictStr] = Field(description="summary")
    summaryformat: Optional[StrictInt] = Field(default=0, description="summary format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    timeaccess: Optional[StrictInt] = Field(default=0, description="timeaccess")
    viewurl: StrictStr = Field(description="viewurl")
    visible: StrictBool = Field(description="visible")
    __properties: ClassVar[List[str]] = ["coursecategory", "courseimage", "enddate", "fullname", "fullnamedisplay", "hasprogress", "hidden", "id", "idnumber", "isfavourite", "pdfexportfont", "progress", "shortname", "showactivitydates", "showcompletionconditions", "showshortname", "startdate", "summary", "summaryformat", "timeaccess", "viewurl", "visible"]

    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 BlockStarredcoursesGetStarredCoursesResponseInner 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 pdfexportfont (nullable) is None
        # and model_fields_set contains the field
        if self.pdfexportfont is None and "pdfexportfont" in self.model_fields_set:
            _dict['pdfexportfont'] = None

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

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

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

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

        return _dict

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

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

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

        data = {
            "coursecategory": obj.get("coursecategory") if obj.get("coursecategory") is not None else '',
            "courseimage": obj.get("courseimage") if obj.get("courseimage") is not None else '',
            "enddate": obj.get("enddate") if obj.get("enddate") is not None else 0,
            "fullname": obj.get("fullname") if obj.get("fullname") is not None else '',
            "fullnamedisplay": obj.get("fullnamedisplay") if obj.get("fullnamedisplay") is not None else '',
            "hasprogress": obj.get("hasprogress") if obj.get("hasprogress") is not None else False,
            "hidden": obj.get("hidden") if obj.get("hidden") is not None else False,
            "id": obj.get("id") if obj.get("id") is not None else 0,
            "idnumber": obj.get("idnumber") if obj.get("idnumber") is not None else '',
            "isfavourite": obj.get("isfavourite") if obj.get("isfavourite") is not None else False,
            "pdfexportfont": obj.get("pdfexportfont"),
            "progress": obj.get("progress") if obj.get("progress") is not None else 0,
            "shortname": obj.get("shortname") if obj.get("shortname") is not None else '',
            "showactivitydates": obj.get("showactivitydates"),
            "showcompletionconditions": obj.get("showcompletionconditions"),
            "showshortname": obj.get("showshortname") if obj.get("showshortname") is not None else False,
            "startdate": obj.get("startdate") if obj.get("startdate") is not None else 0,
            "summary": obj.get("summary"),
            "summaryformat": obj.get("summaryformat") if obj.get("summaryformat") is not None else 0,
            "timeaccess": obj.get("timeaccess") if obj.get("timeaccess") is not None else 0,
            "viewurl": obj.get("viewurl") if obj.get("viewurl") is not None else '',
            "visible": obj.get("visible") if obj.get("visible") is not None else False
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


