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

- old
+ new

@@ -3,11 +3,11 @@ require 'json' require 'active_support' require 'active_support/core_ext' require 'active_support/inflector' require 'active_model' -require 'rest_client' +require 'faraday' require "coinsetter/configuration" require "coinsetter/net" require "coinsetter/helper" require "coinsetter/model" @@ -37,18 +37,24 @@ def self.configured? configuration.username && configuration.password && configuration.ip_address end def self.with_session - session = ClientSessions.new - client_session = session.create(credentials) - if client_session.kind_of? ClientSession yield client_session if block_given? - client_session.destroy! + destroy_client_session! else client_session end + end + + def self.client_session + @client_session ||= ClientSessions.new.create(credentials) + end + + def self.destroy_client_session! + client_session.destroy! + @client_session = nil end def self.orders @@orders ||= Orders.new end