mexbt-transfer-api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fcf07436d1e15b860976fd32152bf3be4f19639
4
- data.tar.gz: 53c95f06603f12c55d9f3838d2c4142c74593607
3
+ metadata.gz: 14be930cb3afbb63d5954d5aba4e8648907b6f84
4
+ data.tar.gz: bc50d4b44c5af4ebaf558ad44e197bbb0f41c9df
5
5
  SHA512:
6
- metadata.gz: 59b3f569e5e6815fa0c67ffe1e96f788783de1f29a090b309285ccb84e825f89e7a0c18b57e98b00ea0fa6b76432b3e018a930161764d217d5ccf2454591190c
7
- data.tar.gz: bf86131a1c2b129d4c717680765cf591d62bb5aa23ac2ec053462ba4cdaf9eb416fbe586f25549bbfdfaa5d6dc6411e466d081ae7a710a619fd93de89ba20020
6
+ metadata.gz: 401aef1b248a249bea9f849202270043057851a21b1f1d2ef947200b68d718b6daeb8f3d2e7c4d644393942819cced96a925af9ae813ac948bd730e8cbd06a58
7
+ data.tar.gz: f69c2e7c1d877e11dbb2f0e7009246c9646cdc673d84b0cffd70b948acc504f80214096c520a47a48607aea4ff7b6cb24b0cb5ebf61f8b8583e7cafa7a745666
@@ -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
- if in_amount > 0
29
- params[:in] = in_amount
30
- elsif out_amount > 0
31
- params[:out] = out_amount
32
- else
33
- raise "You must specify a value for either in or out"
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
@@ -1,5 +1,5 @@
1
1
  module Mexbt
2
2
  class TransferApi
3
- CLIENT_VERSION = "0.0.2"
3
+ CLIENT_VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -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.2
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-16 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport