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

// TradeOrderSide the model 'TradeOrderSide'
type TradeOrderSide string

// List of TradeOrderSide
const (
	SELL TradeOrderSide = "SELL"
	BUY  TradeOrderSide = "BUY"
)

// All allowed values of TradeOrderSide enum
var AllowedTradeOrderSideEnumValues = []TradeOrderSide{
	"SELL",
	"BUY",
}

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

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

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

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

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

type NullableTradeOrderSide struct {
	value *TradeOrderSide
	isSet bool
}

func (v NullableTradeOrderSide) Get() *TradeOrderSide {
	return v.value
}

func (v *NullableTradeOrderSide) Set(val *TradeOrderSide) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTradeOrderSide(val *TradeOrderSide) *NullableTradeOrderSide {
	return &NullableTradeOrderSide{value: val, isSet: true}
}

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

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