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 +1 -9
- data/lib/itbit/version.rb +1 -1
- data/lib/itbit/wallet.rb +8 -5
- data/spec/fixtures/wallet.json +1 -1
- data/spec/fixtures/wallets.json +1 -1
- data/spec/wallet_spec.rb +20 -14
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
itbit (0.0.
|
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
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(
|
20
|
-
wallet.
|
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
|
-
{
|
23
|
-
|
24
|
-
|
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
|
data/spec/fixtures/wallet.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"id":"
|
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"}
|
data/spec/fixtures/wallets.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[{"id":"
|
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 ==
|
7
|
+
wallets.size.should == 3
|
8
8
|
wallets.first.should == {
|
9
|
-
id: "
|
10
|
-
name: "
|
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
|
-
{
|
13
|
-
|
14
|
-
|
14
|
+
{ total_balance: "20.0".to_d,
|
15
|
+
currency: :usd,
|
16
|
+
available_balance: "10.0".to_d
|
15
17
|
},
|
16
|
-
{
|
17
|
-
|
18
|
-
|
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 == "
|
37
|
+
wallet[:id].should == "fae1ce9a-848d-479b-b059-e93cb026cdf9"
|
32
38
|
end
|
33
39
|
end
|