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

// EventDeliveryStatusesInner struct for EventDeliveryStatusesInner
type EventDeliveryStatusesInner struct {
	// The ID of the integration the status belongs.
	IntegrationId string `json:"integration_id"`
	// Whether the event hook was executed successfully.
	Success bool `json:"success"`
	// The (HTTP) status code of the hook.
	StatusCode *int32 `json:"status_code,omitempty"`
	// An error message if the hook failed.
	Error *string `json:"error,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _EventDeliveryStatusesInner EventDeliveryStatusesInner

// NewEventDeliveryStatusesInner instantiates a new EventDeliveryStatusesInner 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 NewEventDeliveryStatusesInner(integrationId string, success bool) *EventDeliveryStatusesInner {
	this := EventDeliveryStatusesInner{}
	this.IntegrationId = integrationId
	this.Success = success
	return &this
}

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

// GetIntegrationId returns the IntegrationId field value
func (o *EventDeliveryStatusesInner) GetIntegrationId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.IntegrationId
}

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

// SetIntegrationId sets field value
func (o *EventDeliveryStatusesInner) SetIntegrationId(v string) {
	o.IntegrationId = v
}

// GetSuccess returns the Success field value
func (o *EventDeliveryStatusesInner) GetSuccess() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.Success
}

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

// SetSuccess sets field value
func (o *EventDeliveryStatusesInner) SetSuccess(v bool) {
	o.Success = v
}

// GetStatusCode returns the StatusCode field value if set, zero value otherwise.
func (o *EventDeliveryStatusesInner) GetStatusCode() int32 {
	if o == nil || IsNil(o.StatusCode) {
		var ret int32
		return ret
	}
	return *o.StatusCode
}

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

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

	return false
}

// SetStatusCode gets a reference to the given int32 and assigns it to the StatusCode field.
func (o *EventDeliveryStatusesInner) SetStatusCode(v int32) {
	o.StatusCode = &v
}

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

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

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

	return false
}

// SetError gets a reference to the given string and assigns it to the Error field.
func (o *EventDeliveryStatusesInner) SetError(v string) {
	o.Error = &v
}

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

func (o EventDeliveryStatusesInner) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["integration_id"] = o.IntegrationId
	toSerialize["success"] = o.Success
	if !IsNil(o.StatusCode) {
		toSerialize["status_code"] = o.StatusCode
	}
	if !IsNil(o.Error) {
		toSerialize["error"] = o.Error
	}

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

	return toSerialize, nil
}

func (o *EventDeliveryStatusesInner) 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{
		"integration_id",
		"success",
	}

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

	varEventDeliveryStatusesInner := _EventDeliveryStatusesInner{}

	err = json.Unmarshal(data, &varEventDeliveryStatusesInner)

	if err != nil {
		return err
	}

	*o = EventDeliveryStatusesInner(varEventDeliveryStatusesInner)

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

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

	return err
}

type NullableEventDeliveryStatusesInner struct {
	value *EventDeliveryStatusesInner
	isSet bool
}

func (v NullableEventDeliveryStatusesInner) Get() *EventDeliveryStatusesInner {
	return v.value
}

func (v *NullableEventDeliveryStatusesInner) Set(val *EventDeliveryStatusesInner) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableEventDeliveryStatusesInner(val *EventDeliveryStatusesInner) *NullableEventDeliveryStatusesInner {
	return &NullableEventDeliveryStatusesInner{value: val, isSet: true}
}

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

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


