/*
 * SnapTrade
 *
 * Connect brokerage accounts to your app for live positions and trading
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: lyhxr@example.com
 * Generated by: https://konfigthis.com
 */


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = SnapTrade.Net.Client.OpenAPIDateConverter;

namespace SnapTrade.Net.Model
{
    /// <summary>
    /// Execution status of a trade
    /// </summary>
    [DataContract(Name = "TradeExecutionStatus")]
    public partial class TradeExecutionStatus : IEquatable<TradeExecutionStatus>, IValidatableObject
    {
        /// <summary>
        /// Execution state of a trade
        /// </summary>
        /// <value>Execution state of a trade</value>
        [JsonConverter(typeof(StringEnumConverter))]
        public enum StateEnum
        {
            /// <summary>
            /// Enum Executed for value: Executed
            /// </summary>
            [EnumMember(Value = "Executed")]
            Executed = 1,

            /// <summary>
            /// Enum Canceled for value: Canceled
            /// </summary>
            [EnumMember(Value = "Canceled")]
            Canceled = 2,

            /// <summary>
            /// Enum Rejected for value: Rejected
            /// </summary>
            [EnumMember(Value = "Rejected")]
            Rejected = 3,

            /// <summary>
            /// Enum Failed for value: Failed
            /// </summary>
            [EnumMember(Value = "Failed")]
            Failed = 4,

            /// <summary>
            /// Enum NotExecuted for value: Not Executed
            /// </summary>
            [EnumMember(Value = "Not Executed")]
            NotExecuted = 5

        }


        /// <summary>
        /// Execution state of a trade
        /// </summary>
        /// <value>Execution state of a trade</value>
        [DataMember(Name = "state", EmitDefaultValue = false)]
        public StateEnum? State { get; set; }
        /// <summary>
        /// Action of executed trade
        /// </summary>
        /// <value>Action of executed trade</value>
        [JsonConverter(typeof(StringEnumConverter))]
        public enum ActionEnum
        {
            /// <summary>
            /// Enum BUY for value: BUY
            /// </summary>
            [EnumMember(Value = "BUY")]
            BUY = 1,

            /// <summary>
            /// Enum SELL for value: SELL
            /// </summary>
            [EnumMember(Value = "SELL")]
            SELL = 2

        }


        /// <summary>
        /// Action of executed trade
        /// </summary>
        /// <value>Action of executed trade</value>
        [DataMember(Name = "action", EmitDefaultValue = false)]
        public ActionEnum? Action { get; set; }
        /// <summary>
        /// Initializes a new instance of the <see cref="TradeExecutionStatus" /> class.
        /// </summary>
        /// <param name="symbol">symbol.</param>
        /// <param name="universalSymbol">universalSymbol.</param>
        /// <param name="trade">trade.</param>
        /// <param name="state">Execution state of a trade.</param>
        /// <param name="filledUnits">Number of filled units.</param>
        /// <param name="action">Action of executed trade.</param>
        /// <param name="price">Price of execution.</param>
        /// <param name="commissions">Fees paid from executing trade.</param>
        /// <param name="meta">Other misc. data.</param>
        public TradeExecutionStatus(BrokerageSymbol symbol = default(BrokerageSymbol), UniversalSymbol universalSymbol = default(UniversalSymbol), Trade trade = default(Trade), StateEnum? state = default(StateEnum?), int filledUnits = default(int), ActionEnum? action = default(ActionEnum?), decimal price = default(decimal), decimal commissions = default(decimal), Dictionary<string, Object> meta = default(Dictionary<string, Object>)) : base()
        {
            this.Symbol = symbol;
            this.UniversalSymbol = universalSymbol;
            this.Trade = trade;
            this.State = state;
            this.FilledUnits = filledUnits;
            this.Action = action;
            this.Price = price;
            this.Commissions = commissions;
            this.Meta = meta;
            this.AdditionalProperties = new Dictionary<string, object>();
        }

        /// <summary>
        /// Gets or Sets Symbol
        /// </summary>
        [DataMember(Name = "symbol", EmitDefaultValue = false)]
        public BrokerageSymbol Symbol { get; set; }

        /// <summary>
        /// Gets or Sets UniversalSymbol
        /// </summary>
        [DataMember(Name = "universal_symbol", EmitDefaultValue = false)]
        public UniversalSymbol UniversalSymbol { get; set; }

        /// <summary>
        /// Gets or Sets Trade
        /// </summary>
        [DataMember(Name = "trade", EmitDefaultValue = false)]
        public Trade Trade { get; set; }

        /// <summary>
        /// Number of filled units
        /// </summary>
        /// <value>Number of filled units</value>
        [DataMember(Name = "filled_units", EmitDefaultValue = false)]
        public int FilledUnits { get; set; }

        /// <summary>
        /// Price of execution
        /// </summary>
        /// <value>Price of execution</value>
        [DataMember(Name = "price", EmitDefaultValue = false)]
        public decimal Price { get; set; }

        /// <summary>
        /// Fees paid from executing trade
        /// </summary>
        /// <value>Fees paid from executing trade</value>
        [DataMember(Name = "commissions", EmitDefaultValue = false)]
        public decimal Commissions { get; set; }

        /// <summary>
        /// Other misc. data
        /// </summary>
        /// <value>Other misc. data</value>
        [DataMember(Name = "meta", EmitDefaultValue = false)]
        public Dictionary<string, Object> Meta { get; set; }

        /// <summary>
        /// Gets or Sets additional properties
        /// </summary>
        [JsonExtensionData]
        public IDictionary<string, object> AdditionalProperties { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("class TradeExecutionStatus {\n");
            sb.Append("  ").Append(base.ToString().Replace("\n", "\n  ")).Append("\n");
            sb.Append("  Symbol: ").Append(Symbol).Append("\n");
            sb.Append("  UniversalSymbol: ").Append(UniversalSymbol).Append("\n");
            sb.Append("  Trade: ").Append(Trade).Append("\n");
            sb.Append("  State: ").Append(State).Append("\n");
            sb.Append("  FilledUnits: ").Append(FilledUnits).Append("\n");
            sb.Append("  Action: ").Append(Action).Append("\n");
            sb.Append("  Price: ").Append(Price).Append("\n");
            sb.Append("  Commissions: ").Append(Commissions).Append("\n");
            sb.Append("  Meta: ").Append(Meta).Append("\n");
            sb.Append("  AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }

        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public string ToJson()
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as TradeExecutionStatus);
        }

        /// <summary>
        /// Returns true if TradeExecutionStatus instances are equal
        /// </summary>
        /// <param name="input">Instance of TradeExecutionStatus to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TradeExecutionStatus input)
        {
            if (input == null)
            {
                return false;
            }
            return base.Equals(input) && 
                (
                    this.Symbol == input.Symbol ||
                    (this.Symbol != null &&
                    this.Symbol.Equals(input.Symbol))
                ) && base.Equals(input) && 
                (
                    this.UniversalSymbol == input.UniversalSymbol ||
                    (this.UniversalSymbol != null &&
                    this.UniversalSymbol.Equals(input.UniversalSymbol))
                ) && base.Equals(input) && 
                (
                    this.Trade == input.Trade ||
                    (this.Trade != null &&
                    this.Trade.Equals(input.Trade))
                ) && base.Equals(input) && 
                (
                    this.State == input.State ||
                    this.State.Equals(input.State)
                ) && base.Equals(input) && 
                (
                    this.FilledUnits == input.FilledUnits ||
                    this.FilledUnits.Equals(input.FilledUnits)
                ) && base.Equals(input) && 
                (
                    this.Action == input.Action ||
                    this.Action.Equals(input.Action)
                ) && base.Equals(input) && 
                (
                    this.Price == input.Price ||
                    this.Price.Equals(input.Price)
                ) && base.Equals(input) && 
                (
                    this.Commissions == input.Commissions ||
                    this.Commissions.Equals(input.Commissions)
                ) && base.Equals(input) && 
                (
                    this.Meta == input.Meta ||
                    this.Meta != null &&
                    input.Meta != null &&
                    this.Meta.SequenceEqual(input.Meta)
                )
                && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = base.GetHashCode();
                if (this.Symbol != null)
                {
                    hashCode = (hashCode * 59) + this.Symbol.GetHashCode();
                }
                if (this.UniversalSymbol != null)
                {
                    hashCode = (hashCode * 59) + this.UniversalSymbol.GetHashCode();
                }
                if (this.Trade != null)
                {
                    hashCode = (hashCode * 59) + this.Trade.GetHashCode();
                }
                hashCode = (hashCode * 59) + this.State.GetHashCode();
                hashCode = (hashCode * 59) + this.FilledUnits.GetHashCode();
                hashCode = (hashCode * 59) + this.Action.GetHashCode();
                hashCode = (hashCode * 59) + this.Price.GetHashCode();
                hashCode = (hashCode * 59) + this.Commissions.GetHashCode();
                if (this.Meta != null)
                {
                    hashCode = (hashCode * 59) + this.Meta.GetHashCode();
                }
                if (this.AdditionalProperties != null)
                {
                    hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
                }
                return hashCode;
            }
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        public IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> Validate(ValidationContext validationContext)
        {
            yield break;
        }
    }

}
