/*
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 LastDeviceDeploymentsStatuses type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &LastDeviceDeploymentsStatuses{}

// LastDeviceDeploymentsStatuses struct for LastDeviceDeploymentsStatuses
type LastDeviceDeploymentsStatuses struct {
	DeviceDeploymentLastStatuses []LastDeviceDeployment `json:"device_deployment_last_statuses"`
	AdditionalProperties map[string]interface{}
}

type _LastDeviceDeploymentsStatuses LastDeviceDeploymentsStatuses

// NewLastDeviceDeploymentsStatuses instantiates a new LastDeviceDeploymentsStatuses 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 NewLastDeviceDeploymentsStatuses(deviceDeploymentLastStatuses []LastDeviceDeployment) *LastDeviceDeploymentsStatuses {
	this := LastDeviceDeploymentsStatuses{}
	this.DeviceDeploymentLastStatuses = deviceDeploymentLastStatuses
	return &this
}

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

// GetDeviceDeploymentLastStatuses returns the DeviceDeploymentLastStatuses field value
func (o *LastDeviceDeploymentsStatuses) GetDeviceDeploymentLastStatuses() []LastDeviceDeployment {
	if o == nil {
		var ret []LastDeviceDeployment
		return ret
	}

	return o.DeviceDeploymentLastStatuses
}

// GetDeviceDeploymentLastStatusesOk returns a tuple with the DeviceDeploymentLastStatuses field value
// and a boolean to check if the value has been set.
func (o *LastDeviceDeploymentsStatuses) GetDeviceDeploymentLastStatusesOk() ([]LastDeviceDeployment, bool) {
	if o == nil {
		return nil, false
	}
	return o.DeviceDeploymentLastStatuses, true
}

// SetDeviceDeploymentLastStatuses sets field value
func (o *LastDeviceDeploymentsStatuses) SetDeviceDeploymentLastStatuses(v []LastDeviceDeployment) {
	o.DeviceDeploymentLastStatuses = v
}

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

func (o LastDeviceDeploymentsStatuses) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["device_deployment_last_statuses"] = o.DeviceDeploymentLastStatuses

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

	return toSerialize, nil
}

func (o *LastDeviceDeploymentsStatuses) 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{
		"device_deployment_last_statuses",
	}

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

	varLastDeviceDeploymentsStatuses := _LastDeviceDeploymentsStatuses{}

	err = json.Unmarshal(data, &varLastDeviceDeploymentsStatuses)

	if err != nil {
		return err
	}

	*o = LastDeviceDeploymentsStatuses(varLastDeviceDeploymentsStatuses)

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

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

	return err
}

type NullableLastDeviceDeploymentsStatuses struct {
	value *LastDeviceDeploymentsStatuses
	isSet bool
}

func (v NullableLastDeviceDeploymentsStatuses) Get() *LastDeviceDeploymentsStatuses {
	return v.value
}

func (v *NullableLastDeviceDeploymentsStatuses) Set(val *LastDeviceDeploymentsStatuses) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableLastDeviceDeploymentsStatuses(val *LastDeviceDeploymentsStatuses) *NullableLastDeviceDeploymentsStatuses {
	return &NullableLastDeviceDeploymentsStatuses{value: val, isSet: true}
}

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

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


