# 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, 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 AuthEmailGetSignupSettingsResponseProfilefieldsInner(BaseModel):
    """
    AuthEmailGetSignupSettingsResponseProfilefieldsInner
    """ # noqa: E501
    categoryid: Optional[StrictInt] = Field(default=None, description="Profield field category id")
    categoryname: Optional[StrictStr] = Field(default=None, description="Profield field category name")
    datatype: Optional[StrictStr] = Field(default=None, description="Profield field datatype")
    defaultdata: Optional[StrictStr] = Field(default=None, description="Profield field default data")
    defaultdataformat: Optional[StrictInt] = Field(description="defaultdata format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    description: Optional[StrictStr] = Field(default=None, description="Profield field description")
    descriptionformat: Optional[StrictInt] = Field(description="description format (1 = HTML, 0 = MOODLE, 2 = PLAIN, or 4 = MARKDOWN)")
    forceunique: Optional[StrictInt] = Field(default=None, description="Profield field unique")
    id: Optional[StrictInt] = Field(default=None, description="Profile field id")
    locked: Optional[StrictInt] = Field(default=None, description="Profield field locked")
    name: Optional[StrictStr] = Field(default=None, description="Profield field name")
    param1: Optional[StrictStr] = Field(default=None, description="Profield field settings")
    param2: Optional[StrictStr] = Field(default=None, description="Profield field settings")
    param3: Optional[StrictStr] = Field(default=None, description="Profield field settings")
    param4: Optional[StrictStr] = Field(default=None, description="Profield field settings")
    param5: Optional[StrictStr] = Field(default=None, description="Profield field settings")
    required: Optional[StrictInt] = Field(default=None, description="Profield field required")
    shortname: Optional[StrictStr] = Field(default=None, description="Profile field shortname")
    signup: Optional[StrictInt] = Field(default=None, description="Profield field in signup form")
    sortorder: Optional[StrictInt] = Field(default=None, description="Profield field sort order")
    visible: Optional[StrictInt] = Field(default=None, description="Profield field visible")
    __properties: ClassVar[List[str]] = ["categoryid", "categoryname", "datatype", "defaultdata", "defaultdataformat", "description", "descriptionformat", "forceunique", "id", "locked", "name", "param1", "param2", "param3", "param4", "param5", "required", "shortname", "signup", "sortorder", "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 AuthEmailGetSignupSettingsResponseProfilefieldsInner 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 categoryid (nullable) is None
        # and model_fields_set contains the field
        if self.categoryid is None and "categoryid" in self.model_fields_set:
            _dict['categoryid'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

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

        data = {
            "categoryid": obj.get("categoryid"),
            "categoryname": obj.get("categoryname"),
            "datatype": obj.get("datatype"),
            "defaultdata": obj.get("defaultdata"),
            "defaultdataformat": obj.get("defaultdataformat"),
            "description": obj.get("description"),
            "descriptionformat": obj.get("descriptionformat"),
            "forceunique": obj.get("forceunique"),
            "id": obj.get("id"),
            "locked": obj.get("locked"),
            "name": obj.get("name"),
            "param1": obj.get("param1"),
            "param2": obj.get("param2"),
            "param3": obj.get("param3"),
            "param4": obj.get("param4"),
            "param5": obj.get("param5"),
            "required": obj.get("required"),
            "shortname": obj.get("shortname"),
            "signup": obj.get("signup"),
            "sortorder": obj.get("sortorder"),
            "visible": obj.get("visible")
        }
        _obj = cls.model_construct(**data) if relaxed else cls.model_validate(data)
        return _obj


