/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

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

package apiclient

import (
	"encoding/json"
	"fmt"
)

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

// SendWebhookDto struct for SendWebhookDto
type SendWebhookDto struct {
	// The type of event being sent
	EventType WebhookEvent `json:"eventType"`
	// The payload data to send
	Payload map[string]interface{} `json:"payload"`
	// Optional event ID for idempotency
	EventId *string `json:"eventId,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _SendWebhookDto SendWebhookDto

// NewSendWebhookDto instantiates a new SendWebhookDto 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 NewSendWebhookDto(eventType WebhookEvent, payload map[string]interface{}) *SendWebhookDto {
	this := SendWebhookDto{}
	this.EventType = eventType
	this.Payload = payload
	return &this
}

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

// GetEventType returns the EventType field value
func (o *SendWebhookDto) GetEventType() WebhookEvent {
	if o == nil {
		var ret WebhookEvent
		return ret
	}

	return o.EventType
}

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

// SetEventType sets field value
func (o *SendWebhookDto) SetEventType(v WebhookEvent) {
	o.EventType = v
}

// GetPayload returns the Payload field value
func (o *SendWebhookDto) GetPayload() map[string]interface{} {
	if o == nil {
		var ret map[string]interface{}
		return ret
	}

	return o.Payload
}

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

// SetPayload sets field value
func (o *SendWebhookDto) SetPayload(v map[string]interface{}) {
	o.Payload = v
}

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

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

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

	return false
}

// SetEventId gets a reference to the given string and assigns it to the EventId field.
func (o *SendWebhookDto) SetEventId(v string) {
	o.EventId = &v
}

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

func (o SendWebhookDto) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["eventType"] = o.EventType
	toSerialize["payload"] = o.Payload
	if !IsNil(o.EventId) {
		toSerialize["eventId"] = o.EventId
	}

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

	return toSerialize, nil
}

func (o *SendWebhookDto) 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{
		"eventType",
		"payload",
	}

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

	varSendWebhookDto := _SendWebhookDto{}

	err = json.Unmarshal(data, &varSendWebhookDto)

	if err != nil {
		return err
	}

	*o = SendWebhookDto(varSendWebhookDto)

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

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

	return err
}

type NullableSendWebhookDto struct {
	value *SendWebhookDto
	isSet bool
}

func (v NullableSendWebhookDto) Get() *SendWebhookDto {
	return v.value
}

func (v *NullableSendWebhookDto) Set(val *SendWebhookDto) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSendWebhookDto(val *SendWebhookDto) *NullableSendWebhookDto {
	return &NullableSendWebhookDto{value: val, isSet: true}
}

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

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


