=begin
#FinFeedAPI Stock REST API

#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: v1
Contact: support@apibricks.io
Generated by: https://openapi-generator.tech
Generator version: 7.14.0

=end

require 'date'
require 'time'

module OpenapiClient
  # Represents the response DTO for auction information
  class AdminAuctionInformationModel
    # The stock symbol
    attr_accessor :symbol

    # Original timestamp in nanoseconds since epoch
    attr_accessor :timestamp_nanos

    # Time when the auction data was recorded as DateTime
    attr_accessor :timestamp

    # Type of auction as byte value
    attr_accessor :auction_type

    # Type of auction as character string
    attr_accessor :auction_type_code

    # Human-readable description of the auction type
    attr_accessor :auction_type_text

    # Indicates if the auction type is 'Opening Auction' ('O'/0x4f).
    attr_accessor :is_auction_type_opening

    # Indicates if the auction type is 'Closing Auction' ('C'/0x43).
    attr_accessor :is_auction_type_closing

    # Indicates if the auction type is 'IPO Auction' ('I'/0x49).
    attr_accessor :is_auction_type_ipo

    # Indicates if the auction type is 'Halt Auction' ('H'/0x48).
    attr_accessor :is_auction_type_halt

    # Indicates if the auction type is 'Volatility Auction' ('V'/0x56).
    attr_accessor :is_auction_type_volatility

    # Number of shares paired at the Reference Price
    attr_accessor :paired_shares

    # Reference price as decimal
    attr_accessor :reference_price

    # Indicative clearing price as decimal
    attr_accessor :indicative_clearing_price

    # Number of unpaired shares at the Reference Price
    attr_accessor :imbalance_shares

    # Side of the imbalance as byte value
    attr_accessor :imbalance_side

    # Side of the imbalance as character string
    attr_accessor :imbalance_side_code

    # Human-readable description of the imbalance side
    attr_accessor :imbalance_side_text

    # Indicates if there is a buy-side imbalance ('B'/0x42).
    attr_accessor :is_imbalance_side_buy

    # Indicates if there is a sell-side imbalance ('S'/0x53).
    attr_accessor :is_imbalance_side_sell

    # Indicates if there is no imbalance ('N'/0x4e).
    attr_accessor :is_imbalance_side_none

    # Number of extensions to the auction
    attr_accessor :extension_number

    # Scheduled auction time in seconds since epoch
    attr_accessor :scheduled_auction_time_seconds

    # Scheduled time for the auction as DateTime
    attr_accessor :scheduled_auction_time

    # Auction book clearing price as decimal
    attr_accessor :auction_book_clearing_price

    # Collar reference price as decimal
    attr_accessor :collar_reference_price

    # Lower auction collar as decimal
    attr_accessor :lower_auction_collar

    # Upper auction collar as decimal
    attr_accessor :upper_auction_collar

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'symbol' => :'symbol',
        :'timestamp_nanos' => :'timestamp_nanos',
        :'timestamp' => :'timestamp',
        :'auction_type' => :'auction_type',
        :'auction_type_code' => :'auction_type_code',
        :'auction_type_text' => :'auction_type_text',
        :'is_auction_type_opening' => :'is_auction_type_opening',
        :'is_auction_type_closing' => :'is_auction_type_closing',
        :'is_auction_type_ipo' => :'is_auction_type_ipo',
        :'is_auction_type_halt' => :'is_auction_type_halt',
        :'is_auction_type_volatility' => :'is_auction_type_volatility',
        :'paired_shares' => :'paired_shares',
        :'reference_price' => :'reference_price',
        :'indicative_clearing_price' => :'indicative_clearing_price',
        :'imbalance_shares' => :'imbalance_shares',
        :'imbalance_side' => :'imbalance_side',
        :'imbalance_side_code' => :'imbalance_side_code',
        :'imbalance_side_text' => :'imbalance_side_text',
        :'is_imbalance_side_buy' => :'is_imbalance_side_buy',
        :'is_imbalance_side_sell' => :'is_imbalance_side_sell',
        :'is_imbalance_side_none' => :'is_imbalance_side_none',
        :'extension_number' => :'extension_number',
        :'scheduled_auction_time_seconds' => :'scheduled_auction_time_seconds',
        :'scheduled_auction_time' => :'scheduled_auction_time',
        :'auction_book_clearing_price' => :'auction_book_clearing_price',
        :'collar_reference_price' => :'collar_reference_price',
        :'lower_auction_collar' => :'lower_auction_collar',
        :'upper_auction_collar' => :'upper_auction_collar'
      }
    end

    # Returns attribute mapping this model knows about
    def self.acceptable_attribute_map
      attribute_map
    end

    # Returns all the JSON keys this model knows about
    def self.acceptable_attributes
      acceptable_attribute_map.values
    end

    # Attribute type mapping.
    def self.openapi_types
      {
        :'symbol' => :'String',
        :'timestamp_nanos' => :'Integer',
        :'timestamp' => :'Time',
        :'auction_type' => :'Integer',
        :'auction_type_code' => :'String',
        :'auction_type_text' => :'String',
        :'is_auction_type_opening' => :'Boolean',
        :'is_auction_type_closing' => :'Boolean',
        :'is_auction_type_ipo' => :'Boolean',
        :'is_auction_type_halt' => :'Boolean',
        :'is_auction_type_volatility' => :'Boolean',
        :'paired_shares' => :'Integer',
        :'reference_price' => :'Float',
        :'indicative_clearing_price' => :'Float',
        :'imbalance_shares' => :'Integer',
        :'imbalance_side' => :'Integer',
        :'imbalance_side_code' => :'String',
        :'imbalance_side_text' => :'String',
        :'is_imbalance_side_buy' => :'Boolean',
        :'is_imbalance_side_sell' => :'Boolean',
        :'is_imbalance_side_none' => :'Boolean',
        :'extension_number' => :'Integer',
        :'scheduled_auction_time_seconds' => :'Integer',
        :'scheduled_auction_time' => :'Time',
        :'auction_book_clearing_price' => :'Float',
        :'collar_reference_price' => :'Float',
        :'lower_auction_collar' => :'Float',
        :'upper_auction_collar' => :'Float'
      }
    end

    # List of attributes with nullable: true
    def self.openapi_nullable
      Set.new([
        :'symbol',
        :'auction_type_code',
        :'auction_type_text',
        :'imbalance_side_code',
        :'imbalance_side_text',
      ])
    end

    # Initializes the object
    # @param [Hash] attributes Model attributes in the form of hash
    def initialize(attributes = {})
      if (!attributes.is_a?(Hash))
        fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::AdminAuctionInformationModel` initialize method"
      end

      # check to see if the attribute exists and convert string to symbol for hash key
      acceptable_attribute_map = self.class.acceptable_attribute_map
      attributes = attributes.each_with_object({}) { |(k, v), h|
        if (!acceptable_attribute_map.key?(k.to_sym))
          fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::AdminAuctionInformationModel`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
        end
        h[k.to_sym] = v
      }

      if attributes.key?(:'symbol')
        self.symbol = attributes[:'symbol']
      end

      if attributes.key?(:'timestamp_nanos')
        self.timestamp_nanos = attributes[:'timestamp_nanos']
      end

      if attributes.key?(:'timestamp')
        self.timestamp = attributes[:'timestamp']
      end

      if attributes.key?(:'auction_type')
        self.auction_type = attributes[:'auction_type']
      end

      if attributes.key?(:'auction_type_code')
        self.auction_type_code = attributes[:'auction_type_code']
      end

      if attributes.key?(:'auction_type_text')
        self.auction_type_text = attributes[:'auction_type_text']
      end

      if attributes.key?(:'is_auction_type_opening')
        self.is_auction_type_opening = attributes[:'is_auction_type_opening']
      end

      if attributes.key?(:'is_auction_type_closing')
        self.is_auction_type_closing = attributes[:'is_auction_type_closing']
      end

      if attributes.key?(:'is_auction_type_ipo')
        self.is_auction_type_ipo = attributes[:'is_auction_type_ipo']
      end

      if attributes.key?(:'is_auction_type_halt')
        self.is_auction_type_halt = attributes[:'is_auction_type_halt']
      end

      if attributes.key?(:'is_auction_type_volatility')
        self.is_auction_type_volatility = attributes[:'is_auction_type_volatility']
      end

      if attributes.key?(:'paired_shares')
        self.paired_shares = attributes[:'paired_shares']
      end

      if attributes.key?(:'reference_price')
        self.reference_price = attributes[:'reference_price']
      end

      if attributes.key?(:'indicative_clearing_price')
        self.indicative_clearing_price = attributes[:'indicative_clearing_price']
      end

      if attributes.key?(:'imbalance_shares')
        self.imbalance_shares = attributes[:'imbalance_shares']
      end

      if attributes.key?(:'imbalance_side')
        self.imbalance_side = attributes[:'imbalance_side']
      end

      if attributes.key?(:'imbalance_side_code')
        self.imbalance_side_code = attributes[:'imbalance_side_code']
      end

      if attributes.key?(:'imbalance_side_text')
        self.imbalance_side_text = attributes[:'imbalance_side_text']
      end

      if attributes.key?(:'is_imbalance_side_buy')
        self.is_imbalance_side_buy = attributes[:'is_imbalance_side_buy']
      end

      if attributes.key?(:'is_imbalance_side_sell')
        self.is_imbalance_side_sell = attributes[:'is_imbalance_side_sell']
      end

      if attributes.key?(:'is_imbalance_side_none')
        self.is_imbalance_side_none = attributes[:'is_imbalance_side_none']
      end

      if attributes.key?(:'extension_number')
        self.extension_number = attributes[:'extension_number']
      end

      if attributes.key?(:'scheduled_auction_time_seconds')
        self.scheduled_auction_time_seconds = attributes[:'scheduled_auction_time_seconds']
      end

      if attributes.key?(:'scheduled_auction_time')
        self.scheduled_auction_time = attributes[:'scheduled_auction_time']
      end

      if attributes.key?(:'auction_book_clearing_price')
        self.auction_book_clearing_price = attributes[:'auction_book_clearing_price']
      end

      if attributes.key?(:'collar_reference_price')
        self.collar_reference_price = attributes[:'collar_reference_price']
      end

      if attributes.key?(:'lower_auction_collar')
        self.lower_auction_collar = attributes[:'lower_auction_collar']
      end

      if attributes.key?(:'upper_auction_collar')
        self.upper_auction_collar = attributes[:'upper_auction_collar']
      end
    end

    # Show invalid properties with the reasons. Usually used together with valid?
    # @return Array for valid properties with the reasons
    def list_invalid_properties
      warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
      invalid_properties = Array.new
      invalid_properties
    end

    # Check to see if the all the properties in the model are valid
    # @return true if the model is valid
    def valid?
      warn '[DEPRECATED] the `valid?` method is obsolete'
      true
    end

    # Checks equality by comparing each attribute.
    # @param [Object] Object to be compared
    def ==(o)
      return true if self.equal?(o)
      self.class == o.class &&
          symbol == o.symbol &&
          timestamp_nanos == o.timestamp_nanos &&
          timestamp == o.timestamp &&
          auction_type == o.auction_type &&
          auction_type_code == o.auction_type_code &&
          auction_type_text == o.auction_type_text &&
          is_auction_type_opening == o.is_auction_type_opening &&
          is_auction_type_closing == o.is_auction_type_closing &&
          is_auction_type_ipo == o.is_auction_type_ipo &&
          is_auction_type_halt == o.is_auction_type_halt &&
          is_auction_type_volatility == o.is_auction_type_volatility &&
          paired_shares == o.paired_shares &&
          reference_price == o.reference_price &&
          indicative_clearing_price == o.indicative_clearing_price &&
          imbalance_shares == o.imbalance_shares &&
          imbalance_side == o.imbalance_side &&
          imbalance_side_code == o.imbalance_side_code &&
          imbalance_side_text == o.imbalance_side_text &&
          is_imbalance_side_buy == o.is_imbalance_side_buy &&
          is_imbalance_side_sell == o.is_imbalance_side_sell &&
          is_imbalance_side_none == o.is_imbalance_side_none &&
          extension_number == o.extension_number &&
          scheduled_auction_time_seconds == o.scheduled_auction_time_seconds &&
          scheduled_auction_time == o.scheduled_auction_time &&
          auction_book_clearing_price == o.auction_book_clearing_price &&
          collar_reference_price == o.collar_reference_price &&
          lower_auction_collar == o.lower_auction_collar &&
          upper_auction_collar == o.upper_auction_collar
    end

    # @see the `==` method
    # @param [Object] Object to be compared
    def eql?(o)
      self == o
    end

    # Calculates hash code according to all attributes.
    # @return [Integer] Hash code
    def hash
      [symbol, timestamp_nanos, timestamp, auction_type, auction_type_code, auction_type_text, is_auction_type_opening, is_auction_type_closing, is_auction_type_ipo, is_auction_type_halt, is_auction_type_volatility, paired_shares, reference_price, indicative_clearing_price, imbalance_shares, imbalance_side, imbalance_side_code, imbalance_side_text, is_imbalance_side_buy, is_imbalance_side_sell, is_imbalance_side_none, extension_number, scheduled_auction_time_seconds, scheduled_auction_time, auction_book_clearing_price, collar_reference_price, lower_auction_collar, upper_auction_collar].hash
    end

    # Builds the object from hash
    # @param [Hash] attributes Model attributes in the form of hash
    # @return [Object] Returns the model itself
    def self.build_from_hash(attributes)
      return nil unless attributes.is_a?(Hash)
      attributes = attributes.transform_keys(&:to_sym)
      transformed_hash = {}
      openapi_types.each_pair do |key, type|
        if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
          transformed_hash["#{key}"] = nil
        elsif type =~ /\AArray<(.*)>/i
          # check to ensure the input is an array given that the attribute
          # is documented as an array but the input is not
          if attributes[attribute_map[key]].is_a?(Array)
            transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
          end
        elsif !attributes[attribute_map[key]].nil?
          transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
        end
      end
      new(transformed_hash)
    end

    # Deserializes the data based on type
    # @param string type Data type
    # @param string value Value to be deserialized
    # @return [Object] Deserialized data
    def self._deserialize(type, value)
      case type.to_sym
      when :Time
        Time.parse(value)
      when :Date
        Date.parse(value)
      when :String
        value.to_s
      when :Integer
        value.to_i
      when :Float
        value.to_f
      when :Boolean
        if value.to_s =~ /\A(true|t|yes|y|1)\z/i
          true
        else
          false
        end
      when :Object
        # generic object (usually a Hash), return directly
        value
      when /\AArray<(?<inner_type>.+)>\z/
        inner_type = Regexp.last_match[:inner_type]
        value.map { |v| _deserialize(inner_type, v) }
      when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
        k_type = Regexp.last_match[:k_type]
        v_type = Regexp.last_match[:v_type]
        {}.tap do |hash|
          value.each do |k, v|
            hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
          end
        end
      else # model
        # models (e.g. Pet) or oneOf
        klass = OpenapiClient.const_get(type)
        klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
      end
    end

    # Returns the string representation of the object
    # @return [String] String presentation of the object
    def to_s
      to_hash.to_s
    end

    # to_body is an alias to to_hash (backward compatibility)
    # @return [Hash] Returns the object in the form of hash
    def to_body
      to_hash
    end

    # Returns the object in the form of hash
    # @return [Hash] Returns the object in the form of hash
    def to_hash
      hash = {}
      self.class.attribute_map.each_pair do |attr, param|
        value = self.send(attr)
        if value.nil?
          is_nullable = self.class.openapi_nullable.include?(attr)
          next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
        end

        hash[param] = _to_hash(value)
      end
      hash
    end

    # Outputs non-array value in the form of hash
    # For object, use to_hash. Otherwise, just return the value
    # @param [Object] value Any valid value
    # @return [Hash] Returns the value in the form of hash
    def _to_hash(value)
      if value.is_a?(Array)
        value.compact.map { |v| _to_hash(v) }
      elsif value.is_a?(Hash)
        {}.tap do |hash|
          value.each { |k, v| hash[k] = _to_hash(v) }
        end
      elsif value.respond_to? :to_hash
        value.to_hash
      else
        value
      end
    end

  end

end
