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

// HTTPHttp struct for HTTPHttp
type HTTPHttp struct {
	// The destination URL for the webhook. The webhook will send POST requests with event details to this target URL.
	Url string `json:"url"`
	// An optional secret used to verify the integrity of the payload. The string must be in hexadecimal format.
	Secret *string `json:"secret,omitempty" validate:"regexp=[0-9a-f]{1,64}"`
	AdditionalProperties map[string]interface{}
}

type _HTTPHttp HTTPHttp

// NewHTTPHttp instantiates a new HTTPHttp 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 NewHTTPHttp(url string) *HTTPHttp {
	this := HTTPHttp{}
	this.Url = url
	return &this
}

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

// GetUrl returns the Url field value
func (o *HTTPHttp) GetUrl() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Url
}

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

// SetUrl sets field value
func (o *HTTPHttp) SetUrl(v string) {
	o.Url = v
}

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

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

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

	return false
}

// SetSecret gets a reference to the given string and assigns it to the Secret field.
func (o *HTTPHttp) SetSecret(v string) {
	o.Secret = &v
}

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

func (o HTTPHttp) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["url"] = o.Url
	if !IsNil(o.Secret) {
		toSerialize["secret"] = o.Secret
	}

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

	return toSerialize, nil
}

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

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

	varHTTPHttp := _HTTPHttp{}

	err = json.Unmarshal(data, &varHTTPHttp)

	if err != nil {
		return err
	}

	*o = HTTPHttp(varHTTPHttp)

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

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

	return err
}

type NullableHTTPHttp struct {
	value *HTTPHttp
	isSet bool
}

func (v NullableHTTPHttp) Get() *HTTPHttp {
	return v.value
}

func (v *NullableHTTPHttp) Set(val *HTTPHttp) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableHTTPHttp(val *HTTPHttp) *NullableHTTPHttp {
	return &NullableHTTPHttp{value: val, isSet: true}
}

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

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


