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

// TradeOrderStatus the model 'TradeOrderStatus'
type TradeOrderStatus string

// List of TradeOrderStatus
const (
	OPEN                TradeOrderStatus = "OPEN"
	REJECTED            TradeOrderStatus = "REJECTED"
	CANCELLED           TradeOrderStatus = "CANCELLED"
	PARTIALLY_CANCELLED TradeOrderStatus = "PARTIALLY_CANCELLED"
	PARTIALLY_REJECTED  TradeOrderStatus = "PARTIALLY_REJECTED"
	FILLED              TradeOrderStatus = "FILLED"
)

// All allowed values of TradeOrderStatus enum
var AllowedTradeOrderStatusEnumValues = []TradeOrderStatus{
	"OPEN",
	"REJECTED",
	"CANCELLED",
	"PARTIALLY_CANCELLED",
	"PARTIALLY_REJECTED",
	"FILLED",
}

func (v *TradeOrderStatus) UnmarshalJSON(src []byte) error {
	var value string
	err := json.Unmarshal(src, &value)
	if err != nil {
		return err
	}
	enumTypeValue := TradeOrderStatus(value)
	for _, existing := range AllowedTradeOrderStatusEnumValues {
		if existing == enumTypeValue {
			*v = enumTypeValue
			return nil
		}
	}

	return fmt.Errorf("%+v is not a valid TradeOrderStatus", value)
}

// NewTradeOrderStatusFromValue returns a pointer to a valid TradeOrderStatus
// for the value passed as argument, or an error if the value passed is not allowed by the enum
func NewTradeOrderStatusFromValue(v string) (*TradeOrderStatus, error) {
	ev := TradeOrderStatus(v)
	if ev.IsValid() {
		return &ev, nil
	} else {
		return nil, fmt.Errorf("invalid value '%v' for TradeOrderStatus: valid values are %v", v, AllowedTradeOrderStatusEnumValues)
	}
}

// IsValid return true if the value is valid for the enum, false otherwise
func (v TradeOrderStatus) IsValid() bool {
	for _, existing := range AllowedTradeOrderStatusEnumValues {
		if existing == v {
			return true
		}
	}
	return false
}

// Ptr returns reference to TradeOrderStatus value
func (v TradeOrderStatus) Ptr() *TradeOrderStatus {
	return &v
}

type NullableTradeOrderStatus struct {
	value *TradeOrderStatus
	isSet bool
}

func (v NullableTradeOrderStatus) Get() *TradeOrderStatus {
	return v.value
}

func (v *NullableTradeOrderStatus) Set(val *TradeOrderStatus) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTradeOrderStatus(val *TradeOrderStatus) *NullableTradeOrderStatus {
	return &NullableTradeOrderStatus{value: val, isSet: true}
}

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

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