Class: BandCampBX::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bandcampbx/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, secret = nil) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/bandcampbx/client.rb', line 10

def initialize(key = nil, secret = nil)
  @key    = key
  @secret = secret
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



7
8
9
# File 'lib/bandcampbx/client.rb', line 7

def key
  @key
end

#secretObject

Returns the value of attribute secret.



8
9
10
# File 'lib/bandcampbx/client.rb', line 8

def secret
  @secret
end

Instance Method Details

#balanceObject



15
16
17
# File 'lib/bandcampbx/client.rb', line 15

def balance
  mapper.map_balance(net.post("myfunds.php"))
end

#buy!(quantity, price, order_type) ⇒ Object



23
24
25
# File 'lib/bandcampbx/client.rb', line 23

def buy!(quantity, price, order_type)
  trade!("tradeenter.php", quantity, price, order_type)
end

#cancel(id, type) ⇒ Object



31
32
33
34
35
# 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

#ordersObject



19
20
21
# File 'lib/bandcampbx/client.rb', line 19

def orders
  mapper.map_orders(net.post("myorders.php"))
end

#sell!(quantity, price, order_type) ⇒ Object



27
28
29
# File 'lib/bandcampbx/client.rb', line 27

def sell!(quantity, price, order_type)
  trade!("tradeenter.php", quantity, price, order_type)
end