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

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

// TradeOrder struct for TradeOrder
type TradeOrder struct {
	Id *string `json:"id,omitempty"`
	// Ticker-like name of the instrument. For monetary instruments, a currency pair is used.
	Instrument  *string                `json:"instrument,omitempty"`
	Side        *TradeOrderSide        `json:"side,omitempty"`
	Type        *TradeOrderType        `json:"type,omitempty"`
	TimeInForce *TradeOrderTimeInForce `json:"timeInForce,omitempty"`
	Status      *TradeOrderStatus      `json:"status,omitempty"`
	Price       *float64               `json:"price,omitempty"`
	Amount      *float64               `json:"amount,omitempty"`
	OpenAmount  *float64               `json:"openAmount,omitempty"`
	Created     *time.Time             `json:"created,omitempty"`
}

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

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

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

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

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

	return false
}

// SetId gets a reference to the given string and assigns it to the Id field.
func (o *TradeOrder) SetId(v string) {
	o.Id = &v
}

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

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

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

	return false
}

// SetInstrument gets a reference to the given string and assigns it to the Instrument field.
func (o *TradeOrder) SetInstrument(v string) {
	o.Instrument = &v
}

// GetSide returns the Side field value if set, zero value otherwise.
func (o *TradeOrder) GetSide() TradeOrderSide {
	if o == nil || IsNil(o.Side) {
		var ret TradeOrderSide
		return ret
	}
	return *o.Side
}

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

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

	return false
}

// SetSide gets a reference to the given TradeOrderSide and assigns it to the Side field.
func (o *TradeOrder) SetSide(v TradeOrderSide) {
	o.Side = &v
}

// GetType returns the Type field value if set, zero value otherwise.
func (o *TradeOrder) GetType() TradeOrderType {
	if o == nil || IsNil(o.Type) {
		var ret TradeOrderType
		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 *TradeOrder) GetTypeOk() (*TradeOrderType, bool) {
	if o == nil || IsNil(o.Type) {
		return nil, false
	}
	return o.Type, true
}

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

	return false
}

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

// GetTimeInForce returns the TimeInForce field value if set, zero value otherwise.
func (o *TradeOrder) GetTimeInForce() TradeOrderTimeInForce {
	if o == nil || IsNil(o.TimeInForce) {
		var ret TradeOrderTimeInForce
		return ret
	}
	return *o.TimeInForce
}

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

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

	return false
}

// SetTimeInForce gets a reference to the given TradeOrderTimeInForce and assigns it to the TimeInForce field.
func (o *TradeOrder) SetTimeInForce(v TradeOrderTimeInForce) {
	o.TimeInForce = &v
}

// GetStatus returns the Status field value if set, zero value otherwise.
func (o *TradeOrder) GetStatus() TradeOrderStatus {
	if o == nil || IsNil(o.Status) {
		var ret TradeOrderStatus
		return ret
	}
	return *o.Status
}

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

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

	return false
}

// SetStatus gets a reference to the given TradeOrderStatus and assigns it to the Status field.
func (o *TradeOrder) SetStatus(v TradeOrderStatus) {
	o.Status = &v
}

// GetPrice returns the Price field value if set, zero value otherwise.
func (o *TradeOrder) GetPrice() float64 {
	if o == nil || IsNil(o.Price) {
		var ret float64
		return ret
	}
	return *o.Price
}

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

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

	return false
}

// SetPrice gets a reference to the given float64 and assigns it to the Price field.
func (o *TradeOrder) SetPrice(v float64) {
	o.Price = &v
}

// GetAmount returns the Amount field value if set, zero value otherwise.
func (o *TradeOrder) GetAmount() float64 {
	if o == nil || IsNil(o.Amount) {
		var ret float64
		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 *TradeOrder) GetAmountOk() (*float64, bool) {
	if o == nil || IsNil(o.Amount) {
		return nil, false
	}
	return o.Amount, true
}

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

	return false
}

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

// GetOpenAmount returns the OpenAmount field value if set, zero value otherwise.
func (o *TradeOrder) GetOpenAmount() float64 {
	if o == nil || IsNil(o.OpenAmount) {
		var ret float64
		return ret
	}
	return *o.OpenAmount
}

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

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

	return false
}

// SetOpenAmount gets a reference to the given float64 and assigns it to the OpenAmount field.
func (o *TradeOrder) SetOpenAmount(v float64) {
	o.OpenAmount = &v
}

// GetCreated returns the Created field value if set, zero value otherwise.
func (o *TradeOrder) GetCreated() time.Time {
	if o == nil || IsNil(o.Created) {
		var ret time.Time
		return ret
	}
	return *o.Created
}

// GetCreatedOk returns a tuple with the Created field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TradeOrder) GetCreatedOk() (*time.Time, bool) {
	if o == nil || IsNil(o.Created) {
		return nil, false
	}
	return o.Created, true
}

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

	return false
}

// SetCreated gets a reference to the given time.Time and assigns it to the Created field.
func (o *TradeOrder) SetCreated(v time.Time) {
	o.Created = &v
}

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

func (o TradeOrder) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Id) {
		toSerialize["id"] = o.Id
	}
	if !IsNil(o.Instrument) {
		toSerialize["instrument"] = o.Instrument
	}
	if !IsNil(o.Side) {
		toSerialize["side"] = o.Side
	}
	if !IsNil(o.Type) {
		toSerialize["type"] = o.Type
	}
	if !IsNil(o.TimeInForce) {
		toSerialize["timeInForce"] = o.TimeInForce
	}
	if !IsNil(o.Status) {
		toSerialize["status"] = o.Status
	}
	if !IsNil(o.Price) {
		toSerialize["price"] = o.Price
	}
	if !IsNil(o.Amount) {
		toSerialize["amount"] = o.Amount
	}
	if !IsNil(o.OpenAmount) {
		toSerialize["openAmount"] = o.OpenAmount
	}
	if !IsNil(o.Created) {
		toSerialize["created"] = o.Created
	}
	return toSerialize, nil
}

type NullableTradeOrder struct {
	value *TradeOrder
	isSet bool
}

func (v NullableTradeOrder) Get() *TradeOrder {
	return v.value
}

func (v *NullableTradeOrder) Set(val *TradeOrder) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTradeOrder(val *TradeOrder) *NullableTradeOrder {
	return &NullableTradeOrder{value: val, isSet: true}
}

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

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