viabtc 1.3.0 → 1.5.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: 4a32617f0a14be083e1fd11fc0fd5184c3006dce1affa50bad41b7123f1ec415
4
+ data.tar.gz: e7c8785a619f9aeb6919dd5542a8e538563346c3029ab68f74ee8c23643db7a3
5
5
  SHA512:
6
- metadata.gz: 832bf9c0df30e08b77b95101a8080bd4edc3c42fb463d8d087282873ed2df84060ac8155d673b24d3513e04b67e6697e739bb6e58bc58e54cf3771975d64d156
7
- data.tar.gz: 29db96a04a099eadf4fec6c9e15be3da69a6c9dbc3ed48699d70b0209cdc496f910da97109142ca6c1e037150c710bee20a686d62082159b8e3931c3262fd245
6
+ metadata.gz: 78548687590624c0a1abccc7266ed8d776692bc6779e0f6092736ed3ae2c54ba2ab5cf310ea323d324bf4b9305084ab8e5708d3617a0b4ba24a5a635f77df5a8
7
+ data.tar.gz: 546c8d6f5e280948fa8708cce52f366bf0212266b690e61ffcfb9149eb3c8d3dfade43bb7e87f2fc4608e1bef00c67cc357d47d3ed450a3380a2212bd13df20c
@@ -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: ["3.4.1", "3.3.6", "3.2.6", "3.1.6"]
23
+
24
+ steps:
25
+ - uses: actions/checkout@v4
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: ["3.4.1", "3.3.6", "3.2.6", "3.1.6"]
43
+
44
+ steps:
45
+ - uses: actions/checkout@v4
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.4.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/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Kerem Bozdas
3
+ Copyright (c) 2018-2025 Kerem Bozdas
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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/actions/workflow/status/krmbzds/viabtc/test.yml?branch=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,14 +40,42 @@ 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.4.1` (stable)
44
+ - ✅ `3.3.6` (stable)
45
+ - `3.2.6` (stable)
46
+ - ⏳ `3.1.6` (security maintenance)
47
+ - 🪦 `3.0.7` (end of life)
46
48
 
47
49
  #### ViaBTC Exchange Server API Support
48
50
 
49
51
  - 📖 [HTTP Protocol](https://github.com/krmbzds/viabtc/wiki/API-Support#http-protocol)
50
52
 
53
+ | API Method | Corresponding Methods |
54
+ |---|---|
55
+ | `balance.query` | `#balance` |
56
+ | `balance.update` | `#withdraw` `#deposit` |
57
+ | `balance.history` | `#balance_history` |
58
+ | `asset.list` | `#asset_list` |
59
+ | `asset.summary` | `#asset_summary` |
60
+ | `order.put_limit` | `#limit_sell` `#limit_buy` |
61
+ | `order.put_market` | `#market_sell` `#market_buy` |
62
+ | `order.cancel` | `#cancel_order` |
63
+ | `order.deals` | `#order_deals` |
64
+ | `order.book` | `#sell_orders` `#buy_orders` |
65
+ | `order.depth` | `#order_depth` |
66
+ | `order.pending` | `#pending_orders` |
67
+ | `order.pending_detail` | `#pending_order_details` |
68
+ | `order.finished` | `#finished_orders` `#finished_sell_orders` `#finished_buy_orders` |
69
+ | `order.finished_detail` | `#finished_order_detail` |
70
+ | `market.last` | `#market_last` |
71
+ | `market.deals` | `#market_deals` |
72
+ | `market.user_deals` | `#user_executed_orders` |
73
+ | `market.kline` | `#market_kline` |
74
+ | `market.status` | `#market_status` |
75
+ | `market.status_today` | `#market_status_today` |
76
+ | `market.list` | `#market_list` |
77
+ | `market.summary` | `#market_summary` |
78
+
51
79
  ## Development
52
80
 
53
81
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -73,7 +101,7 @@ Yes.
73
101
 
74
102
  ## License
75
103
 
76
- Copyright © 2019-2020 [Kerem Bozdas][Personal Webpage]
104
+ Copyright © 2018-2025 [Kerem Bozdas][Personal Webpage]
77
105
 
78
106
  This gem is available under the terms of the [MIT License][License].
79
107
 
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.5.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 = ">= 3.1.6"
30
30
 
31
31
  # Runtime dependencies
32
- spec.add_dependency 'faraday', '~> 1.0.1'
32
+ spec.add_dependency "faraday", "~> 2.12", ">= 2.12.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,13 @@
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.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kerem Bozdas
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2020-05-16 00:00:00.000000000 Z
10
+ date: 2025-01-01 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -16,14 +15,20 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 1.0.1
18
+ version: '2.12'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 2.12.2
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - "~>"
25
27
  - !ruby/object:Gem::Version
26
- version: 1.0.1
28
+ version: '2.12'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 2.12.2
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: bundler
29
34
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +71,34 @@ dependencies:
66
71
  - - ">="
67
72
  - !ruby/object:Gem::Version
68
73
  version: '0'
74
+ - !ruby/object:Gem::Dependency
75
+ name: standard
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ type: :development
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: coveralls_reborn
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
69
102
  description: An HTTP Client to Interface with the Open-Source ViaBTC Exchange Server
70
103
  email:
71
104
  - krmbzds.github@gmail.com
@@ -74,13 +107,11 @@ extensions: []
74
107
  extra_rdoc_files: []
75
108
  files:
76
109
  - ".editorconfig"
110
+ - ".github/workflows/test.yml"
77
111
  - ".gitignore"
78
112
  - ".rspec"
79
- - ".ruby-gemset"
80
- - ".ruby-version"
81
- - ".travis.yml"
113
+ - ".tool-versions"
82
114
  - Gemfile
83
- - Gemfile.lock
84
115
  - LICENSE.txt
85
116
  - README.md
86
117
  - Rakefile
@@ -97,7 +128,6 @@ homepage: https://github.com/krmbzds/viabtc/
97
128
  licenses:
98
129
  - MIT
99
130
  metadata: {}
100
- post_install_message:
101
131
  rdoc_options: []
102
132
  require_paths:
103
133
  - lib
@@ -105,15 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
135
  requirements:
106
136
  - - ">="
107
137
  - !ruby/object:Gem::Version
108
- version: 2.5.8
138
+ version: 3.1.6
109
139
  required_rubygems_version: !ruby/object:Gem::Requirement
110
140
  requirements:
111
141
  - - ">="
112
142
  - !ruby/object:Gem::Version
113
143
  version: '0'
114
144
  requirements: []
115
- rubygems_version: 3.1.3
116
- signing_key:
145
+ rubygems_version: 3.6.2
117
146
  specification_version: 4
118
147
  summary: ViaBTC Exchange Server API Wrapper
119
148
  test_files: []
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'
data/Gemfile.lock DELETED
@@ -1,39 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- viabtc (1.3.0)
5
- faraday (~> 1.0.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
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)
22
- diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.9.0)
24
- rspec-mocks (3.9.1)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.9.0)
27
- rspec-support (3.9.3)
28
-
29
- PLATFORMS
30
- ruby
31
-
32
- DEPENDENCIES
33
- bundler
34
- rake
35
- rspec
36
- viabtc!
37
-
38
- BUNDLED WITH
39
- 2.1.4