lib/coinsetter.rb in coinsetter-0.0.6 vs lib/coinsetter.rb in coinsetter-0.0.7

- old
+ new

@@ -39,12 +39,12 @@ end def self.with_session if client_session.kind_of? ClientSession yield client_session if block_given? - destroy_client_session! else + destroy_client_session! {error: 'No Client Session available.'} end end def self.client_session @@ -74,16 +74,29 @@ def self.list_accounts accounts.list end - def self.add_order(side='BUY', options={}) - with_session do |client_session| + def self.get_order(order_uuid) + orders.get(order_uuid) + end + + def self.add_order_with_new_session(side='BUY', options={}) + order = with_session do |client_session| params = default_options.merge(options) params.merge!(side: side, customerUuid: client_session.customer_uuid) orders.create(params) end + + order.kind_of?(Order) ? Coinsetter.get_order(order.uuid) : nil + end + + def self.add_order(side='BUY', options={}) + params = default_options.merge(options) + params.merge!(side: side, + customerUuid: client_session.customer_uuid) + orders.create(params) end # Required Order Params # requestedQuantity, requestedPrice, accountUuid def self.buy_order(amount, price, account_uuid, options={})