Class: ChinaShop::Client

Inherits:
Object
  • Object
show all
Includes:
Api, Config
Defined in:
lib/chinashop/client.rb

Instance Attribute Summary

Attributes included from Api

#api_uri

Attributes included from Config

#key, #secret

Instance Method Summary collapse

Methods included from Api

#get, #initialize, #post

Methods included from Config

#configure

Instance Method Details

#accountObject



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

def 
  Account.new(post(:method => 'getAccountInfo'))
end

#buy(h = {}) ⇒ Object



35
36
37
# File 'lib/chinashop/client.rb', line 35

def buy(h = {})
  Buy.new(post(:method => 'buyOrder', :params => ["#{h[:price].to_f.round(5)}", "#{h[:amount].to_f.round(8)}"]))
end

#cancel_order(id) ⇒ Object



43
44
45
# File 'lib/chinashop/client.rb', line 43

def cancel_order(id)
  CancelOrder.new(post(:method => 'cancelOrder', :params => [id]))
end

#depositsObject



51
52
53
# File 'lib/chinashop/client.rb', line 51

def deposits
  Deposits.new(post(:method => 'getDeposits', :params => ['BTC']))
end

#market_depthObject



31
32
33
# File 'lib/chinashop/client.rb', line 31

def market_depth
  MarketDepth.new(post(:method => 'getMarketDepth2'))
end

#order(id) ⇒ Object



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

def order(id)
  Order.new(post(:method => 'getOrder', :params => [id]))
end

#order_bookObject



59
60
61
# File 'lib/chinashop/client.rb', line 59

def order_book
  get('https://data.btcchina.com/data/orderbook')
end

#ordersObject



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

def orders
  Orders.new(post(:method => 'getOrders'))
end

#sell(h = {}) ⇒ Object



39
40
41
# File 'lib/chinashop/client.rb', line 39

def sell(h = {})
  Sell.new(post(:method => 'sellOrder', :params => ["#{h[:price].to_f.round(5)}", "#{h[:amount].to_f.round(8)}"]))
end

#tickerObject



55
56
57
# File 'lib/chinashop/client.rb', line 55

def ticker
  Ticker.new(get('https://data.btcchina.com/data/ticker'))
end

#tradesObject



63
64
65
# File 'lib/chinashop/client.rb', line 63

def trades
  get('https://data.btcchina.com/data/trades')
end

#transactionsObject



47
48
49
# File 'lib/chinashop/client.rb', line 47

def transactions
  Transactions.new(post(:method => 'getTransactions'))
end