bitstamp_client 1.1.0 → 1.2.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
  SHA256:
3
- metadata.gz: 3b8a4f622fc63947b187391a2f3cf52db990a1f793dd5cc6d832670afbbb9153
4
- data.tar.gz: 6f22c74ebdb91f9afa9f36fddb144a752ed439451b0f9aea6886006bd0705fd5
3
+ metadata.gz: 668a5e511c84ba9820c123900ae2fd6fb7a71bf52cff88e3de004687c5b03d10
4
+ data.tar.gz: 473dffa2f501d69394a92aa882a35d5f9b9ca406e98d2df2eb2b352d79df57ab
5
5
  SHA512:
6
- metadata.gz: 3e7f33f7f4fd5d1bd9ef0454111577eef0886d094164df6321ea560402b7c7f791b7f83917284ffaad89e709d7f6c6f14727cc5678ea6b68a33db86f80e9124c
7
- data.tar.gz: 8576a8c6f58623a34119806c2015eb208422396751f6620c0e2da8fe56e7e9fc9dda8e622e120733a1ce19f7d010acb518be18b442dfb3591022b8531f93c406
6
+ metadata.gz: 7a7aeb838bfa7df943db2776f8b2fdd64659fdb51e737dc0bbb719e10e6913732e63c2f2b266746d5d06d12c91da7e86eb2a4c8338daaba3dc26a544812c720b
7
+ data.tar.gz: db3637dd196c7272fa9a49ee7f70db0b927c6b0333e9ba8908285d1b003884c53b3f2161a8705913ffa7574072b254a117323074639ba95a5c8c10c77339a637
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.2.0] - 2019-01-09
8
+ ### Added
9
+ - Add `balance` API call to get balances
10
+
7
11
  ## [1.1.0] - 2019-01-07
8
12
  ### Fixed
9
13
  - Factories updated to FactoryBot
@@ -8,10 +8,12 @@ require "bitstamp_client/models/market_order"
8
8
  require "bitstamp_client/models/order"
9
9
  require "bitstamp_client/models/order_book"
10
10
  require "bitstamp_client/requests/base_request"
11
+ require "bitstamp_client/requests/balance_request"
11
12
  require "bitstamp_client/requests/exchange_rate_request"
12
13
  require "bitstamp_client/requests/order_book_request"
13
14
  require "bitstamp_client/requests/place_market_order_request"
14
15
  require "bitstamp_client/responses/base_response"
16
+ require "bitstamp_client/responses/balance_response"
15
17
  require "bitstamp_client/responses/exchange_rate_response"
16
18
  require "bitstamp_client/responses/order_book_response"
17
19
  require "bitstamp_client/responses/place_market_order_response"
@@ -9,6 +9,7 @@ module BitstampClient
9
9
  api_action :order_book, args: [:currency_pair]
10
10
  api_action :exchange_rate, args: [:currency_pair]
11
11
  api_action :place_market_order
12
+ api_action :balance
12
13
 
13
14
  private
14
15
 
@@ -0,0 +1,35 @@
1
+ module BitstampClient
2
+ class BalanceRequest < BaseRequest
3
+
4
+ attribute :nonce, Integer
5
+ attribute :signature, String, default: :default_signature
6
+
7
+ private
8
+
9
+ def body
10
+ {
11
+ key: key,
12
+ signature: signature,
13
+ nonce: nonce,
14
+ }
15
+ end
16
+
17
+ def path
18
+ "/api/v2/balance/"
19
+ end
20
+
21
+ def action
22
+ :post
23
+ end
24
+
25
+ def headers
26
+ { 'Content-Type' => 'application/x-www-form-urlencoded' }
27
+ end
28
+
29
+ def default_signature
30
+ GenSignature.
31
+ (key: key, secret: secret, nonce: nonce, customer_id: customer_id)
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,52 @@
1
+ module BitstampClient
2
+ class BalanceResponse < BaseResponse
3
+
4
+ KNOWN_FIELDS = %i[
5
+ usd_balance
6
+ btc_balance
7
+ eur_balance
8
+ xrp_balance
9
+ usd_reserved
10
+ btc_reserved
11
+ eur_reserved
12
+ xrp_reserved
13
+ usd_available
14
+ btc_available
15
+ eur_available
16
+ xrp_available
17
+ btcusd_fee
18
+ btceur_fee
19
+ eurusd_fee
20
+ xrpusd_fee
21
+ xrpeur_fee
22
+ xrpbtc_fee
23
+ fee
24
+ ].freeze
25
+
26
+ KNOWN_FIELDS.each do |field|
27
+ attribute field, BigDecimal, default: :"default_#{field}"
28
+
29
+ define_method :"default_#{field}" do
30
+ parsed_body[field.to_s]
31
+ end
32
+ end
33
+
34
+ def method_missing(method_name, *args)
35
+ super if !parsed_body.has_key?(method_name.to_s)
36
+
37
+ self.class.define_method(method_name) do
38
+ BigDecimal.new(parsed_body[method_name.to_s])
39
+ end
40
+
41
+ self.send(method_name)
42
+ end
43
+
44
+ private
45
+
46
+
47
+ def default_order_book
48
+ OrderBook.new(JSON.parse(body))
49
+ end
50
+
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module BitstampClient
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitstamp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-07 00:00:00.000000000 Z
11
+ date: 2019-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -178,10 +178,12 @@ files:
178
178
  - lib/bitstamp_client/models/market_order.rb
179
179
  - lib/bitstamp_client/models/order.rb
180
180
  - lib/bitstamp_client/models/order_book.rb
181
+ - lib/bitstamp_client/requests/balance_request.rb
181
182
  - lib/bitstamp_client/requests/base_request.rb
182
183
  - lib/bitstamp_client/requests/exchange_rate_request.rb
183
184
  - lib/bitstamp_client/requests/order_book_request.rb
184
185
  - lib/bitstamp_client/requests/place_market_order_request.rb
186
+ - lib/bitstamp_client/responses/balance_response.rb
185
187
  - lib/bitstamp_client/responses/base_response.rb
186
188
  - lib/bitstamp_client/responses/exchange_rate_response.rb
187
189
  - lib/bitstamp_client/responses/order_book_response.rb