# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ToolMobileCallExternalFunctionsParametersRequestsInner(BaseModel):
    """
    ToolMobileCallExternalFunctionsParametersRequestsInner
    """ # noqa: E501
    arguments: Optional[StrictStr] = Field(default='{}', description="JSON-encoded object with named arguments")
    function: Optional[StrictStr] = Field(description="Function name")
    settingfileurl: Optional[StrictBool] = Field(default=True, description="Rewrite plugin file URLs")
    settingfilter: Optional[StrictBool] = Field(default=False, description="Filter text")
    settinglang: Optional[StrictStr] = Field(default='', description="Session language")
    settingraw: Optional[StrictBool] = Field(default=False, description="Return raw text")
    __properties: ClassVar[List[str]] = ["arguments", "function", "settingfileurl", "settingfilter", "settinglang", "settingraw"]

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "arguments": obj.get("arguments") if obj.get("arguments") is not None else '{}',
            "function": obj.get("function"),
            "settingfileurl": obj.get("settingfileurl") if obj.get("settingfileurl") is not None else True,
            "settingfilter": obj.get("settingfilter") if obj.get("settingfilter") is not None else False,
            "settinglang": obj.get("settinglang") if obj.get("settinglang") is not None else '',
            "settingraw": obj.get("settingraw") if obj.get("settingraw") is not None else False
        })
        return _obj


