# 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
from poodle_async_full.models.block_starredcourses_get_starred_courses_response_inner import BlockStarredcoursesGetStarredCoursesResponseInner
from poodle_async_full.models.core_competency_list_competencies_in_template_response_inner import CoreCompetencyListCompetenciesInTemplateResponseInner
from poodle_async_full.models.core_competency_list_competency_frameworks_response_inner import CoreCompetencyListCompetencyFrameworksResponseInner
from poodle_async_full.models.report_competency_data_for_report_response_usercompetencies_inner_competency_comppath import ReportCompetencyDataForReportResponseUsercompetenciesInnerCompetencyComppath
from typing import Optional, Set
from typing_extensions import Self

from poodle_async_full.configuration import settings

class ToolLpDataForCompetencySummaryResponse(BaseModel):
    """
    ToolLpDataForCompetencySummaryResponse
    """ # noqa: E501
    competency: CoreCompetencyListCompetenciesInTemplateResponseInner
    comppath: ReportCompetencyDataForReportResponseUsercompetenciesInnerCompetencyComppath
    framework: CoreCompetencyListCompetencyFrameworksResponseInner
    hascourses: StrictBool = Field(description="hascourses")
    hasrelatedcompetencies: StrictBool = Field(description="hasrelatedcompetencies")
    linkedcourses: List[BlockStarredcoursesGetStarredCoursesResponseInner] = Field(description="linkedcourses")
    pluginbaseurl: StrictStr = Field(description="pluginbaseurl")
    relatedcompetencies: List[CoreCompetencyListCompetenciesInTemplateResponseInner] = Field(description="relatedcompetencies")
    scaleconfiguration: StrictStr = Field(description="scaleconfiguration")
    scaleid: StrictInt = Field(description="scaleid")
    taxonomyterm: StrictStr = Field(description="taxonomyterm")
    __properties: ClassVar[List[str]] = ["competency", "comppath", "framework", "hascourses", "hasrelatedcompetencies", "linkedcourses", "pluginbaseurl", "relatedcompetencies", "scaleconfiguration", "scaleid", "taxonomyterm"]

    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 ToolLpDataForCompetencySummaryResponse 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 competency
        if self.competency:
            _dict['competency'] = self.competency.to_dict()
        # override the default output from pydantic by calling `to_dict()` of comppath
        if self.comppath:
            _dict['comppath'] = self.comppath.to_dict()
        # override the default output from pydantic by calling `to_dict()` of framework
        if self.framework:
            _dict['framework'] = self.framework.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in linkedcourses (list)
        _items = []
        if self.linkedcourses:
            for _item_linkedcourses in self.linkedcourses:
                if _item_linkedcourses:
                    _items.append(_item_linkedcourses.to_dict())
            _dict['linkedcourses'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in relatedcompetencies (list)
        _items = []
        if self.relatedcompetencies:
            for _item_relatedcompetencies in self.relatedcompetencies:
                if _item_relatedcompetencies:
                    _items.append(_item_relatedcompetencies.to_dict())
            _dict['relatedcompetencies'] = _items
        return _dict

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

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

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

        data = {
            "competency": CoreCompetencyListCompetenciesInTemplateResponseInner.from_dict(obj["competency"]) if obj.get("competency") is not None else None,
            "comppath": ReportCompetencyDataForReportResponseUsercompetenciesInnerCompetencyComppath.from_dict(obj["comppath"]) if obj.get("comppath") is not None else None,
            "framework": CoreCompetencyListCompetencyFrameworksResponseInner.from_dict(obj["framework"]) if obj.get("framework") is not None else None,
            "hascourses": obj.get("hascourses") if obj.get("hascourses") is not None else False,
            "hasrelatedcompetencies": obj.get("hasrelatedcompetencies") if obj.get("hasrelatedcompetencies") is not None else False,
            "linkedcourses": [BlockStarredcoursesGetStarredCoursesResponseInner.from_dict(_item) for _item in obj["linkedcourses"]] if obj.get("linkedcourses") is not None else None,
            "pluginbaseurl": obj.get("pluginbaseurl") if obj.get("pluginbaseurl") is not None else '',
            "relatedcompetencies": [CoreCompetencyListCompetenciesInTemplateResponseInner.from_dict(_item) for _item in obj["relatedcompetencies"]] if obj.get("relatedcompetencies") is not None else None,
            "scaleconfiguration": obj.get("scaleconfiguration") if obj.get("scaleconfiguration") is not None else '',
            "scaleid": obj.get("scaleid") if obj.get("scaleid") is not None else 0,
            "taxonomyterm": obj.get("taxonomyterm") if obj.get("taxonomyterm") is not None else ''
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


