bitex 0.5.0 → 0.6.0

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: '03555559d3d82a4f379a04f62d31c8ffaf2ab223'
4
- data.tar.gz: 067a8204a071250238538d2b027bc98acc7a8174
3
+ metadata.gz: 7504b1d05131be725c8c685085de3dd783cd6c19
4
+ data.tar.gz: 015ab1434b6fb8fc3fb6723293d4c3251a652ac6
5
5
  SHA512:
6
- metadata.gz: 8ff84068e327879b35f21bdb4eebc3ad1a2b23234f482b4705527b748e2184558b6f44c40e4ce0922daefdcd9e2f2b8be63765068b551167d9b1953555bfc56b
7
- data.tar.gz: be63b22da048ff45b8048ceb613150d8f0e731ee0182d700038c9fd6fb73ba5e7e4fe6762c9c48011073801924595fff9bfcecdb0eaf68280035a7b37fd13d29
6
+ metadata.gz: d2ac3d5ac05de9bb8edd92ab6d4c96aacc7c890d714949f1b65bf52f09ec9350887f9abe6566c087c3396eecb93ccf157a65cd8937f792dbc38c77898c56962e
7
+ data.tar.gz: 8cfac85e42a66e6a53744ebfdc478612801fb745703e13db5bc3222a623cb89451785dd246fed03361bd53da8e84900d1befc21b8f6cd721de0fa9dec3ea1793
@@ -17,4 +17,8 @@ module Bitex
17
17
  mattr_accessor :sandbox
18
18
  mattr_accessor :debug
19
19
  mattr_accessor :ssl_version
20
+
21
+ ORDER_BOOKS = { btc_usd: 1, btc_ars: 5, btc_pyg: 10, btc_clp: 11, btc_uyu: 12 }.freeze
22
+ class UnknownOrderBook < StandardError
23
+ end
20
24
  end
@@ -53,7 +53,10 @@ module Bitex
53
53
 
54
54
  # @visibility private
55
55
  def self.create!(order_book, amount, price, wait = false)
56
- params = { amount: amount, price: price, orderbook: { btc_usd: 1, btc_ars: 5 }[order_book] }
56
+ order_book_id = ORDER_BOOKS[order_book]
57
+ raise UnknownOrderBook, "Could not find order book #{order_book}" unless order_book_id
58
+
59
+ params = { amount: amount, price: price, orderbook: order_book_id }
57
60
 
58
61
  order = from_json(Api.private(:post, "/private#{base_path}", params))
59
62
  retries = 0
@@ -83,8 +86,6 @@ module Bitex
83
86
  end
84
87
  end
85
88
 
86
- private_class_method
87
-
88
89
  def self.find_order(order)
89
90
  find(order.id)
90
91
  rescue StandardError
@@ -92,7 +93,7 @@ module Bitex
92
93
  end
93
94
 
94
95
  def self.order_books
95
- { 1 => :btc_usd, 5 => :btc_ars }
96
+ ORDER_BOOKS.invert
96
97
  end
97
98
 
98
99
  def self.reasons
@@ -102,5 +103,7 @@ module Bitex
102
103
  def self.statuses
103
104
  { 1 => :received, 2 => :executing, 3 => :cancelling, 4 => :cancelled, 5 => :completed }
104
105
  end
106
+
107
+ private_class_method :find_order, :order_books, :reasons, :statuses
105
108
  end
106
109
  end
@@ -113,8 +113,6 @@ module Bitex
113
113
  Api.private(:get, '/private/kyc_profiles').map { |kyc| from_json(kyc) }
114
114
  end
115
115
 
116
- private_class_method
117
-
118
116
  def self.sanitize(params)
119
117
  params.merge(birth_date: params[:birth_date].strftime('%Y/%m/%d'))
120
118
  end
@@ -18,12 +18,12 @@ module Bitex
18
18
  end
19
19
  # rubocop:enable Metrics/AbcSize
20
20
 
21
- private_class_method
22
-
23
21
  def self.order_books
24
- { 1 => :btc_usd, 5 => :btc_ars }
22
+ ORDER_BOOKS.invert
25
23
  end
26
24
 
25
+ private_class_method :order_books
26
+
27
27
  def base_currency
28
28
  base_quote[0]
29
29
  end
@@ -52,10 +52,10 @@ module Bitex
52
52
  Api.private(:post, "#{base_uri}/pos_setup", params)
53
53
  end
54
54
 
55
- private_class_method
56
-
57
55
  def self.base_uri
58
56
  '/private/payments'
59
57
  end
58
+
59
+ private_class_method :base_uri
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module Bitex
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
@@ -35,4 +35,10 @@ shared_examples_for 'Order' do |api_path|
35
35
  order.cancel!
36
36
  order.status.should == :cancelling
37
37
  end
38
+
39
+ it 'blows up when unknown order book is requested' do
40
+ expect do
41
+ subject.class.create!(:bogus_order_book, 100.50, 1_000.00)
42
+ end.to raise_error Bitex::UnknownOrderBook
43
+ end
38
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nubis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-23 00:00:00.000000000 Z
12
+ date: 2018-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport