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

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

// EventRequest Event Serializer
type EventRequest struct {
	User                 map[string]interface{} `json:"user,omitempty"`
	Action               EventActions           `json:"action"`
	App                  string                 `json:"app"`
	Context              map[string]interface{} `json:"context,omitempty"`
	ClientIp             NullableString         `json:"client_ip,omitempty"`
	Expires              *time.Time             `json:"expires,omitempty"`
	Brand                map[string]interface{} `json:"brand,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _EventRequest EventRequest

// NewEventRequest instantiates a new EventRequest 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 NewEventRequest(action EventActions, app string) *EventRequest {
	this := EventRequest{}
	this.Action = action
	this.App = app
	return &this
}

// NewEventRequestWithDefaults instantiates a new EventRequest 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 NewEventRequestWithDefaults() *EventRequest {
	this := EventRequest{}
	return &this
}

// GetUser returns the User field value if set, zero value otherwise.
func (o *EventRequest) GetUser() map[string]interface{} {
	if o == nil || IsNil(o.User) {
		var ret map[string]interface{}
		return ret
	}
	return o.User
}

// GetUserOk returns a tuple with the User field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *EventRequest) GetUserOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.User) {
		return map[string]interface{}{}, false
	}
	return o.User, true
}

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

	return false
}

// SetUser gets a reference to the given map[string]interface{} and assigns it to the User field.
func (o *EventRequest) SetUser(v map[string]interface{}) {
	o.User = v
}

// GetAction returns the Action field value
func (o *EventRequest) GetAction() EventActions {
	if o == nil {
		var ret EventActions
		return ret
	}

	return o.Action
}

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

// SetAction sets field value
func (o *EventRequest) SetAction(v EventActions) {
	o.Action = v
}

// GetApp returns the App field value
func (o *EventRequest) GetApp() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.App
}

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

// SetApp sets field value
func (o *EventRequest) SetApp(v string) {
	o.App = v
}

// GetContext returns the Context field value if set, zero value otherwise.
func (o *EventRequest) GetContext() map[string]interface{} {
	if o == nil || IsNil(o.Context) {
		var ret map[string]interface{}
		return ret
	}
	return o.Context
}

// GetContextOk returns a tuple with the Context field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *EventRequest) GetContextOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Context) {
		return map[string]interface{}{}, false
	}
	return o.Context, true
}

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

	return false
}

// SetContext gets a reference to the given map[string]interface{} and assigns it to the Context field.
func (o *EventRequest) SetContext(v map[string]interface{}) {
	o.Context = v
}

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

// GetClientIpOk returns a tuple with the ClientIp 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 *EventRequest) GetClientIpOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.ClientIp.Get(), o.ClientIp.IsSet()
}

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

	return false
}

// SetClientIp gets a reference to the given NullableString and assigns it to the ClientIp field.
func (o *EventRequest) SetClientIp(v string) {
	o.ClientIp.Set(&v)
}

// SetClientIpNil sets the value for ClientIp to be an explicit nil
func (o *EventRequest) SetClientIpNil() {
	o.ClientIp.Set(nil)
}

// UnsetClientIp ensures that no value is present for ClientIp, not even an explicit nil
func (o *EventRequest) UnsetClientIp() {
	o.ClientIp.Unset()
}

// GetExpires returns the Expires field value if set, zero value otherwise.
func (o *EventRequest) GetExpires() time.Time {
	if o == nil || IsNil(o.Expires) {
		var ret time.Time
		return ret
	}
	return *o.Expires
}

// GetExpiresOk returns a tuple with the Expires field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *EventRequest) GetExpiresOk() (*time.Time, bool) {
	if o == nil || IsNil(o.Expires) {
		return nil, false
	}
	return o.Expires, true
}

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

	return false
}

// SetExpires gets a reference to the given time.Time and assigns it to the Expires field.
func (o *EventRequest) SetExpires(v time.Time) {
	o.Expires = &v
}

// GetBrand returns the Brand field value if set, zero value otherwise.
func (o *EventRequest) GetBrand() map[string]interface{} {
	if o == nil || IsNil(o.Brand) {
		var ret map[string]interface{}
		return ret
	}
	return o.Brand
}

// GetBrandOk returns a tuple with the Brand field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *EventRequest) GetBrandOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Brand) {
		return map[string]interface{}{}, false
	}
	return o.Brand, true
}

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

	return false
}

// SetBrand gets a reference to the given map[string]interface{} and assigns it to the Brand field.
func (o *EventRequest) SetBrand(v map[string]interface{}) {
	o.Brand = v
}

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

func (o EventRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.User) {
		toSerialize["user"] = o.User
	}
	toSerialize["action"] = o.Action
	toSerialize["app"] = o.App
	if !IsNil(o.Context) {
		toSerialize["context"] = o.Context
	}
	if o.ClientIp.IsSet() {
		toSerialize["client_ip"] = o.ClientIp.Get()
	}
	if !IsNil(o.Expires) {
		toSerialize["expires"] = o.Expires
	}
	if !IsNil(o.Brand) {
		toSerialize["brand"] = o.Brand
	}

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

	return toSerialize, nil
}

func (o *EventRequest) 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{
		"action",
		"app",
	}

	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)
		}
	}

	varEventRequest := _EventRequest{}

	err = json.Unmarshal(data, &varEventRequest)

	if err != nil {
		return err
	}

	*o = EventRequest(varEventRequest)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "user")
		delete(additionalProperties, "action")
		delete(additionalProperties, "app")
		delete(additionalProperties, "context")
		delete(additionalProperties, "client_ip")
		delete(additionalProperties, "expires")
		delete(additionalProperties, "brand")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableEventRequest struct {
	value *EventRequest
	isSet bool
}

func (v NullableEventRequest) Get() *EventRequest {
	return v.value
}

func (v *NullableEventRequest) Set(val *EventRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEventRequest(val *EventRequest) *NullableEventRequest {
	return &NullableEventRequest{value: val, isSet: true}
}

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

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