/*
DM OpenAPI DOC

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 6.0.0
*/

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

package dm

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

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

// UpdateTaskRequest struct for UpdateTaskRequest
type UpdateTaskRequest struct {
	Task Task `json:"task"`
}

type _UpdateTaskRequest UpdateTaskRequest

// NewUpdateTaskRequest instantiates a new UpdateTaskRequest 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 NewUpdateTaskRequest(task Task) *UpdateTaskRequest {
	this := UpdateTaskRequest{}
	this.Task = task
	return &this
}

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

// GetTask returns the Task field value
func (o *UpdateTaskRequest) GetTask() Task {
	if o == nil {
		var ret Task
		return ret
	}

	return o.Task
}

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

// SetTask sets field value
func (o *UpdateTaskRequest) SetTask(v Task) {
	o.Task = v
}

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

func (o UpdateTaskRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["task"] = o.Task
	return toSerialize, nil
}

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

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

	varUpdateTaskRequest := _UpdateTaskRequest{}

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

	if err != nil {
		return err
	}

	*o = UpdateTaskRequest(varUpdateTaskRequest)

	return err
}

type NullableUpdateTaskRequest struct {
	value *UpdateTaskRequest
	isSet bool
}

func (v NullableUpdateTaskRequest) Get() *UpdateTaskRequest {
	return v.value
}

func (v *NullableUpdateTaskRequest) Set(val *UpdateTaskRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUpdateTaskRequest(val *UpdateTaskRequest) *NullableUpdateTaskRequest {
	return &NullableUpdateTaskRequest{value: val, isSet: true}
}

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

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