Module: Bitso

Defined in:
lib/bitso.rb,
lib/bitso/net.rb,
lib/bitso/model.rb,
lib/bitso/helper.rb,
lib/bitso/orders.rb,
lib/bitso/ticker.rb,
lib/bitso/balance.rb,
lib/bitso/collection.rb,
lib/bitso/transactions.rb

Defined Under Namespace

Modules: Helper, Net Classes: Balance, Collection, MissingConfigExeception, Model, Order, Orders, Ticker, Transactions, UserTransaction, UserTransactions

Constant Summary collapse

@@currency =
:mxn

Class Method Summary collapse

Class Method Details

.balanceObject



48
49
50
51
# File 'lib/bitso.rb', line 48

def self.balance
  self.sanity_check!
  return Bitso::Balance.from_api
end

.bitcoin_deposit_addressObject



66
67
68
69
70
71
# File 'lib/bitso.rb', line 66

def self.bitcoin_deposit_address
  # returns the deposit address
  self.sanity_check!
  address = Bitso::Net.post('/bitcoin_deposit_address')
  return address[1..address.length-2]
end

.configured?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/bitso.rb', line 85

def self.configured?
  self.key && self.secret && self.client_id
end

.order_bookObject



77
78
79
# File 'lib/bitso.rb', line 77

def self.order_book
  return JSON.parse Bitso::Net.get('/order_book').to_str
end

.ordersObject



32
33
34
35
36
# File 'lib/bitso.rb', line 32

def self.orders
  self.sanity_check!

  @@orders ||= Bitso::Orders.new
end

.sanity_check!Object



89
90
91
92
93
# File 'lib/bitso.rb', line 89

def self.sanity_check!
  unless configured?
    raise MissingConfigExeception.new("Bitso Gem not properly configured")
  end
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Bitso)

    the object that the method was called on



81
82
83
# File 'lib/bitso.rb', line 81

def self.setup
  yield self
end

.tickerObject



73
74
75
# File 'lib/bitso.rb', line 73

def self.ticker
  return Bitso::Ticker.from_api
end

.transactionsObject



44
45
46
# File 'lib/bitso.rb', line 44

def self.transactions
  return Bitso::Transactions.from_api
end

.user_transactionsObject



38
39
40
41
42
# File 'lib/bitso.rb', line 38

def self.user_transactions
  self.sanity_check!

  @@transactions ||= Bitso::UserTransactions.new
end

.withdraw_bitcoins(options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bitso.rb', line 53

def self.withdraw_bitcoins(options = {})
  self.sanity_check!
  if options[:amount].nil? || options[:address].nil?
    raise MissingConfigExeception.new("Required parameters not supplied, :amount, :address")
  end
  response_body = Bitso::Net.post('/bitcoin_withdrawal',options)
  if response_body != '"ok"'
    $stderr.puts "Withdraw Bitcoins Error: " + response_body
    return false
  end
  return true
end