/*
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"
)

// checks if the ContextualFlowInfo type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ContextualFlowInfo{}

// ContextualFlowInfo Contextual flow information for a challenge
type ContextualFlowInfo struct {
	Title                *string                      `json:"title,omitempty"`
	Background           *string                      `json:"background,omitempty"`
	BackgroundThemedUrls NullableThemedUrls           `json:"background_themed_urls,omitempty"`
	CancelUrl            string                       `json:"cancel_url"`
	Layout               ContextualFlowInfoLayoutEnum `json:"layout"`
	AdditionalProperties map[string]interface{}
}

type _ContextualFlowInfo ContextualFlowInfo

// NewContextualFlowInfo instantiates a new ContextualFlowInfo object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewContextualFlowInfo(cancelUrl string, layout ContextualFlowInfoLayoutEnum) *ContextualFlowInfo {
	this := ContextualFlowInfo{}
	this.CancelUrl = cancelUrl
	this.Layout = layout
	return &this
}

// NewContextualFlowInfoWithDefaults instantiates a new ContextualFlowInfo object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewContextualFlowInfoWithDefaults() *ContextualFlowInfo {
	this := ContextualFlowInfo{}
	return &this
}

// GetTitle returns the Title field value if set, zero value otherwise.
func (o *ContextualFlowInfo) GetTitle() string {
	if o == nil || IsNil(o.Title) {
		var ret string
		return ret
	}
	return *o.Title
}

// GetTitleOk returns a tuple with the Title field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ContextualFlowInfo) GetTitleOk() (*string, bool) {
	if o == nil || IsNil(o.Title) {
		return nil, false
	}
	return o.Title, true
}

// HasTitle returns a boolean if a field has been set.
func (o *ContextualFlowInfo) HasTitle() bool {
	if o != nil && !IsNil(o.Title) {
		return true
	}

	return false
}

// SetTitle gets a reference to the given string and assigns it to the Title field.
func (o *ContextualFlowInfo) SetTitle(v string) {
	o.Title = &v
}

// GetBackground returns the Background field value if set, zero value otherwise.
func (o *ContextualFlowInfo) GetBackground() string {
	if o == nil || IsNil(o.Background) {
		var ret string
		return ret
	}
	return *o.Background
}

// GetBackgroundOk returns a tuple with the Background field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ContextualFlowInfo) GetBackgroundOk() (*string, bool) {
	if o == nil || IsNil(o.Background) {
		return nil, false
	}
	return o.Background, true
}

// HasBackground returns a boolean if a field has been set.
func (o *ContextualFlowInfo) HasBackground() bool {
	if o != nil && !IsNil(o.Background) {
		return true
	}

	return false
}

// SetBackground gets a reference to the given string and assigns it to the Background field.
func (o *ContextualFlowInfo) SetBackground(v string) {
	o.Background = &v
}

// GetBackgroundThemedUrls returns the BackgroundThemedUrls field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *ContextualFlowInfo) GetBackgroundThemedUrls() ThemedUrls {
	if o == nil || IsNil(o.BackgroundThemedUrls.Get()) {
		var ret ThemedUrls
		return ret
	}
	return *o.BackgroundThemedUrls.Get()
}

// GetBackgroundThemedUrlsOk returns a tuple with the BackgroundThemedUrls field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *ContextualFlowInfo) GetBackgroundThemedUrlsOk() (*ThemedUrls, bool) {
	if o == nil {
		return nil, false
	}
	return o.BackgroundThemedUrls.Get(), o.BackgroundThemedUrls.IsSet()
}

// HasBackgroundThemedUrls returns a boolean if a field has been set.
func (o *ContextualFlowInfo) HasBackgroundThemedUrls() bool {
	if o != nil && o.BackgroundThemedUrls.IsSet() {
		return true
	}

	return false
}

// SetBackgroundThemedUrls gets a reference to the given NullableThemedUrls and assigns it to the BackgroundThemedUrls field.
func (o *ContextualFlowInfo) SetBackgroundThemedUrls(v ThemedUrls) {
	o.BackgroundThemedUrls.Set(&v)
}

// SetBackgroundThemedUrlsNil sets the value for BackgroundThemedUrls to be an explicit nil
func (o *ContextualFlowInfo) SetBackgroundThemedUrlsNil() {
	o.BackgroundThemedUrls.Set(nil)
}

// UnsetBackgroundThemedUrls ensures that no value is present for BackgroundThemedUrls, not even an explicit nil
func (o *ContextualFlowInfo) UnsetBackgroundThemedUrls() {
	o.BackgroundThemedUrls.Unset()
}

// GetCancelUrl returns the CancelUrl field value
func (o *ContextualFlowInfo) GetCancelUrl() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.CancelUrl
}

// GetCancelUrlOk returns a tuple with the CancelUrl field value
// and a boolean to check if the value has been set.
func (o *ContextualFlowInfo) GetCancelUrlOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.CancelUrl, true
}

// SetCancelUrl sets field value
func (o *ContextualFlowInfo) SetCancelUrl(v string) {
	o.CancelUrl = v
}

// GetLayout returns the Layout field value
func (o *ContextualFlowInfo) GetLayout() ContextualFlowInfoLayoutEnum {
	if o == nil {
		var ret ContextualFlowInfoLayoutEnum
		return ret
	}

	return o.Layout
}

// GetLayoutOk returns a tuple with the Layout field value
// and a boolean to check if the value has been set.
func (o *ContextualFlowInfo) GetLayoutOk() (*ContextualFlowInfoLayoutEnum, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Layout, true
}

// SetLayout sets field value
func (o *ContextualFlowInfo) SetLayout(v ContextualFlowInfoLayoutEnum) {
	o.Layout = v
}

func (o ContextualFlowInfo) MarshalJSON() ([]byte, error) {
	toSerialize, err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o ContextualFlowInfo) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Title) {
		toSerialize["title"] = o.Title
	}
	if !IsNil(o.Background) {
		toSerialize["background"] = o.Background
	}
	if o.BackgroundThemedUrls.IsSet() {
		toSerialize["background_themed_urls"] = o.BackgroundThemedUrls.Get()
	}
	toSerialize["cancel_url"] = o.CancelUrl
	toSerialize["layout"] = o.Layout

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

func (o *ContextualFlowInfo) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"cancel_url",
		"layout",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err
	}

	for _, requiredProperty := range requiredProperties {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varContextualFlowInfo := _ContextualFlowInfo{}

	err = json.Unmarshal(data, &varContextualFlowInfo)

	if err != nil {
		return err
	}

	*o = ContextualFlowInfo(varContextualFlowInfo)

	additionalProperties := make(map[string]interface{})

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "title")
		delete(additionalProperties, "background")
		delete(additionalProperties, "background_themed_urls")
		delete(additionalProperties, "cancel_url")
		delete(additionalProperties, "layout")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableContextualFlowInfo struct {
	value *ContextualFlowInfo
	isSet bool
}

func (v NullableContextualFlowInfo) Get() *ContextualFlowInfo {
	return v.value
}

func (v *NullableContextualFlowInfo) Set(val *ContextualFlowInfo) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableContextualFlowInfo(val *ContextualFlowInfo) *NullableContextualFlowInfo {
	return &NullableContextualFlowInfo{value: val, isSet: true}
}

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

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