bitstamp_client 0.1.0 → 0.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
  SHA1:
3
- metadata.gz: 2cf2fbe93ef8d732174fe7c870a8ae1ff747ce6e
4
- data.tar.gz: 745d6026d5f8b90f6570b645453c4560ece16853
3
+ metadata.gz: 8cd9e417a1496a625f66757c0f3be12cb0a9baae
4
+ data.tar.gz: 0d67f87996b744d1e082d4793b0ceb4397a2e6aa
5
5
  SHA512:
6
- metadata.gz: a1c39a36a429403a76497db9b189adc17222aa1ba07ea44457f0b781d14679e4b1077cc459fc5f3a19943813f11555190211828cabda6d65f60e98ef3cb79ccb
7
- data.tar.gz: 3024c7cdd69588109977341a60b48827ffa397ccbc5a6ad5602b7cab573a9280cbc87efc4aa737987c95a50317c83f38a85d7a0e41ba211479444a721a7c193b
6
+ metadata.gz: ea6dd9300980b8d2000aa16c4304755a15f58a16429145a312a9300b22175a7efb7650becb4852fea348773396765ee43541278edac78034511f4f1dbaebc68e
7
+ data.tar.gz: f071d386e1b6faf6eaa189f23a32e0e74287c25c4eca3f38cab5bbc029a91eb94b3b76b46b4ef2084461a4dc70fc81aab0d151aeab6720e9e1855accdbfef474
data/CHANGELOG.md CHANGED
@@ -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
+ ## [0.2.0]
8
+ ### Added
9
+ - Add functionality to grab exchange rates
10
+
7
11
  ## [0.1.0]
8
12
  ### Added
9
13
  - Initial release. Pull order book
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "pry"
7
+ gem "pry-byebug"
data/README.md CHANGED
@@ -22,7 +22,17 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ```ruby
26
+ client = BitstampClient.new
27
+ response = client.order_book("btcusd")
28
+ response.success? # true
29
+ order_book = response.order_book
30
+ order_book.timestamp # unix timestamp
31
+ order_book.bids # Array of Order instances
32
+ order_book.asks # Array of Order instances
33
+ ```
34
+
35
+ For more, see the files in `spec/acceptance`.
26
36
 
27
37
  ## Development
28
38
 
@@ -3,11 +3,14 @@ require "typhoeus"
3
3
  require "bitstamp_client/version"
4
4
  require "bitstamp_client/client"
5
5
  require "bitstamp_client/models/base_model"
6
+ require "bitstamp_client/models/exchange_rate"
6
7
  require "bitstamp_client/models/order"
7
8
  require "bitstamp_client/models/order_book"
8
9
  require "bitstamp_client/requests/base_request"
10
+ require "bitstamp_client/requests/exchange_rate_request"
9
11
  require "bitstamp_client/requests/order_book_request"
10
12
  require "bitstamp_client/responses/base_response"
13
+ require "bitstamp_client/responses/exchange_rate_response"
11
14
  require "bitstamp_client/responses/order_book_response"
12
15
 
13
16
  module BitstampClient
@@ -4,6 +4,7 @@ module BitstampClient
4
4
  include APIClientBase::Client.module(default_opts: :default_opts)
5
5
  attribute :host, String
6
6
  api_action :order_book, args: [:currency_pair]
7
+ api_action :exchange_rate, args: [:currency_pair]
7
8
 
8
9
  private
9
10
 
@@ -0,0 +1,16 @@
1
+ module BitstampClient
2
+ class ExchangeRate < BaseModel
3
+
4
+ attribute :base_currency, String
5
+ attribute :counter_currency, String
6
+ attribute :mid_rate, Float
7
+ attribute :buy, Float
8
+ attribute :sell, Float
9
+ attribute :timestamp, Integer
10
+
11
+ def currency_pair
12
+ [base_currency, counter_currency].join
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module BitstampClient
2
+ class ExchangeRateRequest < BaseRequest
3
+
4
+ attribute :currency_pair, String
5
+
6
+ private
7
+
8
+ def path
9
+ "/api/v2/ticker/:currency_pair"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ module BitstampClient
2
+ class ExchangeRateResponse < BaseResponse
3
+
4
+ attribute(:exchange_rate, ExchangeRate, {
5
+ lazy: true,
6
+ default: :default_exchange_rate,
7
+ })
8
+
9
+ private
10
+
11
+ def default_exchange_rate
12
+ json = JSON.parse(body)
13
+ ExchangeRate.new(
14
+ buy: json["ask"],
15
+ sell: json["bid"],
16
+ mid_rate: [json["ask"].to_f, json["bid"].to_f].sum / 2,
17
+ timestamp: json["timestamp"],
18
+ )
19
+ end
20
+
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module BitstampClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.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: 0.1.0
4
+ version: 0.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: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -158,11 +158,14 @@ files:
158
158
  - lib/bitstamp_client.rb
159
159
  - lib/bitstamp_client/client.rb
160
160
  - lib/bitstamp_client/models/base_model.rb
161
+ - lib/bitstamp_client/models/exchange_rate.rb
161
162
  - lib/bitstamp_client/models/order.rb
162
163
  - lib/bitstamp_client/models/order_book.rb
163
164
  - lib/bitstamp_client/requests/base_request.rb
165
+ - lib/bitstamp_client/requests/exchange_rate_request.rb
164
166
  - lib/bitstamp_client/requests/order_book_request.rb
165
167
  - lib/bitstamp_client/responses/base_response.rb
168
+ - lib/bitstamp_client/responses/exchange_rate_response.rb
166
169
  - lib/bitstamp_client/responses/order_book_response.rb
167
170
  - lib/bitstamp_client/version.rb
168
171
  homepage: https://github.com/imacchiato/bitstamp_client-ruby
@@ -186,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
189
  version: '0'
187
190
  requirements: []
188
191
  rubyforge_project:
189
- rubygems_version: 2.6.10
192
+ rubygems_version: 2.6.11
190
193
  signing_key:
191
194
  specification_version: 4
192
195
  summary: Ruby wrapper for Bitstamp's API