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

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

// UserNew New user descriptor.
type UserNew struct {
	// A unique email address. Non-ascii characters are invalid.
	Email string `json:"email"`
	// Password.
	Password string `json:"password"`
}

type _UserNew UserNew

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

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

// GetEmail returns the Email field value
func (o *UserNew) 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 *UserNew) GetEmailOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Email, true
}

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

// GetPassword returns the Password field value
func (o *UserNew) 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 *UserNew) GetPasswordOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Password, true
}

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

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

func (o UserNew) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["email"] = o.Email
	toSerialize["password"] = o.Password
	return toSerialize, nil
}

func (o *UserNew) 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)
		}
	}

	varUserNew := _UserNew{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varUserNew)

	if err != nil {
		return err
	}

	*o = UserNew(varUserNew)

	return err
}

type NullableUserNew struct {
	value *UserNew
	isSet bool
}

func (v NullableUserNew) Get() *UserNew {
	return v.value
}

func (v *NullableUserNew) Set(val *UserNew) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUserNew(val *UserNew) *NullableUserNew {
	return &NullableUserNew{value: val, isSet: true}
}

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

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


