Class: Itbit::Wallet
- Inherits:
-
Object
- Object
- Itbit::Wallet
- Defined in:
- lib/itbit/wallet.rb
Overview
Your ItBit wallets, translated from itbit api to a more suitable ruby style. Field names are underscored. Values for balance and trading_balance are converted to BigDecimal
Class Method Summary collapse
-
.all ⇒ Object
Lists all wallets.
-
.create!(name) ⇒ Object
Creates a new order.
- .translate_wallet(raw_wallet) ⇒ Object
Class Method Details
.all ⇒ Object
Lists all wallets.
8 9 10 11 |
# File 'lib/itbit/wallet.rb', line 8 def self.all Api.request(:get, "/wallets", userId: Itbit.user_id) .collect { |wallet| translate_wallet(wallet) } end |
.create!(name) ⇒ Object
Creates a new order
15 16 17 |
# File 'lib/itbit/wallet.rb', line 15 def self.create!(name) translate_wallet(Api.request(:post, "/wallets", name: name, userId: Itbit.user_id)) end |
.translate_wallet(raw_wallet) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/itbit/wallet.rb', line 19 def self.translate_wallet(raw_wallet) wallet = raw_wallet.reduce({}) do |w, pair| w[pair[0].underscore.to_sym] = pair[1] w end wallet[:balances] = wallet[:balances].dup.collect do |b| { total_balance: b['totalBalance'].to_d, currency: b['currency'].downcase.to_sym, available_balance: b['availableBalance'].to_d, } end wallet end |