itbit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- itbit (0.0.1)
4
+ itbit (0.0.2)
5
5
  activesupport
6
6
  rest_client
7
7
 
@@ -15,15 +15,8 @@ GEM
15
15
  thread_safe (~> 0.1)
16
16
  tzinfo (~> 1.1)
17
17
  addressable (2.3.6)
18
- columnize (0.8.9)
19
18
  crack (0.4.2)
20
19
  safe_yaml (~> 1.0.0)
21
- debugger (1.6.8)
22
- columnize (>= 0.3.1)
23
- debugger-linecache (~> 1.2.0)
24
- debugger-ruby_core_source (~> 1.3.5)
25
- debugger-linecache (1.2.0)
26
- debugger-ruby_core_source (1.3.5)
27
20
  diff-lcs (1.2.5)
28
21
  i18n (0.6.9)
29
22
  json (1.8.1)
@@ -60,7 +53,6 @@ PLATFORMS
60
53
 
61
54
  DEPENDENCIES
62
55
  bundler (~> 1.3)
63
- debugger
64
56
  itbit!
65
57
  rake
66
58
  rspec
data/lib/itbit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Itbit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/itbit/wallet.rb CHANGED
@@ -16,12 +16,15 @@ module Itbit
16
16
  translate_wallet(Api.request(:post, "/wallets", name: name, userId: Itbit.user_id))
17
17
  end
18
18
 
19
- def self.translate_wallet(wallet)
20
- wallet.symbolize_keys!
19
+ def self.translate_wallet(raw_wallet)
20
+ wallet = raw_wallet.reduce({}) do |w, pair|
21
+ w[pair[0].underscore.to_sym] = pair[1]
22
+ w
23
+ end
21
24
  wallet[:balances] = wallet[:balances].dup.collect do |b|
22
- { balance: b['balance'].to_d,
23
- currency_code: b['currencyCode'].downcase.to_sym,
24
- trading_balance: b['tradingBalance'].to_d
25
+ { total_balance: b['totalBalance'].to_d,
26
+ currency: b['currency'].downcase.to_sym,
27
+ available_balance: b['availableBalance'].to_d,
25
28
  }
26
29
  end
27
30
  wallet
@@ -1 +1 @@
1
- {"id":"3F2504E0-4F89-41D3-9A0C-0305E82C3301","name":"Wallet","balances":[{"balance":"10203.25","currencyCode":"USD","tradingBalance":"10003.25"},{"balance":"402.110","currencyCode":"XBT","tradingBalance":"402.110"},{"balance":"0.00","currencyCode":"EUR","tradingBalance":"0.00"}]}
1
+ {"id":"fae1ce9a-848d-479b-b059-e93cb026cdf9","userId":"326a3369-78fc-44e7-ad52-03e97371ca72","name":"primary","balances":[{"availableBalance":"10.00000000","totalBalance":"20.00000000","currency":"USD"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"XBT"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"EUR"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"SGD"}],"accountIdentifier":"PRIVATEBETA55-2285-2HN"}
@@ -1 +1 @@
1
- [{"id":"3F2504E0-4F89-41D3-9A0C-0305E82C3301","name":"Wallet","balances":[{"balance":"10203.25","currencyCode":"USD","tradingBalance":"10003.25"},{"balance":"402.110","currencyCode":"XBT","tradingBalance":"402.110"},{"balance":"0.00","currencyCode":"EUR","tradingBalance":"0.00"}]},{"id":"093DA2D8-12D8-408E-B59D-D4730E5F189D","name":"Trading","balances":[{"balance":"0","currencyCode":"USD","tradingBalance":"0"},{"balance":"0.00","currencyCode":"XBT","tradingBalance":"0.00"},{"balance":"0.00","currencyCode":"EUR","tradingBalance":"0.00"}]}]
1
+ [{"id":"fae1ce9a-848d-479b-b059-e93cb026cdf9","userId":"326a3369-78fc-44e7-ad52-03e97371ca72","name":"primary","balances":[{"availableBalance":"10.00000000","totalBalance":"20.00000000","currency":"USD"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"XBT"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"EUR"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"SGD"}],"accountIdentifier":"PRIVATEBETA55-2285-2HN"},{"id":"ff011d0a-c3e0-45f2-8919-5f6b8b1d8c5a","userId":"326a3369-78fc-44e7-ad52-03e97371ca72","name":"secondary","balances":[{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"USD"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"XBT"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"EUR"},{"availableBalance":"0.00000000","totalBalance":"0.00000000","currency":"SGD"}],"accountIdentifier":"PRIVATEBETA55-2285-2E1"},{"id":"b440efce-a83c-4873-8833-802a1022b476","userId":"326a3369-78fc-44e7-ad52-03e97371ca72","name":"Wallet","balances":[{"availableBalance":"98897.00000000","totalBalance":"98897.00000000","currency":"USD"},{"availableBalance":"10006.01500000","totalBalance":"10006.01500000","currency":"XBT"},{"availableBalance":"100456.38207201","totalBalance":"100456.38207201","currency":"EUR"},{"availableBalance":"100000.00000000","totalBalance":"100000.00000000","currency":"SGD"}],"accountIdentifier":"PRIVATEBETA55-2285-26Z"}]
data/spec/wallet_spec.rb CHANGED
@@ -4,23 +4,29 @@ describe Itbit::Wallet do
4
4
  it 'lists all' do
5
5
  stub_get("/wallets", 'wallets', userId: Itbit.user_id)
6
6
  wallets = Itbit::Wallet.all
7
- wallets.size.should == 2
7
+ wallets.size.should == 3
8
8
  wallets.first.should == {
9
- id: "3F2504E0-4F89-41D3-9A0C-0305E82C3301",
10
- name: "Wallet",
9
+ id: "fae1ce9a-848d-479b-b059-e93cb026cdf9",
10
+ name: "primary",
11
+ user_id: "326a3369-78fc-44e7-ad52-03e97371ca72",
12
+ account_identifier: "PRIVATEBETA55-2285-2HN",
11
13
  balances: [
12
- { balance: "10203.25".to_d,
13
- currency_code: :usd,
14
- trading_balance: "10003.25".to_d
14
+ { total_balance: "20.0".to_d,
15
+ currency: :usd,
16
+ available_balance: "10.0".to_d
15
17
  },
16
- { balance: "402.110".to_d,
17
- currency_code: :xbt,
18
- trading_balance: "402.110".to_d
18
+ { total_balance: "0.0".to_d,
19
+ currency: :xbt,
20
+ available_balance: "0.0".to_d
21
+ },
22
+ { total_balance: "0.0".to_d,
23
+ currency: :eur,
24
+ available_balance: "0.0".to_d
25
+ },
26
+ { total_balance: "0.0".to_d,
27
+ currency: :sgd,
28
+ available_balance: "0.0".to_d
19
29
  },
20
- { balance: "0.00".to_d,
21
- currency_code: :eur,
22
- trading_balance: "0.00".to_d
23
- }
24
30
  ]
25
31
  }
26
32
  end
@@ -28,6 +34,6 @@ describe Itbit::Wallet do
28
34
  it 'creates a wallet' do
29
35
  stub_post("/wallets", 'wallet', name: 'Wallet', userId: Itbit.user_id)
30
36
  wallet = Itbit::Wallet.create!('Wallet')
31
- wallet[:id].should == "3F2504E0-4F89-41D3-9A0C-0305E82C3301"
37
+ wallet[:id].should == "fae1ce9a-848d-479b-b059-e93cb026cdf9"
32
38
  end
33
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: