class BandCampBX::Client
Attributes
key[RW]
secret[RW]
Public Class Methods
new(key = nil, secret = nil)
click to toggle source
# File lib/bandcampbx/client.rb, line 10 def initialize(key = nil, secret = nil) @key = key @secret = secret end
Public Instance Methods
balance()
click to toggle source
# File lib/bandcampbx/client.rb, line 15 def balance mapper.map_balance(net.post("myfunds.php")) end
buy!(quantity, price, order_type)
click to toggle source
# File lib/bandcampbx/client.rb, line 23 def buy!(quantity, price, order_type) trade!("tradeenter.php", quantity, price, order_type) end
cancel(id, type)
click to toggle source
# File lib/bandcampbx/client.rb, line 31 def cancel(id, type) wrapping_standard_error do mapper.map_cancel(net.post("tradecancel.php", { id: id.to_s, type: type.to_s })) end end
orders()
click to toggle source
# File lib/bandcampbx/client.rb, line 19 def orders mapper.map_orders(net.post("myorders.php")) end
sell!(quantity, price, order_type)
click to toggle source
# File lib/bandcampbx/client.rb, line 27 def sell!(quantity, price, order_type) trade!("tradeenter.php", quantity, price, order_type) end
Private Instance Methods
mapper()
click to toggle source
# File lib/bandcampbx/client.rb, line 42 def mapper @mapper ||= Mapper.new end
net()
click to toggle source
# File lib/bandcampbx/client.rb, line 38 def net @net ||= Net.new(self) end
trade!(endpoint, quantity, price, order_type)
click to toggle source
# File lib/bandcampbx/client.rb, line 46 def trade!(endpoint, quantity, price, order_type) wrapping_standard_error do mapper.map_order(net.post(endpoint, { price: price.to_digits, quantity: quantity.to_digits, order_type: order_type.to_s })) end end
wrapping_standard_error() { || ... }
click to toggle source
# File lib/bandcampbx/client.rb, line 52 def wrapping_standard_error &block begin yield rescue ::StandardError => e raise BandCampBX::StandardError.new(e.message) end end