/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

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

package client

import (
	"encoding/json"
	"fmt"
)

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

// UserNewInternal New user descriptor.
type UserNewInternal struct {
	// A unique email address. Non-ascii characters are invalid.
	Email string `json:"email"`
	// Password.
	Password string `json:"password"`
	// This paramter is deprecated _since Thu Jul 6 2023_, the propagation of user information to tenantadm is disabled permanently. 
	Propagate *bool `json:"propagate,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _UserNewInternal UserNewInternal

// NewUserNewInternal instantiates a new UserNewInternal 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 NewUserNewInternal(email string, password string) *UserNewInternal {
	this := UserNewInternal{}
	this.Email = email
	this.Password = password
	return &this
}

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

// GetEmail returns the Email field value
func (o *UserNewInternal) GetEmail() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Email
}

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

// SetEmail sets field value
func (o *UserNewInternal) SetEmail(v string) {
	o.Email = v
}

// GetPassword returns the Password field value
func (o *UserNewInternal) GetPassword() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Password
}

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

// SetPassword sets field value
func (o *UserNewInternal) SetPassword(v string) {
	o.Password = v
}

// GetPropagate returns the Propagate field value if set, zero value otherwise.
func (o *UserNewInternal) GetPropagate() bool {
	if o == nil || IsNil(o.Propagate) {
		var ret bool
		return ret
	}
	return *o.Propagate
}

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

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

	return false
}

// SetPropagate gets a reference to the given bool and assigns it to the Propagate field.
func (o *UserNewInternal) SetPropagate(v bool) {
	o.Propagate = &v
}

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

func (o UserNewInternal) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["email"] = o.Email
	toSerialize["password"] = o.Password
	if !IsNil(o.Propagate) {
		toSerialize["propagate"] = o.Propagate
	}

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

	return toSerialize, nil
}

func (o *UserNewInternal) 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{
		"email",
		"password",
	}

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

	varUserNewInternal := _UserNewInternal{}

	err = json.Unmarshal(data, &varUserNewInternal)

	if err != nil {
		return err
	}

	*o = UserNewInternal(varUserNewInternal)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "email")
		delete(additionalProperties, "password")
		delete(additionalProperties, "propagate")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableUserNewInternal struct {
	value *UserNewInternal
	isSet bool
}

func (v NullableUserNewInternal) Get() *UserNewInternal {
	return v.value
}

func (v *NullableUserNewInternal) Set(val *UserNewInternal) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUserNewInternal(val *UserNewInternal) *NullableUserNewInternal {
	return &NullableUserNewInternal{value: val, isSet: true}
}

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

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


