lib/coinsetter.rb in coinsetter-0.0.2 vs lib/coinsetter.rb in coinsetter-0.0.3

- old
+ new

@@ -16,11 +16,10 @@ require "coinsetter/customer/account" require "coinsetter/client_sessions" require "coinsetter/client_session" require "coinsetter/orders" require "coinsetter/order" -require "coinsetter/order" String.send(:include, ActiveSupport::Inflector) module Coinsetter class << self @@ -38,22 +37,23 @@ def self.configured? configuration.username && configuration.password && configuration.ip_address end def self.with_session - session = Coinsetter::ClientSessions.new + session = ClientSessions.new client_session = session.create(credentials) - if client_session.kind_of? Coinsetter::ClientSession + if client_session.kind_of? ClientSession yield client_session if block_given? + client_session.destroy! + else + client_session end - - client_session.destroy! end def self.orders - @@orders ||= Coinsetter::Orders.new + @@orders ||= Orders.new end def self.add_order(side='BUY', options={}) with_session do |client_session| params = default_options.merge(options) @@ -68,10 +68,10 @@ def self.buy_order(amount, price, account_uuid, options={}) add_order('BUY', options.merge(required_params(amount, price, account_uuid))) end def self.sell_order(amount, price, account_uuid, options={}) - add_order('BUY', options.merge(required_params(amount, price, account_uuid))) + add_order('SELL', options.merge(required_params(amount, price, account_uuid))) end def self.default_options { symbol: "BTCUSD",