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

class ModLtiGetToolProxyRegistrationRequestResponse(BaseModel):
    """
    ModLtiGetToolProxyRegistrationRequestResponse
    """ # noqa: E501
    launch_presentation_return_url: Optional[StrictStr] = Field(description="URL to redirect on registration completion")
    lti_message_type: Optional[StrictStr] = Field(description="LTI message type")
    lti_version: Optional[StrictStr] = Field(description="LTI version")
    reg_key: Optional[StrictStr] = Field(description="Tool proxy registration key")
    reg_password: Optional[StrictStr] = Field(description="Tool proxy registration password")
    reg_url: Optional[StrictStr] = Field(description="Tool proxy registration url")
    tc_profile_url: Optional[StrictStr] = Field(description="Tool consumers profile URL")
    __properties: ClassVar[List[str]] = ["launch_presentation_return_url", "lti_message_type", "lti_version", "reg_key", "reg_password", "reg_url", "tc_profile_url"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "launch_presentation_return_url": obj.get("launch_presentation_return_url"),
            "lti_message_type": obj.get("lti_message_type"),
            "lti_version": obj.get("lti_version"),
            "reg_key": obj.get("reg_key"),
            "reg_password": obj.get("reg_password"),
            "reg_url": obj.get("reg_url"),
            "tc_profile_url": obj.get("tc_profile_url")
        })
        return _obj


