mexbt-transfer-api 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mexbt_transfer_api.rb +19 -7
- data/lib/mexbt_transfer_api/version.rb +1 -1
- data/spec/transfer_api_spec.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14be930cb3afbb63d5954d5aba4e8648907b6f84
|
4
|
+
data.tar.gz: bc50d4b44c5af4ebaf558ad44e197bbb0f41c9df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 401aef1b248a249bea9f849202270043057851a21b1f1d2ef947200b68d718b6daeb8f3d2e7c4d644393942819cced96a925af9ae813ac948bd730e8cbd06a58
|
7
|
+
data.tar.gz: f69c2e7c1d877e11dbb2f0e7009246c9646cdc673d84b0cffd70b948acc504f80214096c520a47a48607aea4ff7b6cb24b0cb5ebf61f8b8583e7cafa7a745666
|
data/lib/mexbt_transfer_api.rb
CHANGED
@@ -12,10 +12,14 @@ module Mexbt
|
|
12
12
|
@api_secret = api_secret
|
13
13
|
@client_id = client_id
|
14
14
|
@endpoint = endpoint
|
15
|
+
raise "Api key cannot be null" if @api_key.nil?
|
16
|
+
raise "Api secret cannot be null" if @api_secret.nil?
|
17
|
+
raise "Client id cannot be null" if @client_id.nil?
|
15
18
|
end
|
16
19
|
|
17
20
|
def create_order(in_currency:, out_currency:, out_via:, webhook:, in_amount: 0, out_amount: 0,
|
18
21
|
sender_info: {}, recipient_info: {}, skip_deposit_address_setup: false)
|
22
|
+
raise "You must specify a value for either in or out" if in_amount.nil? && out_amount.nil?
|
19
23
|
params = {
|
20
24
|
in_currency: in_currency,
|
21
25
|
out_currency: out_currency,
|
@@ -25,12 +29,20 @@ module Mexbt
|
|
25
29
|
recipient_info: recipient_info,
|
26
30
|
skip_deposit_address_setup: skip_deposit_address_setup
|
27
31
|
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
amounts = {
|
33
|
+
in: in_amount,
|
34
|
+
out: out_amount
|
35
|
+
}
|
36
|
+
[:in, :out].each do |a|
|
37
|
+
amount = amounts[a]
|
38
|
+
if amount && amount.kind_of?(String)
|
39
|
+
amounts[a] = BigDecimal.new(amount)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
if amounts[:in] > 0
|
43
|
+
params[:in] = amounts[:in]
|
44
|
+
elsif amounts[:out] > 0
|
45
|
+
params[:out] = amounts[:out]
|
34
46
|
end
|
35
47
|
call("/orders", params)
|
36
48
|
end
|
@@ -77,4 +89,4 @@ module Mexbt
|
|
77
89
|
end
|
78
90
|
|
79
91
|
end
|
80
|
-
end
|
92
|
+
end
|
data/spec/transfer_api_spec.rb
CHANGED
@@ -30,6 +30,12 @@ describe Mexbt::TransferApi do
|
|
30
30
|
"status"=>"quote"
|
31
31
|
})
|
32
32
|
end
|
33
|
+
|
34
|
+
context "validation" do
|
35
|
+
it "rejects orders without an in or out amount specified" do
|
36
|
+
expect {transfer_api.create_order(in_currency: 'btc', out_currency: 'mxn', out_via: 'atm', webhook: nil, in_amount: nil, out_amount: nil)}.to raise_error("You must specify a value for either in or out")
|
37
|
+
end
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
context "getting orders" do
|
@@ -38,4 +44,4 @@ describe Mexbt::TransferApi do
|
|
38
44
|
|
39
45
|
end
|
40
46
|
|
41
|
-
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mexbt-transfer-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- williamcoates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|