/*
Adyen Checkout API

API version: 71
*/

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

package checkout

import (
	"encoding/json"

	"github.com/adyen/adyen-go-api-library/v21/src/common"
)

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

// DeliveryMethod struct for DeliveryMethod
type DeliveryMethod struct {
	Amount *Amount `json:"amount,omitempty"`
	// The name of the delivery method as shown to the shopper.
	Description *string `json:"description,omitempty"`
	// The reference of the delivery method.
	Reference *string `json:"reference,omitempty"`
	// If you display the PayPal lightbox with delivery methods, set to **true** for the delivery method that is selected. Only one delivery method can be selected at a time.
	Selected *bool `json:"selected,omitempty"`
	// The type of the delivery method.
	Type *string `json:"type,omitempty"`
}

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

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

// GetAmount returns the Amount field value if set, zero value otherwise.
func (o *DeliveryMethod) GetAmount() Amount {
	if o == nil || common.IsNil(o.Amount) {
		var ret Amount
		return ret
	}
	return *o.Amount
}

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

// HasAmount returns a boolean if a field has been set.
func (o *DeliveryMethod) HasAmount() bool {
	if o != nil && !common.IsNil(o.Amount) {
		return true
	}

	return false
}

// SetAmount gets a reference to the given Amount and assigns it to the Amount field.
func (o *DeliveryMethod) SetAmount(v Amount) {
	o.Amount = &v
}

// GetDescription returns the Description field value if set, zero value otherwise.
func (o *DeliveryMethod) GetDescription() string {
	if o == nil || common.IsNil(o.Description) {
		var ret string
		return ret
	}
	return *o.Description
}

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

// HasDescription returns a boolean if a field has been set.
func (o *DeliveryMethod) HasDescription() bool {
	if o != nil && !common.IsNil(o.Description) {
		return true
	}

	return false
}

// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *DeliveryMethod) SetDescription(v string) {
	o.Description = &v
}

// GetReference returns the Reference field value if set, zero value otherwise.
func (o *DeliveryMethod) GetReference() string {
	if o == nil || common.IsNil(o.Reference) {
		var ret string
		return ret
	}
	return *o.Reference
}

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

// HasReference returns a boolean if a field has been set.
func (o *DeliveryMethod) HasReference() bool {
	if o != nil && !common.IsNil(o.Reference) {
		return true
	}

	return false
}

// SetReference gets a reference to the given string and assigns it to the Reference field.
func (o *DeliveryMethod) SetReference(v string) {
	o.Reference = &v
}

// GetSelected returns the Selected field value if set, zero value otherwise.
func (o *DeliveryMethod) GetSelected() bool {
	if o == nil || common.IsNil(o.Selected) {
		var ret bool
		return ret
	}
	return *o.Selected
}

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

// HasSelected returns a boolean if a field has been set.
func (o *DeliveryMethod) HasSelected() bool {
	if o != nil && !common.IsNil(o.Selected) {
		return true
	}

	return false
}

// SetSelected gets a reference to the given bool and assigns it to the Selected field.
func (o *DeliveryMethod) SetSelected(v bool) {
	o.Selected = &v
}

// GetType returns the Type field value if set, zero value otherwise.
func (o *DeliveryMethod) GetType() string {
	if o == nil || common.IsNil(o.Type) {
		var ret string
		return ret
	}
	return *o.Type
}

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

// HasType returns a boolean if a field has been set.
func (o *DeliveryMethod) HasType() bool {
	if o != nil && !common.IsNil(o.Type) {
		return true
	}

	return false
}

// SetType gets a reference to the given string and assigns it to the Type field.
func (o *DeliveryMethod) SetType(v string) {
	o.Type = &v
}

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

func (o DeliveryMethod) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !common.IsNil(o.Amount) {
		toSerialize["amount"] = o.Amount
	}
	if !common.IsNil(o.Description) {
		toSerialize["description"] = o.Description
	}
	if !common.IsNil(o.Reference) {
		toSerialize["reference"] = o.Reference
	}
	if !common.IsNil(o.Selected) {
		toSerialize["selected"] = o.Selected
	}
	if !common.IsNil(o.Type) {
		toSerialize["type"] = o.Type
	}
	return toSerialize, nil
}

type NullableDeliveryMethod struct {
	value *DeliveryMethod
	isSet bool
}

func (v NullableDeliveryMethod) Get() *DeliveryMethod {
	return v.value
}

func (v *NullableDeliveryMethod) Set(val *DeliveryMethod) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableDeliveryMethod(val *DeliveryMethod) *NullableDeliveryMethod {
	return &NullableDeliveryMethod{value: val, isSet: true}
}

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

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

func (o *DeliveryMethod) isValidType() bool {
	var allowedEnumValues = []string{"Shipping"}
	for _, allowed := range allowedEnumValues {
		if o.GetType() == allowed {
			return true
		}
	}
	return false
}
