diff --git a/lib/bitstamp.rb b/lib/bitstamp.rb index bd341c6..37e15e3 100644 --- a/lib/bitstamp.rb +++ b/lib/bitstamp.rb @@ -9,6 +9,7 @@ require 'bitstamp/model' require 'bitstamp/orders' +require 'bitstamp/transactions' require 'bitstamp/ticker' String.send(:include, ActiveSupport::Inflector) @@ -30,6 +31,12 @@ def self.orders @@orders ||= Bitstamp::Orders.new end + def self.user_transactions + self.sanity_check! + + @@transactions ||= Bitstamp::UserTransactions.new + end + def self.balance self.sanity_check! diff --git a/lib/bitstamp/helper.rb b/lib/bitstamp/helper.rb index 8b977c9..4c74ccb 100644 --- a/lib/bitstamp/helper.rb +++ b/lib/bitstamp/helper.rb @@ -1,6 +1,9 @@ module Bitstamp module Helper def self.parse_objects!(string, klass) + # If Bitstamp returned nothing (which it does if the results yield empty) 'cast' it to an array + string = "[]" if string == "" + objects = JSON.parse(string) objects.collect do |t_json| parse_object!(t_json, klass) diff --git a/lib/bitstamp/model.rb b/lib/bitstamp/model.rb index 406b20b..0de976e 100644 --- a/lib/bitstamp/model.rb +++ b/lib/bitstamp/model.rb @@ -1,5 +1,7 @@ module Bitstamp class Model + attr_accessor :error, :message + if ActiveModel::VERSION::MAJOR <= 3 include ActiveModel::Validations include ActiveModel::Conversion