class Kucoin::Models::Order

Constants

INDEX_MAPPING
MAPPING

Attributes

deals[RW]

Public Class Methods

new(hash) click to toggle source
Calls superclass method Kucoin::Models::Base::new
# File lib/kucoin/models/order.rb, line 32
def initialize(hash)
  super(hash)
  
  self.id       =   ::Kucoin::Utilities::Parsing.convert_value(hash.fetch("oid", hash.fetch("orderOid", nil)), :string)    if self.id.to_s.empty?
  self.price    =   ::Kucoin::Utilities::Parsing.convert_value(hash.fetch("price", hash.fetch("orderPrice", nil)), :float) if self.price.nil?
  
  dealt         =   hash.dig("dealOrders", "datas")
  self.deals    =   ::Kucoin::Models::Trade.parse(response) if dealt && dealt.is_a?(Array) && dealt.any?
end
parse(response) click to toggle source
# File lib/kucoin/models/order.rb, line 42
def self.parse(response)
  orders              =   []
  
  response&.each do |item|
    data              =   {}
    
    item.each_with_index do |value, index|
      data[INDEX_MAPPING[index]] = value
    end
    
    orders << ::Kucoin::Models::Order.new(data)
  end
  
  return orders
end
parse_map(response) click to toggle source
# File lib/kucoin/models/order.rb, line 58
def self.parse_map(response)
  orders        =     []
  
  response&.each do |type, collection|
    collection.each do |item|
      orders << ::Kucoin::Models::Order.new(item)
    end
  end
  
  return orders
end