/*
OPEN OUTCRY API

# Introduction This API is documented in **OpenAPI 3.0 format**.  This API the following operations: * Retrieve a list of available instruments * Retrieve a list of executed trades  # Basics * API calls have to be secured with HTTPS. * All data has to be submitted UTF-8 encoded. * The reply is sent JSON encoded.

API version: 1.0.0
*/

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

package api

import (
	"encoding/json"
)

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

// OrderBook struct for OrderBook
type OrderBook struct {
	Sell []PriceVolume `json:"sell,omitempty"`
	Buy  interface{}   `json:"buy,omitempty"`
}

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

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

// GetSell returns the Sell field value if set, zero value otherwise.
func (o *OrderBook) GetSell() []PriceVolume {
	if o == nil || IsNil(o.Sell) {
		var ret []PriceVolume
		return ret
	}
	return o.Sell
}

// GetSellOk returns a tuple with the Sell field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *OrderBook) GetSellOk() ([]PriceVolume, bool) {
	if o == nil || IsNil(o.Sell) {
		return nil, false
	}
	return o.Sell, true
}

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

	return false
}

// SetSell gets a reference to the given []PriceVolume and assigns it to the Sell field.
func (o *OrderBook) SetSell(v []PriceVolume) {
	o.Sell = v
}

// GetBuy returns the Buy field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *OrderBook) GetBuy() interface{} {
	if o == nil {
		var ret interface{}
		return ret
	}
	return o.Buy
}

// GetBuyOk returns a tuple with the Buy field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *OrderBook) GetBuyOk() (*interface{}, bool) {
	if o == nil || IsNil(o.Buy) {
		return nil, false
	}
	return &o.Buy, true
}

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

	return false
}

// SetBuy gets a reference to the given interface{} and assigns it to the Buy field.
func (o *OrderBook) SetBuy(v interface{}) {
	o.Buy = v
}

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

func (o OrderBook) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Sell) {
		toSerialize["sell"] = o.Sell
	}
	if o.Buy != nil {
		toSerialize["buy"] = o.Buy
	}
	return toSerialize, nil
}

type NullableOrderBook struct {
	value *OrderBook
	isSet bool
}

func (v NullableOrderBook) Get() *OrderBook {
	return v.value
}

func (v *NullableOrderBook) Set(val *OrderBook) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableOrderBook(val *OrderBook) *NullableOrderBook {
	return &NullableOrderBook{value: val, isSet: true}
}

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

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