/*
Libre Graph API

Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.

API version: v1.0.8
*/

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

package libregraph

import (
	"encoding/json"
	"bytes"
	"fmt"
)

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

// OdataErrorMain struct for OdataErrorMain
type OdataErrorMain struct {
	Code string `json:"code"`
	Message string `json:"message"`
	Target *string `json:"target,omitempty"`
	Details []OdataErrorDetail `json:"details,omitempty"`
	// The structure of this object is service-specific
	Innererror map[string]interface{} `json:"innererror,omitempty"`
}

type _OdataErrorMain OdataErrorMain

// NewOdataErrorMain instantiates a new OdataErrorMain 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 NewOdataErrorMain(code string, message string) *OdataErrorMain {
	this := OdataErrorMain{}
	this.Code = code
	this.Message = message
	return &this
}

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

// GetCode returns the Code field value
func (o *OdataErrorMain) GetCode() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Code
}

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

// SetCode sets field value
func (o *OdataErrorMain) SetCode(v string) {
	o.Code = v
}

// GetMessage returns the Message field value
func (o *OdataErrorMain) GetMessage() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Message
}

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

// SetMessage sets field value
func (o *OdataErrorMain) SetMessage(v string) {
	o.Message = v
}

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

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

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

	return false
}

// SetTarget gets a reference to the given string and assigns it to the Target field.
func (o *OdataErrorMain) SetTarget(v string) {
	o.Target = &v
}

// GetDetails returns the Details field value if set, zero value otherwise.
func (o *OdataErrorMain) GetDetails() []OdataErrorDetail {
	if o == nil || IsNil(o.Details) {
		var ret []OdataErrorDetail
		return ret
	}
	return o.Details
}

// GetDetailsOk returns a tuple with the Details field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *OdataErrorMain) GetDetailsOk() ([]OdataErrorDetail, bool) {
	if o == nil || IsNil(o.Details) {
		return nil, false
	}
	return o.Details, true
}

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

	return false
}

// SetDetails gets a reference to the given []OdataErrorDetail and assigns it to the Details field.
func (o *OdataErrorMain) SetDetails(v []OdataErrorDetail) {
	o.Details = v
}

// GetInnererror returns the Innererror field value if set, zero value otherwise.
func (o *OdataErrorMain) GetInnererror() map[string]interface{} {
	if o == nil || IsNil(o.Innererror) {
		var ret map[string]interface{}
		return ret
	}
	return o.Innererror
}

// GetInnererrorOk returns a tuple with the Innererror field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *OdataErrorMain) GetInnererrorOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.Innererror) {
		return map[string]interface{}{}, false
	}
	return o.Innererror, true
}

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

	return false
}

// SetInnererror gets a reference to the given map[string]interface{} and assigns it to the Innererror field.
func (o *OdataErrorMain) SetInnererror(v map[string]interface{}) {
	o.Innererror = v
}

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

func (o OdataErrorMain) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["code"] = o.Code
	toSerialize["message"] = o.Message
	if !IsNil(o.Target) {
		toSerialize["target"] = o.Target
	}
	if !IsNil(o.Details) {
		toSerialize["details"] = o.Details
	}
	if !IsNil(o.Innererror) {
		toSerialize["innererror"] = o.Innererror
	}
	return toSerialize, nil
}

func (o *OdataErrorMain) 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{
		"code",
		"message",
	}

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

	varOdataErrorMain := _OdataErrorMain{}

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

	if err != nil {
		return err
	}

	*o = OdataErrorMain(varOdataErrorMain)

	return err
}

type NullableOdataErrorMain struct {
	value *OdataErrorMain
	isSet bool
}

func (v NullableOdataErrorMain) Get() *OdataErrorMain {
	return v.value
}

func (v *NullableOdataErrorMain) Set(val *OdataErrorMain) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableOdataErrorMain(val *OdataErrorMain) *NullableOdataErrorMain {
	return &NullableOdataErrorMain{value: val, isSet: true}
}

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

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


