From 0cf709d3a5113a653c64af0f2fb92731bbf39be4 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 12 Jun 2013 16:25:16 +0200 Subject: [PATCH] Bistamp => Bitstamp. Adden cancel order method --- lib/bitstamp/collection.rb | 2 +- lib/bitstamp/orders.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/bitstamp/collection.rb b/lib/bitstamp/collection.rb index 3f6a883..d61562b 100644 --- a/lib/bitstamp/collection.rb +++ b/lib/bitstamp/collection.rb @@ -20,7 +20,7 @@ def create(options = {}) end def find(id, options = {}) - Bitstamp::Helper.parse_object! Bistamp::Net::get("#{self.path}/#{id}").body_str, self.model + Bitstamp::Helper.parse_object! Bitstamp::Net::get("#{self.path}/#{id}").body_str, self.model end def update(id, options = {}) diff --git a/lib/bitstamp/orders.rb b/lib/bitstamp/orders.rb index a47b673..6e8e339 100644 --- a/lib/bitstamp/orders.rb +++ b/lib/bitstamp/orders.rb @@ -18,6 +18,13 @@ def buy(options = {}) options.merge!({type: Bitstamp::Order::BUY}) self.create options end + + def find(order_id) + all = self.all + index = all.index {|order| order.id.to_i == order_id} + + return all[index] if index + end end class Order < Bitstamp::Model @@ -26,5 +33,9 @@ class Order < Bitstamp::Model attr_accessor :type, :amount, :price, :id, :datetime attr_accessor :error, :message + + def cancel! + Bitstamp::Net::post('/cancel_order', {id: self.id}).body_str + end end end