# coding: utf-8

"""
    Moodle Webservice API

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

    The version of the OpenAPI document: 4.5 (Build: 20241007)
    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 typing import Optional, Set
from typing_extensions import Self

class CoreCourseRemoveContentItemFromUserFavouritesResponse(BaseModel):
    """
    CoreCourseRemoveContentItemFromUserFavouritesResponse
    """ # noqa: E501
    archetype: StrictStr = Field(description="The archetype of the module exposing the content item")
    branded: StrictBool = Field(description=" Whether this content item is branded or not")
    componentname: StrictStr = Field(description="The name of the component exposing the content item")
    favourite: StrictBool = Field(description="Has the user favourited the content item")
    help: StrictStr = Field(description="Html description / help for the content item")
    icon: StrictStr = Field(description="Html containing the icon for the content item")
    id: StrictInt = Field(description="The id of the content item")
    legacyitem: StrictBool = Field(description="If this item was pulled from the old callback and has no item id.")
    link: StrictStr = Field(description="The link to the content item creation page")
    name: StrictStr = Field(description="Name of the content item")
    purpose: StrictStr = Field(description="The purpose of the component exposing the content item")
    recommended: StrictBool = Field(description="Has this item been recommended")
    title: StrictStr = Field(description="The string title of the content item, human readable")
    __properties: ClassVar[List[str]] = ["archetype", "branded", "componentname", "favourite", "help", "icon", "id", "legacyitem", "link", "name", "purpose", "recommended", "title"]

    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 CoreCourseRemoveContentItemFromUserFavouritesResponse 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "archetype": obj.get("archetype") if obj.get("archetype") is not None else '',
            "branded": obj.get("branded") if obj.get("branded") is not None else False,
            "componentname": obj.get("componentname") if obj.get("componentname") is not None else '',
            "favourite": obj.get("favourite") if obj.get("favourite") is not None else False,
            "help": obj.get("help") if obj.get("help") is not None else '',
            "icon": obj.get("icon") if obj.get("icon") is not None else '',
            "id": obj.get("id") if obj.get("id") is not None else 0,
            "legacyitem": obj.get("legacyitem") if obj.get("legacyitem") is not None else False,
            "link": obj.get("link") if obj.get("link") is not None else '',
            "name": obj.get("name") if obj.get("name") is not None else '',
            "purpose": obj.get("purpose") if obj.get("purpose") is not None else '',
            "recommended": obj.get("recommended") if obj.get("recommended") is not None else False,
            "title": obj.get("title") if obj.get("title") is not None else ''
        })
        return _obj


