# 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 ModDataGetFieldsResponseFieldsInner(BaseModel):
    """
    ModDataGetFieldsResponseFieldsInner
    """ # noqa: E501
    dataid: StrictInt = Field(description="The field type of the content.")
    description: StrictStr = Field(description="The field description.")
    id: StrictInt = Field(description="Field id.")
    name: StrictStr = Field(description="The field name.")
    param1: Optional[StrictStr] = Field(description="Field parameters")
    param10: Optional[StrictStr] = Field(description="Field parameters")
    param2: Optional[StrictStr] = Field(description="Field parameters")
    param3: Optional[StrictStr] = Field(description="Field parameters")
    param4: Optional[StrictStr] = Field(description="Field parameters")
    param5: Optional[StrictStr] = Field(description="Field parameters")
    param6: Optional[StrictStr] = Field(description="Field parameters")
    param7: Optional[StrictStr] = Field(description="Field parameters")
    param8: Optional[StrictStr] = Field(description="Field parameters")
    param9: Optional[StrictStr] = Field(description="Field parameters")
    required: StrictBool = Field(description="Whether is a field required or not.")
    type: StrictStr = Field(description="The field type.")
    __properties: ClassVar[List[str]] = ["dataid", "description", "id", "name", "param1", "param10", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9", "required", "type"]

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

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

        data = {
            "dataid": obj.get("dataid") if obj.get("dataid") is not None else 0,
            "description": obj.get("description") if obj.get("description") is not None else '',
            "id": obj.get("id") if obj.get("id") is not None else 0,
            "name": obj.get("name") if obj.get("name") is not None else '',
            "param1": obj.get("param1"),
            "param10": obj.get("param10"),
            "param2": obj.get("param2"),
            "param3": obj.get("param3"),
            "param4": obj.get("param4"),
            "param5": obj.get("param5"),
            "param6": obj.get("param6"),
            "param7": obj.get("param7"),
            "param8": obj.get("param8"),
            "param9": obj.get("param9"),
            "required": obj.get("required") if obj.get("required") is not None else False,
            "type": obj.get("type") if obj.get("type") is not None else ''
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


