viabtc 1.3.0 → 1.4.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: 2cbededaf7cdf0ab5ea287d35be0d780e65f8ed1071550b362570bd70fbe268c
4
- data.tar.gz: ad75701f8f8ecd209ff65f0c35b533ccd8518a2177f103ecb2f9e7b4483cfcd9
3
+ metadata.gz: 3f05110edb45d3b8f373d712d0537caee80c5ab4b0a9a0635338c377b72c0452
4
+ data.tar.gz: ee8853ae0fab153a83358c8082d83c9c4a6ad2d9e891320386c6b52081d5a7bb
5
5
  SHA512:
6
- metadata.gz: 832bf9c0df30e08b77b95101a8080bd4edc3c42fb463d8d087282873ed2df84060ac8155d673b24d3513e04b67e6697e739bb6e58bc58e54cf3771975d64d156
7
- data.tar.gz: 29db96a04a099eadf4fec6c9e15be3da69a6c9dbc3ed48699d70b0209cdc496f910da97109142ca6c1e037150c710bee20a686d62082159b8e3931c3262fd245
6
+ metadata.gz: ea9a94479d803461d7a12c929ad0d896cf76c245c1dd42e76083a115e7a13d7879027b1dc8256b791ba180a7b81d153d6bbba625219dbbaf87880f83a8c989c6
7
+ data.tar.gz: 6225491f5cde3c67d638f0c3868cf0d3adb58ef015ac772856477b12e27f004a73681392212ebd6d6332886b9c4f0ff3a06cd095177b02fde800e0da94a69d73
@@ -0,0 +1,24 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ name: Publish Packages
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ bundler-cache: true
19
+
20
+ - name: Publish to RubyGems
21
+ uses: dawidd6/action-publish-gem@v1
22
+ with:
23
+ api_key: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
24
+ github_token: ${{secrets.VIABTC_GITHUB_AUTH_TOKEN}}
@@ -0,0 +1,54 @@
1
+ name: Test
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ push:
7
+ branches: [ develop, master ]
8
+
9
+ env:
10
+ GIT_COMMIT_SHA: ${{ github.sha }}
11
+ GIT_BRANCH: ${{ github.ref }}
12
+ COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
13
+
14
+ jobs:
15
+
16
+ lint:
17
+ runs-on: ubuntu-latest
18
+ name: lint ${{ matrix.ruby }}
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ ruby: [ '2.6.9', '2.7.5', '3.0.3', '3.1.1' ]
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+
31
+ - name: StandardRB
32
+ continue-on-error: ${{ matrix.experimental }}
33
+ run: bundle exec standardrb --parallel --format progress
34
+
35
+ test:
36
+ needs: [ lint ]
37
+ runs-on: ubuntu-latest
38
+ name: test ${{ matrix.ruby }}
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ ruby: [ '2.6.9', '2.7.5', '3.0.3', '3.1.1' ]
43
+
44
+ steps:
45
+ - uses: actions/checkout@v2
46
+ - uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true
50
+
51
+ - name: Test
52
+ continue-on-error: ${{ matrix.experimental }}
53
+ run: bundle exec rake
54
+
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.1
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
data/Gemfile.lock CHANGED
@@ -1,39 +1,87 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- viabtc (1.3.0)
5
- faraday (~> 1.0.1)
4
+ viabtc (1.4.0)
5
+ faraday (~> 2.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- diff-lcs (1.3)
11
- faraday (1.0.1)
12
- multipart-post (>= 1.2, < 3)
13
- multipart-post (2.1.1)
14
- rake (13.0.1)
15
- rspec (3.9.0)
16
- rspec-core (~> 3.9.0)
17
- rspec-expectations (~> 3.9.0)
18
- rspec-mocks (~> 3.9.0)
19
- rspec-core (3.9.2)
20
- rspec-support (~> 3.9.3)
21
- rspec-expectations (3.9.2)
10
+ ast (2.4.2)
11
+ coveralls_reborn (0.24.0)
12
+ simplecov (>= 0.18.1, < 0.22.0)
13
+ term-ansicolor (~> 1.6)
14
+ thor (>= 0.20.3, < 2.0)
15
+ tins (~> 1.16)
16
+ diff-lcs (1.5.0)
17
+ docile (1.4.0)
18
+ faraday (2.2.0)
19
+ faraday-net_http (~> 2.0)
20
+ ruby2_keywords (>= 0.0.4)
21
+ faraday-net_http (2.0.1)
22
+ parallel (1.21.0)
23
+ parser (3.1.1.0)
24
+ ast (~> 2.4.1)
25
+ rainbow (3.1.1)
26
+ rake (13.0.6)
27
+ regexp_parser (2.2.1)
28
+ rexml (3.2.5)
29
+ rspec (3.11.0)
30
+ rspec-core (~> 3.11.0)
31
+ rspec-expectations (~> 3.11.0)
32
+ rspec-mocks (~> 3.11.0)
33
+ rspec-core (3.11.0)
34
+ rspec-support (~> 3.11.0)
35
+ rspec-expectations (3.11.0)
22
36
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.9.0)
24
- rspec-mocks (3.9.1)
37
+ rspec-support (~> 3.11.0)
38
+ rspec-mocks (3.11.0)
25
39
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.9.0)
27
- rspec-support (3.9.3)
40
+ rspec-support (~> 3.11.0)
41
+ rspec-support (3.11.0)
42
+ rubocop (1.25.1)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.1.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml
48
+ rubocop-ast (>= 1.15.1, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.16.0)
52
+ parser (>= 3.1.1.0)
53
+ rubocop-performance (1.13.3)
54
+ rubocop (>= 1.7.0, < 2.0)
55
+ rubocop-ast (>= 0.4.0)
56
+ ruby-progressbar (1.11.0)
57
+ ruby2_keywords (0.0.5)
58
+ simplecov (0.21.2)
59
+ docile (~> 1.1)
60
+ simplecov-html (~> 0.11)
61
+ simplecov_json_formatter (~> 0.1)
62
+ simplecov-html (0.12.3)
63
+ simplecov_json_formatter (0.1.4)
64
+ standard (1.7.3)
65
+ rubocop (= 1.25.1)
66
+ rubocop-performance (= 1.13.3)
67
+ sync (0.5.0)
68
+ term-ansicolor (1.7.1)
69
+ tins (~> 1.0)
70
+ thor (1.2.1)
71
+ tins (1.31.0)
72
+ sync
73
+ unicode-display_width (2.1.0)
28
74
 
29
75
  PLATFORMS
30
- ruby
76
+ x86_64-linux
31
77
 
32
78
  DEPENDENCIES
33
79
  bundler
80
+ coveralls_reborn
34
81
  rake
35
82
  rspec
83
+ standard
36
84
  viabtc!
37
85
 
38
86
  BUNDLED WITH
39
- 2.1.4
87
+ 2.3.7
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ViaBTC 📈
2
2
 
3
- [![Build Status](https://travis-ci.org/krmbzds/viabtc.svg?branch=develop)](https://travis-ci.org/krmbzds/viabtc) [![Downloaded](https://img.shields.io/gem/dt/viabtc.svg)](https://rubygems.org/gems/viabtc) [![Gem Version](https://img.shields.io/gem/v/viabtc.svg)](https://rubygems.org/gems/viabtc) [![RubyDoc](https://img.shields.io/badge/rubydoc-info-blue.svg)](https://www.rubydoc.info/gems/viabtc/)
3
+ [![Build Status](https://img.shields.io/github/workflow/status/krmbzds/viabtc/Test/develop)](https://github.com/krmbzds/viabtc/actions/workflows/test.yml) [![Downloaded](https://img.shields.io/gem/dt/viabtc.svg)](https://rubygems.org/gems/viabtc) [![Coveralls](https://img.shields.io/coveralls/github/krmbzds/viabtc/develop)](https://coveralls.io/github/krmbzds/viabtc?branch=develop) [![Gem Version](https://img.shields.io/gem/v/viabtc.svg)](https://rubygems.org/gems/viabtc) [![RubyDoc](https://img.shields.io/badge/rubydoc-info-blue.svg)](https://www.rubydoc.info/gems/viabtc/)
4
4
 
5
5
  An HTTP client to interface with the open-source [ViaBTC Exchange Server][ViaBTC Exchange Server Repo].
6
6
 
@@ -40,9 +40,10 @@ viabtc_http_client.market_status(market: 'ETHBTC')
40
40
 
41
41
  #### Ruby Versions Tested Against
42
42
 
43
- - ✅ `2.7.1` (stable)
44
- - ✅ `2.6.6` (stable)
45
- - `2.5.8` (security maintenance)
43
+ - ✅ `3.1.1` (stable)
44
+ - ✅ `3.0.3` (stable)
45
+ - `2.7.5` (stable)
46
+ - ⏳ `2.6.9` (security maintenance)
46
47
 
47
48
  #### ViaBTC Exchange Server API Support
48
49
 
@@ -73,7 +74,7 @@ Yes.
73
74
 
74
75
  ## License
75
76
 
76
- Copyright © 2019-2020 [Kerem Bozdas][Personal Webpage]
77
+ Copyright © 2019-2022 [Kerem Bozdas][Personal Webpage]
77
78
 
78
79
  This gem is available under the terms of the [MIT License][License].
79
80
 
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'viabtc'
4
+ require "bundler/setup"
5
+ require "viabtc"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require 'viabtc'
11
11
  # require 'pry'
12
12
  # Pry.start
13
13
 
14
- require 'irb'
14
+ require "irb"
15
15
  IRB.start(__FILE__)
data/lib/viabtc/error.rb CHANGED
@@ -3,37 +3,37 @@
3
3
  module ViaBTC
4
4
  module Error
5
5
  # ViaBTC Module Error Classes
6
- ViaBTCError = Class.new(StandardError) # Module Base Error Class
7
- Configuration = Class.new(ViaBTCError) # Module Config Error
8
- InvalidParameter = Class.new(ViaBTCError) # Module Invalid Param Error
6
+ ViaBTCError = Class.new(StandardError) # Module Base Error Class
7
+ Configuration = Class.new(ViaBTCError) # Module Config Error
8
+ InvalidParameter = Class.new(ViaBTCError) # Module Invalid Param Error
9
9
 
10
10
  # ViaBTC Exchange Server Base Error Class
11
11
  class ExchangeError < StandardError
12
12
  attr_reader :response
13
13
  def initialize(response)
14
- @code = response['error']['code']
15
- @message = response['error']['message']
14
+ @code = response["error"]["code"]
15
+ @message = response["error"]["message"]
16
16
  @response = response
17
17
  end
18
18
  end
19
19
 
20
20
  # ViaBTC Exchange Server General Error Codes
21
- InvalidArgument = Class.new(ExchangeError) # 1: Invalid Argument
22
- InternalError = Class.new(ExchangeError) # 2: Internal Error
23
- ServiceUnavailable = Class.new(ExchangeError) # 3: Service Unavailable
24
- MethodNotFound = Class.new(ExchangeError) # 4: Method Not Found
25
- ServiceTimeout = Class.new(ExchangeError) # 5: Service Timeout
26
- RequireAuthentication = Class.new(ExchangeError) # 6: Require Authentication
21
+ InvalidArgument = Class.new(ExchangeError) # 1: Invalid Argument
22
+ InternalError = Class.new(ExchangeError) # 2: Internal Error
23
+ ServiceUnavailable = Class.new(ExchangeError) # 3: Service Unavailable
24
+ MethodNotFound = Class.new(ExchangeError) # 4: Method Not Found
25
+ ServiceTimeout = Class.new(ExchangeError) # 5: Service Timeout
26
+ RequireAuthentication = Class.new(ExchangeError) # 6: Require Authentication
27
27
 
28
28
  # ViaBTC Exchange Server Undocumented Error Codes with Gotchas
29
29
 
30
30
  # matchengine/me_server.c: on_cmd_order_put_limit
31
- LimitOrderBalanceNotEnough = Class.new(ExchangeError) # 10: Balance Not Enough
32
- LimitOrderAmountTooSmall = Class.new(ExchangeError) # 11: Amount Too Small
33
- LimitOrderNoEnoughTrader = Class.new(ExchangeError) # 12: No Enough Trader
31
+ LimitOrderBalanceNotEnough = Class.new(ExchangeError) # 10: Balance Not Enough
32
+ LimitOrderAmountTooSmall = Class.new(ExchangeError) # 11: Amount Too Small
33
+ LimitOrderNoEnoughTrader = Class.new(ExchangeError) # 12: No Enough Trader
34
34
 
35
35
  # matchengine/me_server.c: on_cmd_balance_update
36
- RepeatBalanceUpdate = Class.new(ExchangeError) # 10: Repeat Update
37
- BalanceNotEnough = Class.new(ExchangeError) # 11: Balance Not Enough
36
+ RepeatBalanceUpdate = Class.new(ExchangeError) # 10: Repeat Update
37
+ BalanceNotEnough = Class.new(ExchangeError) # 11: Balance Not Enough
38
38
  end
39
39
  end
@@ -3,7 +3,7 @@
3
3
  module ViaBTC
4
4
  module Helpers
5
5
  def response_invalid?(response)
6
- !response['error'].nil?
6
+ !response["error"].nil?
7
7
  end
8
8
 
9
9
  def amount_valid?(amount)
@@ -19,8 +19,8 @@ module ViaBTC
19
19
  end
20
20
 
21
21
  def raise_exchange_error(response)
22
- error_code = response['error']['code']
23
- error_message = response['error']['message']
22
+ error_code = response["error"]["code"]
23
+ error_message = response["error"]["message"]
24
24
 
25
25
  case error_code
26
26
  when 1 then raise ViaBTC::Error::InvalidArgument, response
@@ -31,14 +31,14 @@ module ViaBTC
31
31
  when 6 then raise ViaBTC::Error::RequireAuthentication, response
32
32
  when 10
33
33
  case error_message
34
- when 'balance not enough' then raise ViaBTC::Error::LimitOrderBalanceNotEnough, response
35
- when 'repeat update' then raise ViaBTC::Error::RepeatBalanceUpdate, response
34
+ when "balance not enough" then raise ViaBTC::Error::LimitOrderBalanceNotEnough, response
35
+ when "repeat update" then raise ViaBTC::Error::RepeatBalanceUpdate, response
36
36
  else raise ViaBTC::Error::ExchangeError, response
37
37
  end
38
38
  when 11
39
39
  case error_message
40
- when 'amount too small' then raise ViaBTC::Error::LimitOrderAmountTooSmall, response
41
- when 'balance not enough' then raise ViaBTC::Error::BalanceNotEnough, response
40
+ when "amount too small" then raise ViaBTC::Error::LimitOrderAmountTooSmall, response
41
+ when "balance not enough" then raise ViaBTC::Error::BalanceNotEnough, response
42
42
  end
43
43
  when 12 then raise ViaBTC::Error::LimitOrderNoEnoughTrader, response
44
44
  else raise ViaBTC::Error::ExchangeError, response
data/lib/viabtc/http.rb CHANGED
@@ -7,9 +7,9 @@ module ViaBTC
7
7
 
8
8
  def initialize(url: nil, http_response: nil, http_adapter: nil)
9
9
  if ViaBTC.configuration
10
- url ||= ViaBTC.configuration.http_base_url
10
+ url ||= ViaBTC.configuration.http_base_url
11
11
  http_response ||= ViaBTC.configuration.http_response
12
- http_adapter ||= ViaBTC.configuration.http_adapter
12
+ http_adapter ||= ViaBTC.configuration.http_adapter
13
13
  end
14
14
 
15
15
  @connection ||= connection(url, http_response, http_adapter)
@@ -18,153 +18,153 @@ module ViaBTC
18
18
  # Asset API
19
19
 
20
20
  def balance(user_id:, id: 0)
21
- request(id: id, method: 'balance.query', params: [user_id])
21
+ request(id: id, method: "balance.query", params: [user_id])
22
22
  end
23
23
 
24
- def withdraw(user_id:, asset:, withdraw_id:, amount:, source: 'web', id: 0)
24
+ def withdraw(user_id:, asset:, withdraw_id:, amount:, source: "web", id: 0)
25
25
  raise ViaBTC::Error::InvalidParameter, "invalid amount: #{amount}" unless amount_valid?(amount)
26
26
 
27
27
  request(
28
28
  id: id,
29
- method: 'balance.update',
30
- params: [user_id, asset, 'withdraw', withdraw_id, amount, { source: source }]
29
+ method: "balance.update",
30
+ params: [user_id, asset, "withdraw", withdraw_id, amount, {source: source}]
31
31
  )
32
32
  end
33
33
 
34
- def deposit(user_id:, asset:, deposit_id:, amount:, source: 'web', id: 0)
34
+ def deposit(user_id:, asset:, deposit_id:, amount:, source: "web", id: 0)
35
35
  raise ViaBTC::Error::InvalidParameter, "invalid amount: #{amount}" unless amount_valid?(amount)
36
36
 
37
37
  request(
38
38
  id: id,
39
- method: 'balance.update',
40
- params: [user_id, asset, 'deposit', deposit_id, amount, { source: source }]
39
+ method: "balance.update",
40
+ params: [user_id, asset, "deposit", deposit_id, amount, {source: source}]
41
41
  )
42
42
  end
43
43
 
44
- def balance_history(user_id:, asset:, business: '', start_time: 0, end_time: 0, offset: 0, limit: 100, id: 0)
45
- request(id: id, method: 'balance.history', params: [user_id, asset, business, start_time, end_time, offset, limit])
44
+ def balance_history(user_id:, asset:, business: "", start_time: 0, end_time: 0, offset: 0, limit: 100, id: 0)
45
+ request(id: id, method: "balance.history", params: [user_id, asset, business, start_time, end_time, offset, limit])
46
46
  end
47
47
 
48
48
  def asset_list
49
- request(method: 'asset.list', params: [])
49
+ request(method: "asset.list", params: [])
50
50
  end
51
51
 
52
52
  def asset_summary
53
- request(method: 'asset.summary', params: [])
53
+ request(method: "asset.summary", params: [])
54
54
  end
55
55
 
56
56
  # Trade API
57
57
 
58
- def limit_sell(user_id:, market:, amount:, price:, taker_fee_rate:, maker_fee_rate:, source: 'web', id: 0)
58
+ def limit_sell(user_id:, market:, amount:, price:, taker_fee_rate:, maker_fee_rate:, source: "web", id: 0)
59
59
  raise ViaBTC::Error::InvalidParameter, "invalid amount: #{amount}" unless amount_valid?(amount)
60
60
  raise ViaBTC::Error::InvalidParameter, "invalid fee rate #{taker_fee_rate}" unless fee_rate_valid?(taker_fee_rate)
61
61
  raise ViaBTC::Error::InvalidParameter, "invalid fee rate #{maker_fee_rate}" unless fee_rate_valid?(maker_fee_rate)
62
62
 
63
63
  request(
64
64
  id: id,
65
- method: 'order.put_limit',
65
+ method: "order.put_limit",
66
66
  params: [user_id, market, 1, amount, price, taker_fee_rate, maker_fee_rate, source]
67
67
  )
68
68
  end
69
69
 
70
- def limit_buy(user_id:, market:, amount:, price:, taker_fee_rate:, maker_fee_rate:, source: 'web', id: 0)
70
+ def limit_buy(user_id:, market:, amount:, price:, taker_fee_rate:, maker_fee_rate:, source: "web", id: 0)
71
71
  raise ViaBTC::Error::InvalidParameter, "invalid amount: #{amount}" unless amount_valid?(amount)
72
72
  raise ViaBTC::Error::InvalidParameter, "invalid fee rate #{taker_fee_rate}" unless fee_rate_valid?(taker_fee_rate)
73
73
  raise ViaBTC::Error::InvalidParameter, "invalid fee rate #{maker_fee_rate}" unless fee_rate_valid?(maker_fee_rate)
74
74
 
75
75
  request(
76
76
  id: id,
77
- method: 'order.put_limit',
77
+ method: "order.put_limit",
78
78
  params: [user_id, market, 2, amount, price, taker_fee_rate, maker_fee_rate, source]
79
79
  )
80
80
  end
81
81
 
82
- def market_sell(user_id:, market:, amount:, taker_fee_rate:, source: 'web', id: 0)
82
+ def market_sell(user_id:, market:, amount:, taker_fee_rate:, source: "web", id: 0)
83
83
  raise ViaBTC::Error::InvalidParameter, "invalid amount: #{amount}" unless amount_valid?(amount)
84
84
  raise ViaBTC::Error::InvalidParameter, "invalid fee rate #{taker_fee_rate}" unless fee_rate_valid?(taker_fee_rate)
85
85
 
86
86
  request(
87
87
  id: id,
88
- method: 'order.put_market',
88
+ method: "order.put_market",
89
89
  params: [user_id, market, 1, amount, taker_fee_rate.to_s, source]
90
90
  )
91
91
  end
92
92
 
93
- def market_buy(user_id:, market:, amount:, taker_fee_rate:, source: 'web', id: 0)
93
+ def market_buy(user_id:, market:, amount:, taker_fee_rate:, source: "web", id: 0)
94
94
  raise ViaBTC::Error::InvalidParameter, "invalid amount: #{amount}" unless amount_valid?(amount)
95
95
  raise ViaBTC::Error::InvalidParameter, "invalid fee rate #{taker_fee_rate}" unless fee_rate_valid?(taker_fee_rate)
96
96
 
97
97
  request(
98
98
  id: id,
99
- method: 'order.put_market',
99
+ method: "order.put_market",
100
100
  params: [user_id, market, 2, amount, taker_fee_rate.to_s, source]
101
101
  )
102
102
  end
103
103
 
104
104
  def cancel_order(user_id:, market:, order_id:, id: 0)
105
- request(id: id, method: 'order.cancel', params: [user_id, market, order_id])
105
+ request(id: id, method: "order.cancel", params: [user_id, market, order_id])
106
106
  end
107
107
 
108
108
  def order_deals(order_id:, offset: 0, limit: 100, id: 0)
109
- request(id: id, method: 'order.deals', params: [order_id, offset, limit])
109
+ request(id: id, method: "order.deals", params: [order_id, offset, limit])
110
110
  end
111
111
 
112
112
  def sell_orders(market:, offset: 0, limit: 100, id: 0)
113
- request(id: id, method: 'order.book', params: [market, 1, offset, limit])
113
+ request(id: id, method: "order.book", params: [market, 1, offset, limit])
114
114
  end
115
115
 
116
116
  def buy_orders(market:, offset: 0, limit: 100, id: 0)
117
- request(id: id, method: 'order.book', params: [market, 2, offset, limit])
117
+ request(id: id, method: "order.book", params: [market, 2, offset, limit])
118
118
  end
119
119
 
120
- def order_depth(market:, limit: 100, interval: '0', id: 0)
121
- request(id: id, method: 'order.depth', params: [market, limit, interval])
120
+ def order_depth(market:, limit: 100, interval: "0", id: 0)
121
+ request(id: id, method: "order.depth", params: [market, limit, interval])
122
122
  end
123
123
 
124
124
  def pending_orders(user_id:, market:, offset: 0, limit: 100, id: 0)
125
- request(id: id, method: 'order.pending', params: [user_id, market, offset, limit])
125
+ request(id: id, method: "order.pending", params: [user_id, market, offset, limit])
126
126
  end
127
127
 
128
128
  def pending_order_details(order_id:, market:, id: 0)
129
- request(id: id, method: 'order.pending_detail', params: [market, order_id])
129
+ request(id: id, method: "order.pending_detail", params: [market, order_id])
130
130
  end
131
131
 
132
132
  def finished_orders(user_id:, market:, start_time: 0, end_time: 0, offset: 0, limit: 100, side: 0, id: 0)
133
- request(id: id, method: 'order.finished', params: [user_id, market, start_time, end_time, offset, limit, side])
133
+ request(id: id, method: "order.finished", params: [user_id, market, start_time, end_time, offset, limit, side])
134
134
  end
135
135
 
136
136
  def finished_sell_orders(user_id:, market:, start_time: 0, end_time: 0, offset: 0, limit: 100, side: 1, id: 0)
137
- request(id: id, method: 'order.finished', params: [user_id, market, start_time, end_time, offset, limit, side])
137
+ request(id: id, method: "order.finished", params: [user_id, market, start_time, end_time, offset, limit, side])
138
138
  end
139
139
 
140
140
  def finished_buy_orders(user_id:, market:, start_time: 0, end_time: 0, offset: 0, limit: 100, side: 2, id: 0)
141
- request(id: id, method: 'order.finished', params: [user_id, market, start_time, end_time, offset, limit, side])
141
+ request(id: id, method: "order.finished", params: [user_id, market, start_time, end_time, offset, limit, side])
142
142
  end
143
143
 
144
144
  def finished_order_detail(order_id:, id: 0)
145
- request(id: id, method: 'order.finished_detail', params: [order_id])
145
+ request(id: id, method: "order.finished_detail", params: [order_id])
146
146
  end
147
147
 
148
148
  # Market API
149
149
 
150
150
  def market_last(market:, id: 0)
151
- request(id: id, method: 'market.last', params: [market])
151
+ request(id: id, method: "market.last", params: [market])
152
152
  end
153
153
 
154
154
  def market_deals(market:, limit: 10_000, last_id: 0, id: 0)
155
- request(id: id, method: 'market.deals', params: [market, limit, last_id])
155
+ request(id: id, method: "market.deals", params: [market, limit, last_id])
156
156
  end
157
157
 
158
158
  def user_executed_orders(user_id:, market:, offset: 0, limit: 100, id: 0)
159
- request(id: id, method: 'market.user_deals', params: [user_id, market, offset, limit])
159
+ request(id: id, method: "market.user_deals", params: [user_id, market, offset, limit])
160
160
  end
161
161
 
162
162
  def market_kline(market:, start_time: now - 86_400, end_time: now, interval: 3600, id: 0)
163
- request(id: id, method: 'market.kline', params: [market, start_time, end_time, interval])
163
+ request(id: id, method: "market.kline", params: [market, start_time, end_time, interval])
164
164
  end
165
165
 
166
166
  def market_status(market:, period: 86_400, id: 0)
167
- request(id: id, method: 'market.status', params: [market, period])
167
+ request(id: id, method: "market.status", params: [market, period])
168
168
  end
169
169
 
170
170
  def market_status_today(market:, id: 0)
@@ -172,34 +172,34 @@ module ViaBTC
172
172
  end
173
173
 
174
174
  def market_list(id: 0)
175
- request(id: id, method: 'market.list', params: [])
175
+ request(id: id, method: "market.list", params: [])
176
176
  end
177
177
 
178
178
  def market_summary(id: 0)
179
- request(id: id, method: 'market.summary', params: [])
179
+ request(id: id, method: "market.summary", params: [])
180
180
  end
181
181
 
182
182
  private
183
183
 
184
184
  def connection(url, http_response, http_adapter)
185
- raise ViaBTC::Error::Configuration, 'required: url' unless url
185
+ raise ViaBTC::Error::Configuration, "required: url" unless url
186
186
 
187
187
  http_response ||= :logger
188
- http_adapter ||= :net_http
188
+ http_adapter ||= :net_http
189
189
 
190
190
  Faraday.new(url) do |conn|
191
191
  conn.response http_response
192
192
  conn.adapter http_adapter
193
- conn.headers['Content-Type'] = ['application/json']
193
+ conn.headers["Content-Type"] = ["application/json"]
194
194
  end
195
195
  end
196
196
 
197
197
  def request(method:, params:, id: 0)
198
198
  response = @connection.post do |req|
199
199
  req.body = {
200
- 'id' => id,
201
- 'method' => method,
202
- 'params' => params
200
+ "id" => id,
201
+ "method" => method,
202
+ "params" => params
203
203
  }.to_json
204
204
  end
205
205
  response = JSON.parse(response.body)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViaBTC
4
- VERSION = '1.3.0'
4
+ VERSION = "1.4.0"
5
5
  end
data/lib/viabtc.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'viabtc/version'
4
- require 'viabtc/error'
5
- require 'viabtc/config'
6
- require 'viabtc/helpers'
7
- require 'viabtc/http'
3
+ require "viabtc/version"
4
+ require "viabtc/error"
5
+ require "viabtc/config"
6
+ require "viabtc/helpers"
7
+ require "viabtc/http"
8
8
 
9
- require 'faraday'
10
- require 'json'
9
+ require "faraday"
10
+ require "json"
data/viabtc.gemspec CHANGED
@@ -1,38 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'viabtc/version'
5
+ require "viabtc/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'viabtc'
9
- spec.version = ViaBTC::VERSION
10
- spec.authors = ['Kerem Bozdas']
11
- spec.email = ['krmbzds.github@gmail.com']
8
+ spec.name = "viabtc"
9
+ spec.version = ViaBTC::VERSION
10
+ spec.authors = ["Kerem Bozdas"]
11
+ spec.email = ["krmbzds.github@gmail.com"]
12
12
 
13
- spec.summary = 'ViaBTC Exchange Server API Wrapper'
14
- spec.description = 'An HTTP Client to Interface with the Open-Source ViaBTC Exchange Server'
15
- spec.homepage = 'https://github.com/krmbzds/viabtc/'
16
- spec.license = 'MIT'
13
+ spec.summary = "ViaBTC Exchange Server API Wrapper"
14
+ spec.description = "An HTTP Client to Interface with the Open-Source ViaBTC Exchange Server"
15
+ spec.homepage = "https://github.com/krmbzds/viabtc/"
16
+ spec.license = "MIT"
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
22
  end
23
23
 
24
- spec.bindir = 'exe'
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
- spec.require_paths = ['lib']
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
27
 
28
28
  # Ruby required keyword arguments
29
- spec.required_ruby_version = '>= 2.5.8'
29
+ spec.required_ruby_version = ">= 2.5.8"
30
30
 
31
31
  # Runtime dependencies
32
- spec.add_dependency 'faraday', '~> 1.0.1'
32
+ spec.add_dependency "faraday", "~> 2.2"
33
33
 
34
34
  # Development dependencies
35
- spec.add_development_dependency 'bundler'
36
- spec.add_development_dependency 'rake'
37
- spec.add_development_dependency 'rspec'
35
+ spec.add_development_dependency "bundler"
36
+ spec.add_development_dependency "rake"
37
+ spec.add_development_dependency "rspec"
38
+ spec.add_development_dependency "standard"
39
+ spec.add_development_dependency "coveralls_reborn"
38
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viabtc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kerem Bozdas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-16 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: standard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls_reborn
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: An HTTP Client to Interface with the Open-Source ViaBTC Exchange Server
70
98
  email:
71
99
  - krmbzds.github@gmail.com
@@ -74,11 +102,11 @@ extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
76
104
  - ".editorconfig"
105
+ - ".github/workflows/publish.yml"
106
+ - ".github/workflows/test.yml"
77
107
  - ".gitignore"
78
108
  - ".rspec"
79
- - ".ruby-gemset"
80
- - ".ruby-version"
81
- - ".travis.yml"
109
+ - ".tool-versions"
82
110
  - Gemfile
83
111
  - Gemfile.lock
84
112
  - LICENSE.txt
@@ -112,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
140
  - !ruby/object:Gem::Version
113
141
  version: '0'
114
142
  requirements: []
115
- rubygems_version: 3.1.3
143
+ rubygems_version: 3.3.7
116
144
  signing_key:
117
145
  specification_version: 4
118
146
  summary: ViaBTC Exchange Server API Wrapper
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- viabtc
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.7.1
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- language: ruby
3
- rvm:
4
- - 2.7.1
5
- - 2.6.6
6
- - 2.5.8
7
- before_install:
8
- - 'gem update --system'
9
- - 'gem --version'
10
- - 'gem install bundler'