// Code generated by Fern. DO NOT EDIT.

package management

import (
	json "encoding/json"
	fmt "fmt"
	internal "github.com/auth0/go-auth0/v2/management/internal"
	big "math/big"
)

var (
	getSettingsResponseContentFieldUniversalLoginExperience    = big.NewInt(1 << 0)
	getSettingsResponseContentFieldIdentifierFirst             = big.NewInt(1 << 1)
	getSettingsResponseContentFieldWebauthnPlatformFirstFactor = big.NewInt(1 << 2)
)

type GetSettingsResponseContent struct {
	UniversalLoginExperience *UniversalLoginExperienceEnum `json:"universal_login_experience,omitempty" url:"universal_login_experience,omitempty"`
	// Whether identifier first is enabled or not
	IdentifierFirst *bool `json:"identifier_first,omitempty" url:"identifier_first,omitempty"`
	// Use WebAuthn with Device Biometrics as the first authentication factor
	WebauthnPlatformFirstFactor *bool `json:"webauthn_platform_first_factor,omitempty" url:"webauthn_platform_first_factor,omitempty"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`

	ExtraProperties map[string]interface{} `json:"-" url:"-"`

	rawJSON json.RawMessage
}

func (g *GetSettingsResponseContent) GetUniversalLoginExperience() UniversalLoginExperienceEnum {
	if g == nil || g.UniversalLoginExperience == nil {
		return ""
	}
	return *g.UniversalLoginExperience
}

func (g *GetSettingsResponseContent) GetIdentifierFirst() bool {
	if g == nil || g.IdentifierFirst == nil {
		return false
	}
	return *g.IdentifierFirst
}

func (g *GetSettingsResponseContent) GetWebauthnPlatformFirstFactor() bool {
	if g == nil || g.WebauthnPlatformFirstFactor == nil {
		return false
	}
	return *g.WebauthnPlatformFirstFactor
}

func (g *GetSettingsResponseContent) GetExtraProperties() map[string]interface{} {
	return g.ExtraProperties
}

func (g *GetSettingsResponseContent) require(field *big.Int) {
	if g.explicitFields == nil {
		g.explicitFields = big.NewInt(0)
	}
	g.explicitFields.Or(g.explicitFields, field)
}

// SetUniversalLoginExperience sets the UniversalLoginExperience field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (g *GetSettingsResponseContent) SetUniversalLoginExperience(universalLoginExperience *UniversalLoginExperienceEnum) {
	g.UniversalLoginExperience = universalLoginExperience
	g.require(getSettingsResponseContentFieldUniversalLoginExperience)
}

// SetIdentifierFirst sets the IdentifierFirst field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (g *GetSettingsResponseContent) SetIdentifierFirst(identifierFirst *bool) {
	g.IdentifierFirst = identifierFirst
	g.require(getSettingsResponseContentFieldIdentifierFirst)
}

// SetWebauthnPlatformFirstFactor sets the WebauthnPlatformFirstFactor field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (g *GetSettingsResponseContent) SetWebauthnPlatformFirstFactor(webauthnPlatformFirstFactor *bool) {
	g.WebauthnPlatformFirstFactor = webauthnPlatformFirstFactor
	g.require(getSettingsResponseContentFieldWebauthnPlatformFirstFactor)
}

func (g *GetSettingsResponseContent) UnmarshalJSON(data []byte) error {
	type embed GetSettingsResponseContent
	var unmarshaler = struct {
		embed
	}{
		embed: embed(*g),
	}
	if err := json.Unmarshal(data, &unmarshaler); err != nil {
		return err
	}
	*g = GetSettingsResponseContent(unmarshaler.embed)
	extraProperties, err := internal.ExtractExtraProperties(data, *g)
	if err != nil {
		return err
	}
	g.ExtraProperties = extraProperties
	g.rawJSON = json.RawMessage(data)
	return nil
}

func (g *GetSettingsResponseContent) MarshalJSON() ([]byte, error) {
	type embed GetSettingsResponseContent
	var marshaler = struct {
		embed
	}{
		embed: embed(*g),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, g.explicitFields)
	return internal.MarshalJSONWithExtraProperties(explicitMarshaler, g.ExtraProperties)
}

func (g *GetSettingsResponseContent) String() string {
	if len(g.rawJSON) > 0 {
		if value, err := internal.StringifyJSON(g.rawJSON); err == nil {
			return value
		}
	}
	if value, err := internal.StringifyJSON(g); err == nil {
		return value
	}
	return fmt.Sprintf("%#v", g)
}

// Which login experience to use. Can be `new` or `classic`.
type UniversalLoginExperienceEnum string

const (
	UniversalLoginExperienceEnumNew     UniversalLoginExperienceEnum = "new"
	UniversalLoginExperienceEnumClassic UniversalLoginExperienceEnum = "classic"
)

func NewUniversalLoginExperienceEnumFromString(s string) (UniversalLoginExperienceEnum, error) {
	switch s {
	case "new":
		return UniversalLoginExperienceEnumNew, nil
	case "classic":
		return UniversalLoginExperienceEnumClassic, nil
	}
	var t UniversalLoginExperienceEnum
	return "", fmt.Errorf("%s is not a valid %T", s, t)
}

func (u UniversalLoginExperienceEnum) Ptr() *UniversalLoginExperienceEnum {
	return &u
}

var (
	updateSettingsResponseContentFieldUniversalLoginExperience    = big.NewInt(1 << 0)
	updateSettingsResponseContentFieldIdentifierFirst             = big.NewInt(1 << 1)
	updateSettingsResponseContentFieldWebauthnPlatformFirstFactor = big.NewInt(1 << 2)
)

type UpdateSettingsResponseContent struct {
	UniversalLoginExperience *UniversalLoginExperienceEnum `json:"universal_login_experience,omitempty" url:"universal_login_experience,omitempty"`
	// Whether identifier first is enabled or not
	IdentifierFirst *bool `json:"identifier_first,omitempty" url:"identifier_first,omitempty"`
	// Use WebAuthn with Device Biometrics as the first authentication factor
	WebauthnPlatformFirstFactor *bool `json:"webauthn_platform_first_factor,omitempty" url:"webauthn_platform_first_factor,omitempty"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`

	ExtraProperties map[string]interface{} `json:"-" url:"-"`

	rawJSON json.RawMessage
}

func (u *UpdateSettingsResponseContent) GetUniversalLoginExperience() UniversalLoginExperienceEnum {
	if u == nil || u.UniversalLoginExperience == nil {
		return ""
	}
	return *u.UniversalLoginExperience
}

func (u *UpdateSettingsResponseContent) GetIdentifierFirst() bool {
	if u == nil || u.IdentifierFirst == nil {
		return false
	}
	return *u.IdentifierFirst
}

func (u *UpdateSettingsResponseContent) GetWebauthnPlatformFirstFactor() bool {
	if u == nil || u.WebauthnPlatformFirstFactor == nil {
		return false
	}
	return *u.WebauthnPlatformFirstFactor
}

func (u *UpdateSettingsResponseContent) GetExtraProperties() map[string]interface{} {
	return u.ExtraProperties
}

func (u *UpdateSettingsResponseContent) require(field *big.Int) {
	if u.explicitFields == nil {
		u.explicitFields = big.NewInt(0)
	}
	u.explicitFields.Or(u.explicitFields, field)
}

// SetUniversalLoginExperience sets the UniversalLoginExperience field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (u *UpdateSettingsResponseContent) SetUniversalLoginExperience(universalLoginExperience *UniversalLoginExperienceEnum) {
	u.UniversalLoginExperience = universalLoginExperience
	u.require(updateSettingsResponseContentFieldUniversalLoginExperience)
}

// SetIdentifierFirst sets the IdentifierFirst field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (u *UpdateSettingsResponseContent) SetIdentifierFirst(identifierFirst *bool) {
	u.IdentifierFirst = identifierFirst
	u.require(updateSettingsResponseContentFieldIdentifierFirst)
}

// SetWebauthnPlatformFirstFactor sets the WebauthnPlatformFirstFactor field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (u *UpdateSettingsResponseContent) SetWebauthnPlatformFirstFactor(webauthnPlatformFirstFactor *bool) {
	u.WebauthnPlatformFirstFactor = webauthnPlatformFirstFactor
	u.require(updateSettingsResponseContentFieldWebauthnPlatformFirstFactor)
}

func (u *UpdateSettingsResponseContent) UnmarshalJSON(data []byte) error {
	type embed UpdateSettingsResponseContent
	var unmarshaler = struct {
		embed
	}{
		embed: embed(*u),
	}
	if err := json.Unmarshal(data, &unmarshaler); err != nil {
		return err
	}
	*u = UpdateSettingsResponseContent(unmarshaler.embed)
	extraProperties, err := internal.ExtractExtraProperties(data, *u)
	if err != nil {
		return err
	}
	u.ExtraProperties = extraProperties
	u.rawJSON = json.RawMessage(data)
	return nil
}

func (u *UpdateSettingsResponseContent) MarshalJSON() ([]byte, error) {
	type embed UpdateSettingsResponseContent
	var marshaler = struct {
		embed
	}{
		embed: embed(*u),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, u.explicitFields)
	return internal.MarshalJSONWithExtraProperties(explicitMarshaler, u.ExtraProperties)
}

func (u *UpdateSettingsResponseContent) String() string {
	if len(u.rawJSON) > 0 {
		if value, err := internal.StringifyJSON(u.rawJSON); err == nil {
			return value
		}
	}
	if value, err := internal.StringifyJSON(u); err == nil {
		return value
	}
	return fmt.Sprintf("%#v", u)
}
