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

// GetStatisticsInternal200Response struct for GetStatisticsInternal200Response
type GetStatisticsInternal200Response struct {
	DevicesByStatus DeviceStatusStatistics `json:"devices_by_status"`
	AdditionalProperties map[string]interface{}
}

type _GetStatisticsInternal200Response GetStatisticsInternal200Response

// NewGetStatisticsInternal200Response instantiates a new GetStatisticsInternal200Response 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 NewGetStatisticsInternal200Response(devicesByStatus DeviceStatusStatistics) *GetStatisticsInternal200Response {
	this := GetStatisticsInternal200Response{}
	this.DevicesByStatus = devicesByStatus
	return &this
}

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

// GetDevicesByStatus returns the DevicesByStatus field value
func (o *GetStatisticsInternal200Response) GetDevicesByStatus() DeviceStatusStatistics {
	if o == nil {
		var ret DeviceStatusStatistics
		return ret
	}

	return o.DevicesByStatus
}

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

// SetDevicesByStatus sets field value
func (o *GetStatisticsInternal200Response) SetDevicesByStatus(v DeviceStatusStatistics) {
	o.DevicesByStatus = v
}

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

func (o GetStatisticsInternal200Response) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["devices_by_status"] = o.DevicesByStatus

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

	return toSerialize, nil
}

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

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

	varGetStatisticsInternal200Response := _GetStatisticsInternal200Response{}

	err = json.Unmarshal(data, &varGetStatisticsInternal200Response)

	if err != nil {
		return err
	}

	*o = GetStatisticsInternal200Response(varGetStatisticsInternal200Response)

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

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

	return err
}

type NullableGetStatisticsInternal200Response struct {
	value *GetStatisticsInternal200Response
	isSet bool
}

func (v NullableGetStatisticsInternal200Response) Get() *GetStatisticsInternal200Response {
	return v.value
}

func (v *NullableGetStatisticsInternal200Response) Set(val *GetStatisticsInternal200Response) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableGetStatisticsInternal200Response(val *GetStatisticsInternal200Response) *NullableGetStatisticsInternal200Response {
	return &NullableGetStatisticsInternal200Response{value: val, isSet: true}
}

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

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


