bitfinex-rb 0.0.5 → 0.0.6

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: 685070e19c5fd5d873dfdbf4e913af07afca0dd2
4
- data.tar.gz: 025b79fb12c285d334a4a78a1bb6f88815f187a5
3
+ metadata.gz: 20394641fe58898e7fa5501718f59ecec7e5a431
4
+ data.tar.gz: 49a23548584876b2b6d6970c1ce5336b9beb6648
5
5
  SHA512:
6
- metadata.gz: 0b739604627de5dffc0210404db6dfa51c28ce37aaaa0c6355ee4c1e58ac72f163272c01eda225e664e5d825c7225755eb5677a9c4f084c1480a39a926438b7d
7
- data.tar.gz: c67934b085c0c5d157e7a541510f03c5d1c04e37e16d52e5f400d6cc936cbe12defe79102ebf53bc44b3feb59f234cfdceff7b1d54f9053bdd017e192bcfdbfa
6
+ metadata.gz: 7f5e35855f8157c774498ab745ed8742371ace95c55bbbbb72733c6a846128fca0837aaee8020bf2306f91d59948c0540d41ce39e6f47bcf2c8b4211e0e00611
7
+ data.tar.gz: 340a63e8b1b9140b5d209dcadff434bbfc9c2f4cb604f3923305951dd5c61563841c6a334e890fa4592273fb3b27603b18f9d476f747de2c4caf591f393b4427
@@ -32,7 +32,7 @@ module Bitfinex
32
32
 
33
33
  def new_rest_connection
34
34
  Faraday.new(url: base_api_endpoint) do |conn|
35
- conn.use Faraday::Response::RaiseError
35
+ conn.use Bitfinex::CustomErrors
36
36
  conn.response :logger, Logger.new(STDOUT) , bodies: true if config.debug_connection
37
37
  conn.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
38
38
  conn.adapter :net_http
@@ -1,6 +1,33 @@
1
+ require 'faraday'
2
+
1
3
  module Bitfinex
2
4
  class ClientError < Exception; end
3
5
  class ParamsError < ClientError; end
4
6
  class InvalidAuthKeyError < ClientError; end
5
7
  class BlockMissingError < ParamsError; end
8
+ class ServerError < Exception; end # Error reported back by Binfinex server
9
+ class BadRequestError < ServerError; end
10
+ class NotFoundError < ServerError; end
11
+ class ForbiddenError < ServerError; end
12
+ class UnauthorizedError < ServerError; end
13
+ class InternalServerError < ServerError; end
14
+
15
+ class CustomErrors < Faraday::Response::Middleware
16
+ def on_complete(env)
17
+ case env[:status]
18
+ when 400
19
+ raise BadRequestError, env.body['message']
20
+ when 401
21
+ raise UnauthorizedError
22
+ when 403
23
+ raise ForbiddenError
24
+ when 404
25
+ raise NotFoundError
26
+ when 500
27
+ raise InternalServerError
28
+ else
29
+ super
30
+ end
31
+ end
32
+ end
6
33
  end
@@ -11,7 +11,7 @@ module Bitfinex
11
11
  # client.funding_book
12
12
  def funding_book(currency="usd", params = {})
13
13
  check_params(params, %i{limit_bids limit_asks})
14
- get("lendbook/#{currency}", params).body
14
+ get("lendbook/#{currency}", params: params).body
15
15
  end
16
16
 
17
17
  end
@@ -11,7 +11,7 @@ module Bitfinex
11
11
  # client.lends
12
12
  def lends(currency = "usd", params = {})
13
13
  check_params(params, %i{timestamp limit_lends})
14
- get("lends/#{currency}", params).body
14
+ get("lends/#{currency}", params: params).body
15
15
  end
16
16
 
17
17
  end
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  module Bitfinex
2
3
  module OrderbookClient
3
4
 
@@ -12,7 +13,7 @@ module Bitfinex
12
13
  # client.orderbook("btcusd")
13
14
  def orderbook(symbol="btcusd", params = {})
14
15
  check_params(params, %i{limit_bids limit_asks group})
15
- get("book/#{symbol}",params).body
16
+ get("book/#{symbol}", params: params).body
16
17
  end
17
18
 
18
19
 
@@ -19,7 +19,7 @@ module Bitfinex
19
19
  check_params(params, %i{is_hidden is_postonly ocoorder buy_price_oco})
20
20
 
21
21
  # for 'market' order, we need to pass a random positive price, not nil
22
- price ||= 0.00001 if type == "market" || type == "exchange market"
22
+ price ||= 0.001 if type == "market" || type == "exchange market"
23
23
 
24
24
  params.merge!({
25
25
  symbol: symbol,
@@ -29,7 +29,6 @@ module Bitfinex
29
29
  exchange: 'bitfinex',
30
30
  price: price.to_s
31
31
  })
32
-
33
32
  authenticated_post("order/new", params: params).body
34
33
  end
35
34
 
@@ -1,3 +1,3 @@
1
1
  module Bitfinex
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -35,10 +35,10 @@ module Bitfinex
35
35
  # client.transfer(10, 'btc', "exchange", "deposit")
36
36
  def transfer(amount, currency, wallet_from, wallet_to)
37
37
  params = {
38
- amount: amount,
39
- currency: currency,
40
- wallet_from: wallet_from,
41
- wallet_to: wallet_to
38
+ amount: amount.to_s,
39
+ currency: currency.upcase,
40
+ walletfrom: wallet_from.downcase,
41
+ walletto: wallet_to.downcase
42
42
  }
43
43
  authenticated_post("transfer", params: params).body
44
44
  end
@@ -71,8 +71,8 @@ module Bitfinex
71
71
  def withdraw(withdraw_type, walletselected, amount, params={})
72
72
  params.merge!({
73
73
  withdraw_type: withdraw_type,
74
- walletselected: walletselected,
75
- amount: amount})
74
+ walletselected: walletselected.downcase,
75
+ amount: amount.to_s})
76
76
 
77
77
  authenticated_post("withdraw", params: params).body
78
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfinex-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bitfinex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday