/*
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"
	"bytes"
	"fmt"
)

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

// SortCriteria Sort criteria definition
type SortCriteria struct {
	// Attribute name.
	Attribute string `json:"attribute"`
	Scope Scope `json:"scope"`
	// Sort order.
	Order string `json:"order"`
}

type _SortCriteria SortCriteria

// NewSortCriteria instantiates a new SortCriteria 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 NewSortCriteria(attribute string, scope Scope, order string) *SortCriteria {
	this := SortCriteria{}
	this.Attribute = attribute
	this.Scope = scope
	this.Order = order
	return &this
}

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

// GetAttribute returns the Attribute field value
func (o *SortCriteria) GetAttribute() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Attribute
}

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

// SetAttribute sets field value
func (o *SortCriteria) SetAttribute(v string) {
	o.Attribute = v
}

// GetScope returns the Scope field value
func (o *SortCriteria) GetScope() Scope {
	if o == nil {
		var ret Scope
		return ret
	}

	return o.Scope
}

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

// SetScope sets field value
func (o *SortCriteria) SetScope(v Scope) {
	o.Scope = v
}

// GetOrder returns the Order field value
func (o *SortCriteria) GetOrder() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Order
}

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

// SetOrder sets field value
func (o *SortCriteria) SetOrder(v string) {
	o.Order = v
}

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

func (o SortCriteria) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["attribute"] = o.Attribute
	toSerialize["scope"] = o.Scope
	toSerialize["order"] = o.Order
	return toSerialize, nil
}

func (o *SortCriteria) 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{
		"attribute",
		"scope",
		"order",
	}

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

	varSortCriteria := _SortCriteria{}

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

	if err != nil {
		return err
	}

	*o = SortCriteria(varSortCriteria)

	return err
}

type NullableSortCriteria struct {
	value *SortCriteria
	isSet bool
}

func (v NullableSortCriteria) Get() *SortCriteria {
	return v.value
}

func (v *NullableSortCriteria) Set(val *SortCriteria) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSortCriteria(val *SortCriteria) *NullableSortCriteria {
	return &NullableSortCriteria{value: val, isSet: true}
}

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

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


