bitopro 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 400df4fabd57efac65d8ce91cf6b8b1f6f5175dfecd142e0639f7134cb83a466
4
- data.tar.gz: '06871ef22a043496f61aac115ecdd869d2187749864cdd725c44e0a87f2554fb'
3
+ metadata.gz: 702e22156760e7587f16f08495dc420e32fe2ff085c153486c152ba6378e3e2e
4
+ data.tar.gz: '074962b5a5f02e99f9acd29d530d9f4ed742eb12795f54c39280fc833d8bba66'
5
5
  SHA512:
6
- metadata.gz: a7a76aaf65109f2a8273c1234189c6fef9ab649e2e70d07bf25058622c4fb06a33d6046a29432a4b42f5bf7ef29a8ac6b916d7cfa50ef950e2d3eaf0355272f2
7
- data.tar.gz: c2aab8d98acbf5b6ea015ec41596f6902c53dc57d5fbf47f7980a29c96869cef6c0858f5b2251bb8a5e8689b87a9a7fd803d07088df6b3f9b5988cc4ea1f7997
6
+ metadata.gz: 4ca8a92af4cf42936837c3713a6c8a27fdace328e242d27c9a6b6311017202573ad3d1e5157ca6a94517112d3d8f2368406c02cca4e8b87f91dbebe854d85ab7
7
+ data.tar.gz: df9a9757c3c53db3e536fa8d0ab30bca53d7334d2a095819282d68e4c0865b0d8ce01ad833cef7d0a0636deb1a6cc5df7ac8b28cc8307de26488874159550c8a
@@ -1,14 +1,22 @@
1
1
  module Bitopro
2
2
  module Public
3
+ class Error < StandardError; end
4
+
3
5
  def order_book(currency_pair)
6
+ raise Error, "currency_pair is required" unless currency_pair
7
+
4
8
  get("/order-book/#{currency_pair}")
5
9
  end
6
10
 
7
- def ticker(currency_pair)
8
- get("/ticker/#{currency_pair}")
11
+ def tickers(currency_pair)
12
+ raise Error, "currency_pair is required" unless currency_pair
13
+
14
+ get("/tickers/#{currency_pair}")
9
15
  end
10
16
 
11
17
  def recent_trades(currency_pair)
18
+ raise Error, "currency_pair is required" unless currency_pair
19
+
12
20
  get("/trades/#{currency_pair}")
13
21
  end
14
22
  end
@@ -4,7 +4,7 @@ require_relative './api/order'
4
4
 
5
5
  module Bitopro
6
6
  class Client
7
- class BitoproSetupError < StandardError; end
7
+ class SetupError < StandardError; end
8
8
 
9
9
  BASE_URL = "https://api.bitopro.com/v2".freeze
10
10
 
@@ -23,7 +23,7 @@ module Bitopro
23
23
  end
24
24
 
25
25
  def authenticated_get(url, params = {})
26
- raise BitoproSetupError, "Must be set configure before call authenticate action" unless Bitopro.configured?
26
+ raise SetupError, "Must be set configure before call authenticate action" unless Bitopro.configured?
27
27
 
28
28
  complete_url = build_url(url)
29
29
 
@@ -41,7 +41,7 @@ module Bitopro
41
41
  end
42
42
 
43
43
  def authenticated_post(url, params = {})
44
- raise BitoproSetupError, "Must be set configure before call authenticate action" unless Bitopro.configured?
44
+ raise SetupError, "Must be set configure before call authenticate action" unless Bitopro.configured?
45
45
 
46
46
  complete_url = build_url(url)
47
47
 
@@ -1,3 +1,3 @@
1
1
  module Bitopro
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
@@ -0,0 +1,72 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Bitopro::Client do
4
+ describe "#order_book" do
5
+ subject { Bitopro::Client.new.order_book(currency_pair) }
6
+
7
+ context "when currency pair is empty" do
8
+ let(:currency_pair) { nil }
9
+
10
+ it { is_expected_block.to raise_error Bitopro::Public::Error }
11
+ end
12
+
13
+ context "when api succeeds" do
14
+ let(:currency_pair) { "btc_twd" }
15
+ let!(:request_stub) do
16
+ stub_request(:get, "#{Bitopro::BASE_URL}/order-book/#{currency_pair}")
17
+ .to_return(status: 200, body: json_fixture('order-book'))
18
+ end
19
+
20
+ it "return parsed json order book" do
21
+ subject
22
+ expect(request_stub).to have_been_requested
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "#ticker" do
28
+ subject { Bitopro::Client.new.ticker(currency_pair) }
29
+
30
+ context "when currency pair is empty" do
31
+ let(:currency_pair) { nil }
32
+
33
+ it { is_expected_block.to raise_error Bitopro::Public::Error }
34
+ end
35
+
36
+ context "when api succeeds" do
37
+ let(:currency_pair) { "btc_twd" }
38
+ let!(:request_stub) do
39
+ stub_request(:get, "#{Bitopro::BASE_URL}/ticker/#{currency_pair}")
40
+ .to_return(status: 200, body: json_fixture('ticker'))
41
+ end
42
+
43
+ it "return parsed json order book" do
44
+ subject
45
+ expect(request_stub).to have_been_requested
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#recent_trades" do
51
+ subject { Bitopro::Client.new.recent_trades(currency_pair) }
52
+
53
+ context "when currency pair is empty" do
54
+ let(:currency_pair) { nil }
55
+
56
+ it { is_expected_block.to raise_error Bitopro::Public::Error }
57
+ end
58
+
59
+ context "when api succeeds" do
60
+ let(:currency_pair) { "btc_twd" }
61
+ let!(:request_stub) do
62
+ stub_request(:get, "#{Bitopro::BASE_URL}/trades/#{currency_pair}")
63
+ .to_return(status: 200, body: json_fixture('recent_trades'))
64
+ end
65
+
66
+ it "return parsed json order book" do
67
+ subject
68
+ expect(request_stub).to have_been_requested
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Bitopro::Config do
4
+ describe ".configure" do
5
+ before do
6
+ described_class.instance = described_class.new
7
+ end
8
+
9
+ it "makes Bitopro configured" do
10
+ expect(Bitopro).not_to be_configured
11
+
12
+ Bitopro.configure do |config|
13
+ config.email = "bitopro@ruby.rspec"
14
+ config.key = "1"
15
+ config.secret = "2"
16
+ end
17
+
18
+ expect(Bitopro).to be_configured
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Bitopro do
4
+ it "has a version number" do
5
+ expect(described_class::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "amount": "0.11000000",
5
+ "isBuyer": false,
6
+ "price": "126709.00000000",
7
+ "timestamp": 1551753875
8
+ },
9
+ {
10
+ "amount": "0.10000000",
11
+ "isBuyer": false,
12
+ "price": "126787.00000000",
13
+ "timestamp": 1551753796
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "high": "7000",
3
+ "lastPrice": "7000",
4
+ "low": "6000",
5
+ "timestamp": 1508753757000,
6
+ "volume": "16.7"
7
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitopro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - niclin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-18 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,8 +108,12 @@ files:
108
108
  - lib/bitopro/client.rb
109
109
  - lib/bitopro/config.rb
110
110
  - lib/bitopro/version.rb
111
- - spec/bitopro/api_spec.rb
111
+ - spec/bitopro/client_spec.rb
112
+ - spec/bitopro/config_spec.rb
113
+ - spec/bitopro/version_spec.rb
112
114
  - spec/fixtures/order-book.json
115
+ - spec/fixtures/recent_trades.json
116
+ - spec/fixtures/ticker.json
113
117
  - spec/spec_helper.rb
114
118
  - spec/support/rspec_helpers.rb
115
119
  homepage: https://github.com/niclin/bitopro
@@ -137,9 +141,13 @@ rubyforge_project:
137
141
  rubygems_version: 2.7.8
138
142
  signing_key:
139
143
  specification_version: 4
140
- summary: bitopro-1.0.0
144
+ summary: bitopro-1.0.1
141
145
  test_files:
142
146
  - spec/spec_helper.rb
143
- - spec/bitopro/api_spec.rb
147
+ - spec/bitopro/config_spec.rb
148
+ - spec/bitopro/client_spec.rb
149
+ - spec/bitopro/version_spec.rb
144
150
  - spec/support/rspec_helpers.rb
151
+ - spec/fixtures/ticker.json
145
152
  - spec/fixtures/order-book.json
153
+ - spec/fixtures/recent_trades.json
@@ -1,51 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Bitopro do
4
- it "has a version number" do
5
- expect(Bitopro::VERSION).not_to be nil
6
- end
7
-
8
- describe ".configure" do
9
- before do
10
- Bitopro::Config.instance = Bitopro::Config.new
11
- end
12
-
13
- it "makes Bitopro configured" do
14
- expect(described_class).not_to be_configured
15
-
16
- described_class.configure do |config|
17
- config.email = "bitopro@ruby.rspec"
18
- config.key = "1"
19
- config.secret = "2"
20
- end
21
-
22
- expect(described_class).to be_configured
23
- end
24
- end
25
-
26
- describe "#order_book" do
27
- let(:currency_pair) { "btc_twd" }
28
-
29
- subject { Bitopro::Client.new.order_book(currency_pair) }
30
-
31
- context "when currency pair is empty" do
32
-
33
- end
34
-
35
- context "when api responds with error" do
36
-
37
- end
38
-
39
- context "when api succeeds" do
40
- let!(:request_stub) do
41
- stub_request(:get, "#{Bitopro::BASE_URL}/order-book/#{currency_pair}")
42
- .to_return(status: 200, body: json_fixture('order-book'))
43
- end
44
-
45
- it "return parsed json order book" do
46
- subject
47
- expect(request_stub).to have_been_requested
48
- end
49
- end
50
- end
51
- end