/*
authentik

Making authentication simple.

API version: 2026.5.0-rc1
Contact: hello@goauthentik.io
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package api

import (
	"encoding/json"
	"fmt"
)

// ChallengeTypes - struct for ChallengeTypes
type ChallengeTypes struct {
	AccessDeniedChallenge            *AccessDeniedChallenge
	AppleLoginChallenge              *AppleLoginChallenge
	AuthenticatorDuoChallenge        *AuthenticatorDuoChallenge
	AuthenticatorEmailChallenge      *AuthenticatorEmailChallenge
	AuthenticatorSMSChallenge        *AuthenticatorSMSChallenge
	AuthenticatorStaticChallenge     *AuthenticatorStaticChallenge
	AuthenticatorTOTPChallenge       *AuthenticatorTOTPChallenge
	AuthenticatorValidationChallenge *AuthenticatorValidationChallenge
	AuthenticatorWebAuthnChallenge   *AuthenticatorWebAuthnChallenge
	AutosubmitChallenge              *AutosubmitChallenge
	CaptchaChallenge                 *CaptchaChallenge
	ConsentChallenge                 *ConsentChallenge
	DummyChallenge                   *DummyChallenge
	EmailChallenge                   *EmailChallenge
	EndpointAgentChallenge           *EndpointAgentChallenge
	FlowErrorChallenge               *FlowErrorChallenge
	FrameChallenge                   *FrameChallenge
	IdentificationChallenge          *IdentificationChallenge
	IframeLogoutChallenge            *IframeLogoutChallenge
	NativeLogoutChallenge            *NativeLogoutChallenge
	OAuthDeviceCodeChallenge         *OAuthDeviceCodeChallenge
	OAuthDeviceCodeFinishChallenge   *OAuthDeviceCodeFinishChallenge
	PasswordChallenge                *PasswordChallenge
	PlexAuthenticationChallenge      *PlexAuthenticationChallenge
	PromptChallenge                  *PromptChallenge
	RedirectChallenge                *RedirectChallenge
	SessionEndChallenge              *SessionEndChallenge
	ShellChallenge                   *ShellChallenge
	TelegramLoginChallenge           *TelegramLoginChallenge
	UserLoginChallenge               *UserLoginChallenge
}

// AccessDeniedChallengeAsChallengeTypes is a convenience function that returns AccessDeniedChallenge wrapped in ChallengeTypes
func AccessDeniedChallengeAsChallengeTypes(v *AccessDeniedChallenge) ChallengeTypes {
	return ChallengeTypes{
		AccessDeniedChallenge: v,
	}
}

// AppleLoginChallengeAsChallengeTypes is a convenience function that returns AppleLoginChallenge wrapped in ChallengeTypes
func AppleLoginChallengeAsChallengeTypes(v *AppleLoginChallenge) ChallengeTypes {
	return ChallengeTypes{
		AppleLoginChallenge: v,
	}
}

// AuthenticatorDuoChallengeAsChallengeTypes is a convenience function that returns AuthenticatorDuoChallenge wrapped in ChallengeTypes
func AuthenticatorDuoChallengeAsChallengeTypes(v *AuthenticatorDuoChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorDuoChallenge: v,
	}
}

// AuthenticatorEmailChallengeAsChallengeTypes is a convenience function that returns AuthenticatorEmailChallenge wrapped in ChallengeTypes
func AuthenticatorEmailChallengeAsChallengeTypes(v *AuthenticatorEmailChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorEmailChallenge: v,
	}
}

// AuthenticatorSMSChallengeAsChallengeTypes is a convenience function that returns AuthenticatorSMSChallenge wrapped in ChallengeTypes
func AuthenticatorSMSChallengeAsChallengeTypes(v *AuthenticatorSMSChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorSMSChallenge: v,
	}
}

// AuthenticatorStaticChallengeAsChallengeTypes is a convenience function that returns AuthenticatorStaticChallenge wrapped in ChallengeTypes
func AuthenticatorStaticChallengeAsChallengeTypes(v *AuthenticatorStaticChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorStaticChallenge: v,
	}
}

// AuthenticatorTOTPChallengeAsChallengeTypes is a convenience function that returns AuthenticatorTOTPChallenge wrapped in ChallengeTypes
func AuthenticatorTOTPChallengeAsChallengeTypes(v *AuthenticatorTOTPChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorTOTPChallenge: v,
	}
}

// AuthenticatorValidationChallengeAsChallengeTypes is a convenience function that returns AuthenticatorValidationChallenge wrapped in ChallengeTypes
func AuthenticatorValidationChallengeAsChallengeTypes(v *AuthenticatorValidationChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorValidationChallenge: v,
	}
}

// AuthenticatorWebAuthnChallengeAsChallengeTypes is a convenience function that returns AuthenticatorWebAuthnChallenge wrapped in ChallengeTypes
func AuthenticatorWebAuthnChallengeAsChallengeTypes(v *AuthenticatorWebAuthnChallenge) ChallengeTypes {
	return ChallengeTypes{
		AuthenticatorWebAuthnChallenge: v,
	}
}

// AutosubmitChallengeAsChallengeTypes is a convenience function that returns AutosubmitChallenge wrapped in ChallengeTypes
func AutosubmitChallengeAsChallengeTypes(v *AutosubmitChallenge) ChallengeTypes {
	return ChallengeTypes{
		AutosubmitChallenge: v,
	}
}

// CaptchaChallengeAsChallengeTypes is a convenience function that returns CaptchaChallenge wrapped in ChallengeTypes
func CaptchaChallengeAsChallengeTypes(v *CaptchaChallenge) ChallengeTypes {
	return ChallengeTypes{
		CaptchaChallenge: v,
	}
}

// ConsentChallengeAsChallengeTypes is a convenience function that returns ConsentChallenge wrapped in ChallengeTypes
func ConsentChallengeAsChallengeTypes(v *ConsentChallenge) ChallengeTypes {
	return ChallengeTypes{
		ConsentChallenge: v,
	}
}

// DummyChallengeAsChallengeTypes is a convenience function that returns DummyChallenge wrapped in ChallengeTypes
func DummyChallengeAsChallengeTypes(v *DummyChallenge) ChallengeTypes {
	return ChallengeTypes{
		DummyChallenge: v,
	}
}

// EmailChallengeAsChallengeTypes is a convenience function that returns EmailChallenge wrapped in ChallengeTypes
func EmailChallengeAsChallengeTypes(v *EmailChallenge) ChallengeTypes {
	return ChallengeTypes{
		EmailChallenge: v,
	}
}

// EndpointAgentChallengeAsChallengeTypes is a convenience function that returns EndpointAgentChallenge wrapped in ChallengeTypes
func EndpointAgentChallengeAsChallengeTypes(v *EndpointAgentChallenge) ChallengeTypes {
	return ChallengeTypes{
		EndpointAgentChallenge: v,
	}
}

// FlowErrorChallengeAsChallengeTypes is a convenience function that returns FlowErrorChallenge wrapped in ChallengeTypes
func FlowErrorChallengeAsChallengeTypes(v *FlowErrorChallenge) ChallengeTypes {
	return ChallengeTypes{
		FlowErrorChallenge: v,
	}
}

// FrameChallengeAsChallengeTypes is a convenience function that returns FrameChallenge wrapped in ChallengeTypes
func FrameChallengeAsChallengeTypes(v *FrameChallenge) ChallengeTypes {
	return ChallengeTypes{
		FrameChallenge: v,
	}
}

// IdentificationChallengeAsChallengeTypes is a convenience function that returns IdentificationChallenge wrapped in ChallengeTypes
func IdentificationChallengeAsChallengeTypes(v *IdentificationChallenge) ChallengeTypes {
	return ChallengeTypes{
		IdentificationChallenge: v,
	}
}

// IframeLogoutChallengeAsChallengeTypes is a convenience function that returns IframeLogoutChallenge wrapped in ChallengeTypes
func IframeLogoutChallengeAsChallengeTypes(v *IframeLogoutChallenge) ChallengeTypes {
	return ChallengeTypes{
		IframeLogoutChallenge: v,
	}
}

// NativeLogoutChallengeAsChallengeTypes is a convenience function that returns NativeLogoutChallenge wrapped in ChallengeTypes
func NativeLogoutChallengeAsChallengeTypes(v *NativeLogoutChallenge) ChallengeTypes {
	return ChallengeTypes{
		NativeLogoutChallenge: v,
	}
}

// OAuthDeviceCodeChallengeAsChallengeTypes is a convenience function that returns OAuthDeviceCodeChallenge wrapped in ChallengeTypes
func OAuthDeviceCodeChallengeAsChallengeTypes(v *OAuthDeviceCodeChallenge) ChallengeTypes {
	return ChallengeTypes{
		OAuthDeviceCodeChallenge: v,
	}
}

// OAuthDeviceCodeFinishChallengeAsChallengeTypes is a convenience function that returns OAuthDeviceCodeFinishChallenge wrapped in ChallengeTypes
func OAuthDeviceCodeFinishChallengeAsChallengeTypes(v *OAuthDeviceCodeFinishChallenge) ChallengeTypes {
	return ChallengeTypes{
		OAuthDeviceCodeFinishChallenge: v,
	}
}

// PasswordChallengeAsChallengeTypes is a convenience function that returns PasswordChallenge wrapped in ChallengeTypes
func PasswordChallengeAsChallengeTypes(v *PasswordChallenge) ChallengeTypes {
	return ChallengeTypes{
		PasswordChallenge: v,
	}
}

// PlexAuthenticationChallengeAsChallengeTypes is a convenience function that returns PlexAuthenticationChallenge wrapped in ChallengeTypes
func PlexAuthenticationChallengeAsChallengeTypes(v *PlexAuthenticationChallenge) ChallengeTypes {
	return ChallengeTypes{
		PlexAuthenticationChallenge: v,
	}
}

// PromptChallengeAsChallengeTypes is a convenience function that returns PromptChallenge wrapped in ChallengeTypes
func PromptChallengeAsChallengeTypes(v *PromptChallenge) ChallengeTypes {
	return ChallengeTypes{
		PromptChallenge: v,
	}
}

// RedirectChallengeAsChallengeTypes is a convenience function that returns RedirectChallenge wrapped in ChallengeTypes
func RedirectChallengeAsChallengeTypes(v *RedirectChallenge) ChallengeTypes {
	return ChallengeTypes{
		RedirectChallenge: v,
	}
}

// SessionEndChallengeAsChallengeTypes is a convenience function that returns SessionEndChallenge wrapped in ChallengeTypes
func SessionEndChallengeAsChallengeTypes(v *SessionEndChallenge) ChallengeTypes {
	return ChallengeTypes{
		SessionEndChallenge: v,
	}
}

// ShellChallengeAsChallengeTypes is a convenience function that returns ShellChallenge wrapped in ChallengeTypes
func ShellChallengeAsChallengeTypes(v *ShellChallenge) ChallengeTypes {
	return ChallengeTypes{
		ShellChallenge: v,
	}
}

// TelegramLoginChallengeAsChallengeTypes is a convenience function that returns TelegramLoginChallenge wrapped in ChallengeTypes
func TelegramLoginChallengeAsChallengeTypes(v *TelegramLoginChallenge) ChallengeTypes {
	return ChallengeTypes{
		TelegramLoginChallenge: v,
	}
}

// UserLoginChallengeAsChallengeTypes is a convenience function that returns UserLoginChallenge wrapped in ChallengeTypes
func UserLoginChallengeAsChallengeTypes(v *UserLoginChallenge) ChallengeTypes {
	return ChallengeTypes{
		UserLoginChallenge: v,
	}
}

// Unmarshal JSON data into one of the pointers in the struct
func (dst *ChallengeTypes) UnmarshalJSON(data []byte) error {
	var err error
	// use discriminator value to speed up the lookup
	var jsonDict map[string]interface{}
	err = newStrictDecoder(data).Decode(&jsonDict)
	if err != nil {
		return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
	}

	// check if the discriminator value is 'ak-provider-iframe-logout'
	if jsonDict["component"] == "ak-provider-iframe-logout" {
		// try to unmarshal JSON data into IframeLogoutChallenge
		err = json.Unmarshal(data, &dst.IframeLogoutChallenge)
		if err == nil {
			return nil // data stored in dst.IframeLogoutChallenge, return on the first match
		} else {
			dst.IframeLogoutChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as IframeLogoutChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-provider-oauth2-device-code'
	if jsonDict["component"] == "ak-provider-oauth2-device-code" {
		// try to unmarshal JSON data into OAuthDeviceCodeChallenge
		err = json.Unmarshal(data, &dst.OAuthDeviceCodeChallenge)
		if err == nil {
			return nil // data stored in dst.OAuthDeviceCodeChallenge, return on the first match
		} else {
			dst.OAuthDeviceCodeChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as OAuthDeviceCodeChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-provider-oauth2-device-code-finish'
	if jsonDict["component"] == "ak-provider-oauth2-device-code-finish" {
		// try to unmarshal JSON data into OAuthDeviceCodeFinishChallenge
		err = json.Unmarshal(data, &dst.OAuthDeviceCodeFinishChallenge)
		if err == nil {
			return nil // data stored in dst.OAuthDeviceCodeFinishChallenge, return on the first match
		} else {
			dst.OAuthDeviceCodeFinishChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as OAuthDeviceCodeFinishChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-provider-saml-native-logout'
	if jsonDict["component"] == "ak-provider-saml-native-logout" {
		// try to unmarshal JSON data into NativeLogoutChallenge
		err = json.Unmarshal(data, &dst.NativeLogoutChallenge)
		if err == nil {
			return nil // data stored in dst.NativeLogoutChallenge, return on the first match
		} else {
			dst.NativeLogoutChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as NativeLogoutChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-source-oauth-apple'
	if jsonDict["component"] == "ak-source-oauth-apple" {
		// try to unmarshal JSON data into AppleLoginChallenge
		err = json.Unmarshal(data, &dst.AppleLoginChallenge)
		if err == nil {
			return nil // data stored in dst.AppleLoginChallenge, return on the first match
		} else {
			dst.AppleLoginChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AppleLoginChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-source-plex'
	if jsonDict["component"] == "ak-source-plex" {
		// try to unmarshal JSON data into PlexAuthenticationChallenge
		err = json.Unmarshal(data, &dst.PlexAuthenticationChallenge)
		if err == nil {
			return nil // data stored in dst.PlexAuthenticationChallenge, return on the first match
		} else {
			dst.PlexAuthenticationChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as PlexAuthenticationChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-source-telegram'
	if jsonDict["component"] == "ak-source-telegram" {
		// try to unmarshal JSON data into TelegramLoginChallenge
		err = json.Unmarshal(data, &dst.TelegramLoginChallenge)
		if err == nil {
			return nil // data stored in dst.TelegramLoginChallenge, return on the first match
		} else {
			dst.TelegramLoginChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as TelegramLoginChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-access-denied'
	if jsonDict["component"] == "ak-stage-access-denied" {
		// try to unmarshal JSON data into AccessDeniedChallenge
		err = json.Unmarshal(data, &dst.AccessDeniedChallenge)
		if err == nil {
			return nil // data stored in dst.AccessDeniedChallenge, return on the first match
		} else {
			dst.AccessDeniedChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AccessDeniedChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-duo'
	if jsonDict["component"] == "ak-stage-authenticator-duo" {
		// try to unmarshal JSON data into AuthenticatorDuoChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorDuoChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorDuoChallenge, return on the first match
		} else {
			dst.AuthenticatorDuoChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorDuoChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-email'
	if jsonDict["component"] == "ak-stage-authenticator-email" {
		// try to unmarshal JSON data into AuthenticatorEmailChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorEmailChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorEmailChallenge, return on the first match
		} else {
			dst.AuthenticatorEmailChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorEmailChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-sms'
	if jsonDict["component"] == "ak-stage-authenticator-sms" {
		// try to unmarshal JSON data into AuthenticatorSMSChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorSMSChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorSMSChallenge, return on the first match
		} else {
			dst.AuthenticatorSMSChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorSMSChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-static'
	if jsonDict["component"] == "ak-stage-authenticator-static" {
		// try to unmarshal JSON data into AuthenticatorStaticChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorStaticChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorStaticChallenge, return on the first match
		} else {
			dst.AuthenticatorStaticChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorStaticChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-totp'
	if jsonDict["component"] == "ak-stage-authenticator-totp" {
		// try to unmarshal JSON data into AuthenticatorTOTPChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorTOTPChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorTOTPChallenge, return on the first match
		} else {
			dst.AuthenticatorTOTPChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorTOTPChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-validate'
	if jsonDict["component"] == "ak-stage-authenticator-validate" {
		// try to unmarshal JSON data into AuthenticatorValidationChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorValidationChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorValidationChallenge, return on the first match
		} else {
			dst.AuthenticatorValidationChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorValidationChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-authenticator-webauthn'
	if jsonDict["component"] == "ak-stage-authenticator-webauthn" {
		// try to unmarshal JSON data into AuthenticatorWebAuthnChallenge
		err = json.Unmarshal(data, &dst.AuthenticatorWebAuthnChallenge)
		if err == nil {
			return nil // data stored in dst.AuthenticatorWebAuthnChallenge, return on the first match
		} else {
			dst.AuthenticatorWebAuthnChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AuthenticatorWebAuthnChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-autosubmit'
	if jsonDict["component"] == "ak-stage-autosubmit" {
		// try to unmarshal JSON data into AutosubmitChallenge
		err = json.Unmarshal(data, &dst.AutosubmitChallenge)
		if err == nil {
			return nil // data stored in dst.AutosubmitChallenge, return on the first match
		} else {
			dst.AutosubmitChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as AutosubmitChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-captcha'
	if jsonDict["component"] == "ak-stage-captcha" {
		// try to unmarshal JSON data into CaptchaChallenge
		err = json.Unmarshal(data, &dst.CaptchaChallenge)
		if err == nil {
			return nil // data stored in dst.CaptchaChallenge, return on the first match
		} else {
			dst.CaptchaChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as CaptchaChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-consent'
	if jsonDict["component"] == "ak-stage-consent" {
		// try to unmarshal JSON data into ConsentChallenge
		err = json.Unmarshal(data, &dst.ConsentChallenge)
		if err == nil {
			return nil // data stored in dst.ConsentChallenge, return on the first match
		} else {
			dst.ConsentChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as ConsentChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-dummy'
	if jsonDict["component"] == "ak-stage-dummy" {
		// try to unmarshal JSON data into DummyChallenge
		err = json.Unmarshal(data, &dst.DummyChallenge)
		if err == nil {
			return nil // data stored in dst.DummyChallenge, return on the first match
		} else {
			dst.DummyChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as DummyChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-email'
	if jsonDict["component"] == "ak-stage-email" {
		// try to unmarshal JSON data into EmailChallenge
		err = json.Unmarshal(data, &dst.EmailChallenge)
		if err == nil {
			return nil // data stored in dst.EmailChallenge, return on the first match
		} else {
			dst.EmailChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as EmailChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-endpoint-agent'
	if jsonDict["component"] == "ak-stage-endpoint-agent" {
		// try to unmarshal JSON data into EndpointAgentChallenge
		err = json.Unmarshal(data, &dst.EndpointAgentChallenge)
		if err == nil {
			return nil // data stored in dst.EndpointAgentChallenge, return on the first match
		} else {
			dst.EndpointAgentChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as EndpointAgentChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-flow-error'
	if jsonDict["component"] == "ak-stage-flow-error" {
		// try to unmarshal JSON data into FlowErrorChallenge
		err = json.Unmarshal(data, &dst.FlowErrorChallenge)
		if err == nil {
			return nil // data stored in dst.FlowErrorChallenge, return on the first match
		} else {
			dst.FlowErrorChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as FlowErrorChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-identification'
	if jsonDict["component"] == "ak-stage-identification" {
		// try to unmarshal JSON data into IdentificationChallenge
		err = json.Unmarshal(data, &dst.IdentificationChallenge)
		if err == nil {
			return nil // data stored in dst.IdentificationChallenge, return on the first match
		} else {
			dst.IdentificationChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as IdentificationChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-password'
	if jsonDict["component"] == "ak-stage-password" {
		// try to unmarshal JSON data into PasswordChallenge
		err = json.Unmarshal(data, &dst.PasswordChallenge)
		if err == nil {
			return nil // data stored in dst.PasswordChallenge, return on the first match
		} else {
			dst.PasswordChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as PasswordChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-prompt'
	if jsonDict["component"] == "ak-stage-prompt" {
		// try to unmarshal JSON data into PromptChallenge
		err = json.Unmarshal(data, &dst.PromptChallenge)
		if err == nil {
			return nil // data stored in dst.PromptChallenge, return on the first match
		} else {
			dst.PromptChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as PromptChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-session-end'
	if jsonDict["component"] == "ak-stage-session-end" {
		// try to unmarshal JSON data into SessionEndChallenge
		err = json.Unmarshal(data, &dst.SessionEndChallenge)
		if err == nil {
			return nil // data stored in dst.SessionEndChallenge, return on the first match
		} else {
			dst.SessionEndChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as SessionEndChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'ak-stage-user-login'
	if jsonDict["component"] == "ak-stage-user-login" {
		// try to unmarshal JSON data into UserLoginChallenge
		err = json.Unmarshal(data, &dst.UserLoginChallenge)
		if err == nil {
			return nil // data stored in dst.UserLoginChallenge, return on the first match
		} else {
			dst.UserLoginChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as UserLoginChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'xak-flow-frame'
	if jsonDict["component"] == "xak-flow-frame" {
		// try to unmarshal JSON data into FrameChallenge
		err = json.Unmarshal(data, &dst.FrameChallenge)
		if err == nil {
			return nil // data stored in dst.FrameChallenge, return on the first match
		} else {
			dst.FrameChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as FrameChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'xak-flow-redirect'
	if jsonDict["component"] == "xak-flow-redirect" {
		// try to unmarshal JSON data into RedirectChallenge
		err = json.Unmarshal(data, &dst.RedirectChallenge)
		if err == nil {
			return nil // data stored in dst.RedirectChallenge, return on the first match
		} else {
			dst.RedirectChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as RedirectChallenge: %s", err.Error())
		}
	}

	// check if the discriminator value is 'xak-flow-shell'
	if jsonDict["component"] == "xak-flow-shell" {
		// try to unmarshal JSON data into ShellChallenge
		err = json.Unmarshal(data, &dst.ShellChallenge)
		if err == nil {
			return nil // data stored in dst.ShellChallenge, return on the first match
		} else {
			dst.ShellChallenge = nil
			return fmt.Errorf("failed to unmarshal ChallengeTypes as ShellChallenge: %s", err.Error())
		}
	}

	return nil
}

// Marshal data from the first non-nil pointers in the struct to JSON
func (src ChallengeTypes) MarshalJSON() ([]byte, error) {
	if src.AccessDeniedChallenge != nil {
		return json.Marshal(&src.AccessDeniedChallenge)
	}

	if src.AppleLoginChallenge != nil {
		return json.Marshal(&src.AppleLoginChallenge)
	}

	if src.AuthenticatorDuoChallenge != nil {
		return json.Marshal(&src.AuthenticatorDuoChallenge)
	}

	if src.AuthenticatorEmailChallenge != nil {
		return json.Marshal(&src.AuthenticatorEmailChallenge)
	}

	if src.AuthenticatorSMSChallenge != nil {
		return json.Marshal(&src.AuthenticatorSMSChallenge)
	}

	if src.AuthenticatorStaticChallenge != nil {
		return json.Marshal(&src.AuthenticatorStaticChallenge)
	}

	if src.AuthenticatorTOTPChallenge != nil {
		return json.Marshal(&src.AuthenticatorTOTPChallenge)
	}

	if src.AuthenticatorValidationChallenge != nil {
		return json.Marshal(&src.AuthenticatorValidationChallenge)
	}

	if src.AuthenticatorWebAuthnChallenge != nil {
		return json.Marshal(&src.AuthenticatorWebAuthnChallenge)
	}

	if src.AutosubmitChallenge != nil {
		return json.Marshal(&src.AutosubmitChallenge)
	}

	if src.CaptchaChallenge != nil {
		return json.Marshal(&src.CaptchaChallenge)
	}

	if src.ConsentChallenge != nil {
		return json.Marshal(&src.ConsentChallenge)
	}

	if src.DummyChallenge != nil {
		return json.Marshal(&src.DummyChallenge)
	}

	if src.EmailChallenge != nil {
		return json.Marshal(&src.EmailChallenge)
	}

	if src.EndpointAgentChallenge != nil {
		return json.Marshal(&src.EndpointAgentChallenge)
	}

	if src.FlowErrorChallenge != nil {
		return json.Marshal(&src.FlowErrorChallenge)
	}

	if src.FrameChallenge != nil {
		return json.Marshal(&src.FrameChallenge)
	}

	if src.IdentificationChallenge != nil {
		return json.Marshal(&src.IdentificationChallenge)
	}

	if src.IframeLogoutChallenge != nil {
		return json.Marshal(&src.IframeLogoutChallenge)
	}

	if src.NativeLogoutChallenge != nil {
		return json.Marshal(&src.NativeLogoutChallenge)
	}

	if src.OAuthDeviceCodeChallenge != nil {
		return json.Marshal(&src.OAuthDeviceCodeChallenge)
	}

	if src.OAuthDeviceCodeFinishChallenge != nil {
		return json.Marshal(&src.OAuthDeviceCodeFinishChallenge)
	}

	if src.PasswordChallenge != nil {
		return json.Marshal(&src.PasswordChallenge)
	}

	if src.PlexAuthenticationChallenge != nil {
		return json.Marshal(&src.PlexAuthenticationChallenge)
	}

	if src.PromptChallenge != nil {
		return json.Marshal(&src.PromptChallenge)
	}

	if src.RedirectChallenge != nil {
		return json.Marshal(&src.RedirectChallenge)
	}

	if src.SessionEndChallenge != nil {
		return json.Marshal(&src.SessionEndChallenge)
	}

	if src.ShellChallenge != nil {
		return json.Marshal(&src.ShellChallenge)
	}

	if src.TelegramLoginChallenge != nil {
		return json.Marshal(&src.TelegramLoginChallenge)
	}

	if src.UserLoginChallenge != nil {
		return json.Marshal(&src.UserLoginChallenge)
	}

	return nil, nil // no data in oneOf schemas
}

// Get the actual instance
func (obj *ChallengeTypes) GetActualInstance() interface{} {
	if obj == nil {
		return nil
	}
	if obj.AccessDeniedChallenge != nil {
		return obj.AccessDeniedChallenge
	}

	if obj.AppleLoginChallenge != nil {
		return obj.AppleLoginChallenge
	}

	if obj.AuthenticatorDuoChallenge != nil {
		return obj.AuthenticatorDuoChallenge
	}

	if obj.AuthenticatorEmailChallenge != nil {
		return obj.AuthenticatorEmailChallenge
	}

	if obj.AuthenticatorSMSChallenge != nil {
		return obj.AuthenticatorSMSChallenge
	}

	if obj.AuthenticatorStaticChallenge != nil {
		return obj.AuthenticatorStaticChallenge
	}

	if obj.AuthenticatorTOTPChallenge != nil {
		return obj.AuthenticatorTOTPChallenge
	}

	if obj.AuthenticatorValidationChallenge != nil {
		return obj.AuthenticatorValidationChallenge
	}

	if obj.AuthenticatorWebAuthnChallenge != nil {
		return obj.AuthenticatorWebAuthnChallenge
	}

	if obj.AutosubmitChallenge != nil {
		return obj.AutosubmitChallenge
	}

	if obj.CaptchaChallenge != nil {
		return obj.CaptchaChallenge
	}

	if obj.ConsentChallenge != nil {
		return obj.ConsentChallenge
	}

	if obj.DummyChallenge != nil {
		return obj.DummyChallenge
	}

	if obj.EmailChallenge != nil {
		return obj.EmailChallenge
	}

	if obj.EndpointAgentChallenge != nil {
		return obj.EndpointAgentChallenge
	}

	if obj.FlowErrorChallenge != nil {
		return obj.FlowErrorChallenge
	}

	if obj.FrameChallenge != nil {
		return obj.FrameChallenge
	}

	if obj.IdentificationChallenge != nil {
		return obj.IdentificationChallenge
	}

	if obj.IframeLogoutChallenge != nil {
		return obj.IframeLogoutChallenge
	}

	if obj.NativeLogoutChallenge != nil {
		return obj.NativeLogoutChallenge
	}

	if obj.OAuthDeviceCodeChallenge != nil {
		return obj.OAuthDeviceCodeChallenge
	}

	if obj.OAuthDeviceCodeFinishChallenge != nil {
		return obj.OAuthDeviceCodeFinishChallenge
	}

	if obj.PasswordChallenge != nil {
		return obj.PasswordChallenge
	}

	if obj.PlexAuthenticationChallenge != nil {
		return obj.PlexAuthenticationChallenge
	}

	if obj.PromptChallenge != nil {
		return obj.PromptChallenge
	}

	if obj.RedirectChallenge != nil {
		return obj.RedirectChallenge
	}

	if obj.SessionEndChallenge != nil {
		return obj.SessionEndChallenge
	}

	if obj.ShellChallenge != nil {
		return obj.ShellChallenge
	}

	if obj.TelegramLoginChallenge != nil {
		return obj.TelegramLoginChallenge
	}

	if obj.UserLoginChallenge != nil {
		return obj.UserLoginChallenge
	}

	// all schemas are nil
	return nil
}

// Get the actual instance value
func (obj ChallengeTypes) GetActualInstanceValue() interface{} {
	if obj.AccessDeniedChallenge != nil {
		return *obj.AccessDeniedChallenge
	}

	if obj.AppleLoginChallenge != nil {
		return *obj.AppleLoginChallenge
	}

	if obj.AuthenticatorDuoChallenge != nil {
		return *obj.AuthenticatorDuoChallenge
	}

	if obj.AuthenticatorEmailChallenge != nil {
		return *obj.AuthenticatorEmailChallenge
	}

	if obj.AuthenticatorSMSChallenge != nil {
		return *obj.AuthenticatorSMSChallenge
	}

	if obj.AuthenticatorStaticChallenge != nil {
		return *obj.AuthenticatorStaticChallenge
	}

	if obj.AuthenticatorTOTPChallenge != nil {
		return *obj.AuthenticatorTOTPChallenge
	}

	if obj.AuthenticatorValidationChallenge != nil {
		return *obj.AuthenticatorValidationChallenge
	}

	if obj.AuthenticatorWebAuthnChallenge != nil {
		return *obj.AuthenticatorWebAuthnChallenge
	}

	if obj.AutosubmitChallenge != nil {
		return *obj.AutosubmitChallenge
	}

	if obj.CaptchaChallenge != nil {
		return *obj.CaptchaChallenge
	}

	if obj.ConsentChallenge != nil {
		return *obj.ConsentChallenge
	}

	if obj.DummyChallenge != nil {
		return *obj.DummyChallenge
	}

	if obj.EmailChallenge != nil {
		return *obj.EmailChallenge
	}

	if obj.EndpointAgentChallenge != nil {
		return *obj.EndpointAgentChallenge
	}

	if obj.FlowErrorChallenge != nil {
		return *obj.FlowErrorChallenge
	}

	if obj.FrameChallenge != nil {
		return *obj.FrameChallenge
	}

	if obj.IdentificationChallenge != nil {
		return *obj.IdentificationChallenge
	}

	if obj.IframeLogoutChallenge != nil {
		return *obj.IframeLogoutChallenge
	}

	if obj.NativeLogoutChallenge != nil {
		return *obj.NativeLogoutChallenge
	}

	if obj.OAuthDeviceCodeChallenge != nil {
		return *obj.OAuthDeviceCodeChallenge
	}

	if obj.OAuthDeviceCodeFinishChallenge != nil {
		return *obj.OAuthDeviceCodeFinishChallenge
	}

	if obj.PasswordChallenge != nil {
		return *obj.PasswordChallenge
	}

	if obj.PlexAuthenticationChallenge != nil {
		return *obj.PlexAuthenticationChallenge
	}

	if obj.PromptChallenge != nil {
		return *obj.PromptChallenge
	}

	if obj.RedirectChallenge != nil {
		return *obj.RedirectChallenge
	}

	if obj.SessionEndChallenge != nil {
		return *obj.SessionEndChallenge
	}

	if obj.ShellChallenge != nil {
		return *obj.ShellChallenge
	}

	if obj.TelegramLoginChallenge != nil {
		return *obj.TelegramLoginChallenge
	}

	if obj.UserLoginChallenge != nil {
		return *obj.UserLoginChallenge
	}

	// all schemas are nil
	return nil
}

type NullableChallengeTypes struct {
	value *ChallengeTypes
	isSet bool
}

func (v NullableChallengeTypes) Get() *ChallengeTypes {
	return v.value
}

func (v *NullableChallengeTypes) Set(val *ChallengeTypes) {
	v.value = val
	v.isSet = true
}

func (v NullableChallengeTypes) IsSet() bool {
	return v.isSet
}

func (v *NullableChallengeTypes) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableChallengeTypes(val *ChallengeTypes) *NullableChallengeTypes {
	return &NullableChallengeTypes{value: val, isSet: true}
}

func (v NullableChallengeTypes) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableChallengeTypes) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}
