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

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

// IdentityData Device identity attributes, in the form of a JSON structure. The attributes are completely vendor-specific, the provided ones are just an example. In reference implementation structure contains vendor-selected fields, such as MACs, serial numbers, etc.
type IdentityData struct {
	// MAC address.
	Mac *string `json:"mac,omitempty"`
	// Stock keeping unit.
	Sku *string `json:"sku,omitempty"`
	// Serial number.
	Sn *string `json:"sn,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _IdentityData IdentityData

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

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

// GetMac returns the Mac field value if set, zero value otherwise.
func (o *IdentityData) GetMac() string {
	if o == nil || IsNil(o.Mac) {
		var ret string
		return ret
	}
	return *o.Mac
}

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

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

	return false
}

// SetMac gets a reference to the given string and assigns it to the Mac field.
func (o *IdentityData) SetMac(v string) {
	o.Mac = &v
}

// GetSku returns the Sku field value if set, zero value otherwise.
func (o *IdentityData) GetSku() string {
	if o == nil || IsNil(o.Sku) {
		var ret string
		return ret
	}
	return *o.Sku
}

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

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

	return false
}

// SetSku gets a reference to the given string and assigns it to the Sku field.
func (o *IdentityData) SetSku(v string) {
	o.Sku = &v
}

// GetSn returns the Sn field value if set, zero value otherwise.
func (o *IdentityData) GetSn() string {
	if o == nil || IsNil(o.Sn) {
		var ret string
		return ret
	}
	return *o.Sn
}

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

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

	return false
}

// SetSn gets a reference to the given string and assigns it to the Sn field.
func (o *IdentityData) SetSn(v string) {
	o.Sn = &v
}

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

func (o IdentityData) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Mac) {
		toSerialize["mac"] = o.Mac
	}
	if !IsNil(o.Sku) {
		toSerialize["sku"] = o.Sku
	}
	if !IsNil(o.Sn) {
		toSerialize["sn"] = o.Sn
	}

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

	return toSerialize, nil
}

func (o *IdentityData) UnmarshalJSON(data []byte) (err error) {
	varIdentityData := _IdentityData{}

	err = json.Unmarshal(data, &varIdentityData)

	if err != nil {
		return err
	}

	*o = IdentityData(varIdentityData)

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

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

	return err
}

type NullableIdentityData struct {
	value *IdentityData
	isSet bool
}

func (v NullableIdentityData) Get() *IdentityData {
	return v.value
}

func (v *NullableIdentityData) Set(val *IdentityData) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableIdentityData(val *IdentityData) *NullableIdentityData {
	return &NullableIdentityData{value: val, isSet: true}
}

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

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


