# coding: utf-8

"""
    Better Auth

    API Reference for your Better Auth Instance

    The version of the OpenAPI document: 1.1.0
    Contact: chasenspace@gmail.com
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from better_auth.models.generate_passkey_registration_options200_response_authenticator_selection import GeneratePasskeyRegistrationOptions200ResponseAuthenticatorSelection
from better_auth.models.generate_passkey_registration_options200_response_exclude_credentials_inner import GeneratePasskeyRegistrationOptions200ResponseExcludeCredentialsInner
from better_auth.models.generate_passkey_registration_options200_response_pub_key_cred_params_inner import GeneratePasskeyRegistrationOptions200ResponsePubKeyCredParamsInner
from better_auth.models.generate_passkey_registration_options200_response_rp import GeneratePasskeyRegistrationOptions200ResponseRp
from better_auth.models.generate_passkey_registration_options200_response_user import GeneratePasskeyRegistrationOptions200ResponseUser
from typing import Optional, Set
from typing_extensions import Self

class GeneratePasskeyRegistrationOptions200Response(BaseModel):
    """
    GeneratePasskeyRegistrationOptions200Response
    """ # noqa: E501
    challenge: Optional[StrictStr] = None
    rp: Optional[GeneratePasskeyRegistrationOptions200ResponseRp] = None
    user: Optional[GeneratePasskeyRegistrationOptions200ResponseUser] = None
    pub_key_cred_params: Optional[List[GeneratePasskeyRegistrationOptions200ResponsePubKeyCredParamsInner]] = Field(default=None, alias="pubKeyCredParams")
    timeout: Optional[Union[StrictFloat, StrictInt]] = None
    exclude_credentials: Optional[List[GeneratePasskeyRegistrationOptions200ResponseExcludeCredentialsInner]] = Field(default=None, alias="excludeCredentials")
    authenticator_selection: Optional[GeneratePasskeyRegistrationOptions200ResponseAuthenticatorSelection] = Field(default=None, alias="authenticatorSelection")
    attestation: Optional[StrictStr] = None
    extensions: Optional[Dict[str, Any]] = None
    __properties: ClassVar[List[str]] = ["challenge", "rp", "user", "pubKeyCredParams", "timeout", "excludeCredentials", "authenticatorSelection", "attestation", "extensions"]

    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 GeneratePasskeyRegistrationOptions200Response 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,
        )
        # override the default output from pydantic by calling `to_dict()` of rp
        if self.rp:
            _dict['rp'] = self.rp.to_dict()
        # override the default output from pydantic by calling `to_dict()` of user
        if self.user:
            _dict['user'] = self.user.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in pub_key_cred_params (list)
        _items = []
        if self.pub_key_cred_params:
            for _item_pub_key_cred_params in self.pub_key_cred_params:
                if _item_pub_key_cred_params:
                    _items.append(_item_pub_key_cred_params.to_dict())
            _dict['pubKeyCredParams'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in exclude_credentials (list)
        _items = []
        if self.exclude_credentials:
            for _item_exclude_credentials in self.exclude_credentials:
                if _item_exclude_credentials:
                    _items.append(_item_exclude_credentials.to_dict())
            _dict['excludeCredentials'] = _items
        # override the default output from pydantic by calling `to_dict()` of authenticator_selection
        if self.authenticator_selection:
            _dict['authenticatorSelection'] = self.authenticator_selection.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "challenge": obj.get("challenge"),
            "rp": GeneratePasskeyRegistrationOptions200ResponseRp.from_dict(obj["rp"]) if obj.get("rp") is not None else None,
            "user": GeneratePasskeyRegistrationOptions200ResponseUser.from_dict(obj["user"]) if obj.get("user") is not None else None,
            "pubKeyCredParams": [GeneratePasskeyRegistrationOptions200ResponsePubKeyCredParamsInner.from_dict(_item) for _item in obj["pubKeyCredParams"]] if obj.get("pubKeyCredParams") is not None else None,
            "timeout": obj.get("timeout"),
            "excludeCredentials": [GeneratePasskeyRegistrationOptions200ResponseExcludeCredentialsInner.from_dict(_item) for _item in obj["excludeCredentials"]] if obj.get("excludeCredentials") is not None else None,
            "authenticatorSelection": GeneratePasskeyRegistrationOptions200ResponseAuthenticatorSelection.from_dict(obj["authenticatorSelection"]) if obj.get("authenticatorSelection") is not None else None,
            "attestation": obj.get("attestation"),
            "extensions": obj.get("extensions")
        })
        return _obj


