stocks_exchange_api_client 0.1.2 → 2.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: 3f5276b14f88f028f92918ff4d93cd54272a744b136521333d540f8db5903dbc
4
- data.tar.gz: fd9564868f88d9ff67a923dfd53848e238dff2f36949a45ce237e84c5e80c3d4
3
+ metadata.gz: 4ebadc56eaa5dd75311a797a40d4b6f910dc8b04b2da59a69f6ff78f2a4ce079
4
+ data.tar.gz: bd29fa6ecd9021eced24792c842f2d26a6a839e8b0fe07889459f557a157d476
5
5
  SHA512:
6
- metadata.gz: 44e409f86d0e545c749af69ae65351ef6a4b07daa30711371c2a5b1f4a15d4be0f35c231dcb93fe1037a4fd7e5888fcb94d63224ca079ef5012351bcf7d47c38
7
- data.tar.gz: 4012da2f6c11387904bf508024742a0c123f5bf5eb9b7b096493060e9751a13199631da6d0fc91e2f172f98405a60629e6e2b390b327639d2b554dd04f01b2a4
6
+ metadata.gz: 41ec80c652cde01e7e39f764e39d6fc9a7f4f3bd4d293786a7f08eade46c4c1f81c62ac5d9f1c84398522faaea3df192b0ff3071d66522645e338cba1d16f20e
7
+ data.tar.gz: 6a0aca2fdedc4da1c1ed2498e935bcc8c95197d7d2433b1c49b8aade9e6d25be12a674d4885a92b463e69257137575b4b827059c168b8b87662111b8acf14bf3
data/.gitignore CHANGED
@@ -49,3 +49,5 @@ build-iPhoneSimulator/
49
49
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
50
  .rvmrc
51
51
  /.idea
52
+ Gemfile.lock
53
+ settings.json
data/README.md CHANGED
@@ -12,12 +12,12 @@ STEX (former Stocks.Exchange) provides all the core exchange functionality, and
12
12
  ## General
13
13
  The base URL for all the requests other than public methods is
14
14
  ```
15
- https://app.stocks.exchange/api2
16
- https://app.stex.com/api2
15
+ https://api3.stex.com
17
16
  ```
18
17
 
19
18
  ## Getting started
20
- -[Documentation](http://help.stex.com/api-integration).
19
+ - [Documentation](http://help.stex.com/api-integration).
20
+ - [Sandbox API](https://apidocs.stex.com).
21
21
 
22
22
  To get started with the Ruby API client, here's a snippet for creating a client with existing credentials:
23
23
  > In order to use the API functions, you must have an API key and API secret, which is generated in the user profile.
@@ -31,84 +31,75 @@ After install use for example this code!
31
31
 
32
32
  ### Example
33
33
  ```ruby
34
- require 'stocks_exchange_api_client'
35
-
36
34
  StocksExchangeApiClient.configure do |conf|
37
- conf.url = 'https://app.stocks.exchange/api2'
38
- conf.api_key = '' # Your Api Key
39
- conf.api_secret = '' # Your Api Secret
35
+ conf.url = 'https://api3.stex.com'
36
+ conf.option = {
37
+ client_id: '',
38
+ client_secret: '',
39
+ token_object: {
40
+ access_token: '',
41
+ refresh_token: ''
42
+ },
43
+ access_token_url: 'https://api3.stex.com/oauth/token',
44
+ scope: 'trade profile reports withdrawal'
45
+ }
40
46
  end
41
- # Get information about your account
42
- puts StocksExchangeApiClient::Private.get_info
43
-
44
- # Get information about active orders.
45
- # Params: pair, count, order, type, owner, since, end
46
- puts StocksExchangeApiClient::Private.active_order
47
-
48
- # Create orders for the purchase and sale.
49
- # Params: type, pair, amount, rate
50
- puts StocksExchangeApiClient::Private.trade('BUY', 'LTC_BTC', 0.1, 0.00002)
51
-
52
- # Cancel selected order.
53
- # Params: order_id
54
- puts StocksExchangeApiClient::Private.cancel_order(2761025)
55
-
56
- # Get information about all orders.
57
- # Params: pair, count, order, status, owner, since, end
58
- puts StocksExchangeApiClient::Private.trade_history
59
-
60
- # Get information about all closed orders from Register
61
- # Params: currency, since, end
62
- puts StocksExchangeApiClient::Private.trade_register_history
63
-
64
- # Get information about all orders User
65
- # Params: since, end
66
- puts StocksExchangeApiClient::Private.user_history
67
-
68
- # Get information about your deposits and withdrawals.
69
- # Params: currency, count, order, operation, status
70
- puts StocksExchangeApiClient::Private.trans_history
71
-
72
- # Get information about trade statistic.
73
- # Params: currency, count, order, operation, status, since, end
74
- puts StocksExchangeApiClient::Private.grafic
75
-
76
- # Generate currency wallet address.
77
- # Params: currency
78
- puts StocksExchangeApiClient::Private.generate_wallets('ONION')
79
-
80
- # Get information about your wallet to deposit funds.
81
- # Params: currency
82
- puts StocksExchangeApiClient::Private.deposit('ETH')
83
-
84
- # Withdraw your funds.
85
- # Params: currency, address, amount
86
- puts StocksExchangeApiClient::Private.withdraw('EAG', '12345', 1.001)
87
47
 
88
- # Get all available currencies with additional info.
89
- puts StocksExchangeApiClient::Public.currencies
90
-
91
- # Get all available currency pairs with additional info.
92
- puts StocksExchangeApiClient::Public.markets
93
-
94
- # Get currency pair with additional info.
95
- # Params Currency1 and Currency2
96
- puts StocksExchangeApiClient::Public.markets_summary('BTC', 'USDT')
97
-
98
- # Use it to get the recommended retail exchange rates for all currency pairs.
99
- puts StocksExchangeApiClient::Public.ticker
100
-
101
- # Use it to get the new retail exchange rates for all currency pairs.
102
- puts StocksExchangeApiClient::Public.prices
48
+ puts StocksExchangeApiClient::PrivateApiV3.profile_info
49
+ ```
50
+ ### Example Server-To-Server integrations
51
+ ```ruby
52
+ StocksExchangeApiClient.configure do |conf|
53
+ conf.s2s = true
54
+ conf.option = {
55
+ token_object: {
56
+ access_token: '<access_token>',
57
+ },
58
+ scope: 'profile trade withdrawal reports push settings'
59
+ }
60
+ end
103
61
 
104
- # Used to retrieve the latest trades that have occurred for a specific market.
105
- # Params Pair
106
- puts StocksExchangeApiClient::Public.trade_history('BTC_USDT')
62
+ puts StocksExchangeApiClient::PrivateApiV3.profile_info
63
+ ```
107
64
 
108
- # Used to get retrieve the orderbook for a given market.
109
- # Params Pair
110
- puts StocksExchangeApiClient::Public.order_book('BTC_USDT')
65
+ ## Lists Methods
66
+ - [Sandbox API](https://apidocs.stex.com).
111
67
  ```
68
+ profile_info() // Get general information about the current user.
69
+ wallets() // Get a list of user wallets.
70
+ wallets_by_id() // Single wallet information
71
+ add_wallets_by_currency_id() // Create a wallet for given currency
72
+ get_wallets_address() // Get deposit address for given wallet
73
+ new_wallets_address() // Create new deposit address
74
+ deposits() // Get a list of deposits made by user
75
+ deposits_by_id() // Get deposit by id
76
+ withdrawals() // Get a list of withdrawals made by user
77
+ withdrawals_by_id() // Get withdrawal by id
78
+ add_withdrawal() // Create withdrawal request
79
+ cancel_withdrawal_by_id() // Cancel unconfirmed withdrawal
80
+ reports_orders() // Get past orders
81
+ reports_orders_by_id() // Get specified order details
82
+ all_trading_orders() // List your currently open orders
83
+ delete_all_trading_orders() // Delete all active orders
84
+ trading_orders_by_pair() // List your currently open orders for given currency pair
85
+ delete_trading_orders_by_pair() // Delete active orders for given currency pair
86
+ add_trading_orders_by_pair() // Create new order and put it to the orders processing queue
87
+ trading_order_by_id() // Get a single order
88
+ delete_trading_order_by_id() // Cancel order
89
+
90
+ currencies() // Available Currencies
91
+ currencies_by_id() // Get currency info
92
+ markets() // Available markets
93
+ pairs_list_by_code() // Available currency pairs
94
+ pairs_list_by_id() // Get currency pair information
95
+ ticker() // Tickers list for all currency pairs
96
+ ticker_by_pair_id() // Ticker for currency pair
97
+ trades() // Trades for given currency pair
98
+ orderbook_by_pair_id() // Orderbook for given currency pair
99
+ chart() // A list of candles for given currency pair
100
+ ping() // Test API is working and get server time
101
+ ```
102
+
112
103
  ## Common Errors
113
104
  ### Here is a list with common errors and their descriptions:
114
105
  1. Invalid Key - not generated key or the key does not correspond to the a user
@@ -2,23 +2,21 @@ require 'openssl'
2
2
  require 'httparty'
3
3
  require 'json'
4
4
  require 'ostruct'
5
-
5
+ require 'date'
6
6
 
7
7
  # Version
8
8
  require 'stocks_exchange_api_client/version'
9
9
 
10
10
  # Private API method
11
- require 'stocks_exchange_api_client/private'
11
+ require 'stocks_exchange_api_client/private_v3'
12
12
 
13
- # Public API method
14
- require 'stocks_exchange_api_client/public'
13
+ # Private API method
14
+ require 'stocks_exchange_api_client/public_v3'
15
15
 
16
16
  # Configuration
17
17
  require 'stocks_exchange_api_client/configuration'
18
18
 
19
-
20
19
  module StocksExchangeApiClient
21
-
22
20
  METHOD_NAME = {
23
21
  get_info: 'GetInfo',
24
22
  active_orders: 'ActiveOrders',
@@ -34,35 +32,99 @@ module StocksExchangeApiClient
34
32
  withdraw: 'Withdraw'
35
33
  }.freeze
36
34
 
37
- HEX_ALGORITHM = 'sha512'
35
+ HEX_ALGORITHM = 'sha512'.freeze
36
+ JSON_SETTINGS = 'settings.json'.freeze
38
37
 
39
38
  class << self
40
-
41
39
  def configure
42
40
  yield(configuration)
43
41
  end
44
42
 
45
- def make_api_request(method = :post, params = {}, type)
43
+ def make_api_request_v3(url, params = {}, method = :get, _type = :url, auth = true)
46
44
  configuration.validate!
47
- if method == :post
48
- params.merge!({method: type, nonce: Time.now.to_i})
49
- encode_www_form = URI.encode_www_form(params)
50
- sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new(HEX_ALGORITHM), configuration.api_secret, encode_www_form)
51
- response = JSON.parse(
52
- HTTParty.post(configuration.url, body: params, headers: {
53
- :Sign => sign,
54
- :Key => configuration.api_key
55
- }).body)
56
- response = OpenStruct.new(response)
57
- end
58
- if method == :get
59
- response = JSON.parse(HTTParty.get("#{configuration.url}/#{type}").body)
45
+ post_data = URI.encode_www_form(params)
46
+ url_full = "#{configuration.url}/#{url}#{post_data == '' ? '' : '?'}#{post_data}"
47
+ if auth
48
+ if method == :post
49
+ response = HTTParty.post(url_full, body: params, headers: {
50
+ 'Authorization' => "Bearer #{get_token}",
51
+ 'Accept' => 'application/json',
52
+ 'User-Agent' => 'stocks.exchange-client'
53
+ }).body
54
+ end
55
+ if method == :get
56
+ response = HTTParty.get(url_full, headers: {
57
+ 'Authorization' => "Bearer #{get_token}",
58
+ 'Accept' => 'application/json',
59
+ 'User-Agent' => 'stocks.exchange-client'
60
+ }).body
61
+ end
62
+ if method == :delete
63
+ response = HTTParty.delete(url_full, headers: {
64
+ 'Authorization' => "Bearer #{get_token}",
65
+ 'Accept' => 'application/json',
66
+ 'User-Agent' => 'stocks.exchange-client'
67
+ }).body
68
+ end
69
+ else
70
+ if method == :post
71
+ response = HTTParty.post(url_full, body: params, headers: {
72
+ 'Accept' => 'application/json',
73
+ 'User-Agent' => 'stocks.exchange-client'
74
+ }).body
75
+ end
76
+ if method == :get
77
+ response = HTTParty.get(url_full, headers: {
78
+ 'Accept' => 'application/json',
79
+ 'User-Agent' => 'stocks.exchange-client'
80
+ }).body
81
+ end
82
+ if method == :delete
83
+ response = HTTParty.delete(url_full, headers: {
84
+ 'Accept' => 'application/json',
85
+ 'User-Agent' => 'stocks.exchange-client'
86
+ }).body
87
+ end
60
88
  end
61
89
  response
62
90
  end
63
91
 
92
+ def get_token
93
+ if !configuration.s2s
94
+ if File.exist?(JSON_SETTINGS)
95
+ current_token = JSON.parse(File.read(JSON_SETTINGS))
96
+ else
97
+ current_token = {'access_token' => configuration.option[:token_object][:access_token],
98
+ 'refresh_token' => configuration.option[:token_object][:refresh_token],
99
+ 'expires_in' => nil,
100
+ 'expires_in_date' => nil}
101
+ end
102
+ if !current_token.nil? && !current_token['expires_in_date'].nil?
103
+ return current_token['access_token'] if DateTime.parse(current_token['expires_in_date']).to_datetime > DateTime.now.to_datetime
104
+ end
105
+ begin
106
+ response = HTTParty.post(configuration.option[:access_token_url], body: {
107
+ grant_type: 'refresh_token',
108
+ refresh_token: current_token['refresh_token'],
109
+ client_id: configuration.option[:client_id],
110
+ client_secret: configuration.option[:client_secret],
111
+ scope: configuration.option[:scope]
112
+ }).body
113
+ current_token = JSON.parse(response)
114
+ current_token['expires_in_date'] = Time.at(Time.now.to_i + current_token['expires_in']).to_s
115
+ File.write(JSON_SETTINGS, current_token.to_json)
116
+ current_token['access_token']
117
+ rescue StandardError => e
118
+ puts "Rescued: #{e.inspect}"
119
+ end
120
+ end
121
+ if configuration.s2s
122
+ configuration.option[:token_object][:access_token]
123
+ end
124
+ end
125
+
64
126
  def configuration
65
127
  @configuration ||= Configuration.new
66
128
  end
67
129
  end
68
- end
130
+ end
@@ -1,18 +1,31 @@
1
- module StocksExchangeApiClient
1
+ require 'stocks_exchange_api_client/errors/configuration_error'
2
2
 
3
+ module StocksExchangeApiClient
3
4
  class Configuration
5
+ URL_V3 = 'https://api3.stex.com'.freeze
6
+ attr_accessor :url, :option, :use_version, :s2s
4
7
 
5
- URL = 'https://app.stocks.exchange/api2'
6
-
7
- attr_accessor :url, :api_key, :api_secret
8
-
9
- def initialize
10
- @url ||= URL
8
+ def initialize(url: URL_V3, option: {}, use_version: 3, s2s: false)
9
+ @url||= url
10
+ @option||= option
11
+ @use_version||= use_version
12
+ @s2s||= s2s
11
13
  end
12
14
 
13
15
  def validate!
14
- raise Errors::ConfigurationError unless api_key && api_secret
16
+ if use_version == 2
17
+ raise 'Disabled supporting version 2 API'
18
+ end
19
+ if use_version == 3 && !s2s
20
+ unless option[:client_id] && option[:client_secret] && option[:token_object][:access_token] && option[:token_object][:refresh_token]
21
+ raise Errors::ConfigurationError
22
+ end
23
+ end
24
+ if use_version == 3 && s2s
25
+ unless option[:token_object][:access_token]
26
+ raise Errors::ConfigurationError
27
+ end
28
+ end
15
29
  end
16
30
  end
17
-
18
31
  end
@@ -2,7 +2,7 @@ module StocksExchangeApiClient
2
2
  module Errors
3
3
  class ConfigurationError < StandardError
4
4
  def initialize
5
- super 'Not all config vars were set. Stocks Exchange requires API key and API secret. Get this fields on url https://app.stocks.exchange/en/profile/settings'
5
+ super 'Not all config vars were set. Stocks Exchange requires API key and API secret. Get this fields on url https://app.stex.com/profile/settings'
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,119 @@
1
+ module StocksExchangeApiClient
2
+ class PrivateApiV3
3
+ class << self
4
+ def profile_info
5
+ StocksExchangeApiClient.make_api_request_v3('/profile/info')
6
+ end
7
+
8
+ def wallets
9
+ StocksExchangeApiClient.make_api_request_v3('/profile/wallets')
10
+ end
11
+
12
+ def wallets_by_id(wallet_id)
13
+ url = "/profile/wallets/#{wallet_id}"
14
+ StocksExchangeApiClient.make_api_request_v3(url)
15
+ end
16
+
17
+ def add_wallets_by_currency_id(currency_id)
18
+ url = "/profile/wallets/#{currency_id}"
19
+ StocksExchangeApiClient.make_api_request_v3(url, {}, :post)
20
+ end
21
+
22
+ def get_wallets_address(wallet_id)
23
+ url = "/profile/wallets/address/#{wallet_id}"
24
+ StocksExchangeApiClient.make_api_request_v3(url)
25
+ end
26
+
27
+ def new_wallets_address(wallet_id)
28
+ url = "/profile/wallets/address/#{wallet_id}"
29
+ StocksExchangeApiClient.make_api_request_v3(url, {}, :post)
30
+ end
31
+
32
+ def deposits(params)
33
+ url = '/profile/deposits'
34
+ StocksExchangeApiClient.make_api_request_v3(url, params)
35
+ end
36
+
37
+ def deposits_by_id(id)
38
+ url = "/profile/deposits/#{id}"
39
+ StocksExchangeApiClient.make_api_request_v3(url)
40
+ end
41
+
42
+ def withdrawals(params)
43
+ url = '/profile/withdrawals'
44
+ StocksExchangeApiClient.make_api_request_v3(url, params)
45
+ end
46
+
47
+ def withdrawals_by_id(id)
48
+ url = "/profile/withdrawals/#{id}"
49
+ StocksExchangeApiClient.make_api_request_v3(url)
50
+ end
51
+
52
+ def add_withdrawal(currency_id, amount, address, additional_address)
53
+ url = '/profile/withdraw'
54
+ params = {
55
+ 'currency_id' => currency_id,
56
+ 'amount' => amount,
57
+ 'address' => address
58
+ }
59
+ params['additional_address_parameter'] = additional_address unless additional_address.nil?
60
+ StocksExchangeApiClient.make_api_request_v3(url, params, :post)
61
+ end
62
+
63
+ def cancel_withdrawal_by_id(id)
64
+ url = "/profile/withdraw/#{id}"
65
+ StocksExchangeApiClient.make_api_request_v3(url, {}, :delete)
66
+ end
67
+
68
+ def reports_orders(params)
69
+ url = '/reports/orders'
70
+ StocksExchangeApiClient.make_api_request_v3(url, params)
71
+ end
72
+
73
+ def reports_orders_by_id(order_id)
74
+ url = "/reports/orders/#{order_id}"
75
+ StocksExchangeApiClient.make_api_request_v3(url, {})
76
+ end
77
+
78
+ def all_trading_orders
79
+ url = '/trading/orders'
80
+ StocksExchangeApiClient.make_api_request_v3(url, {})
81
+ end
82
+
83
+ def delete_all_trading_orders
84
+ url = '/trading/orders'
85
+ StocksExchangeApiClient.make_api_request_v3(url, {}, :delete)
86
+ end
87
+
88
+ def trading_orders_by_pair(currency_pair_id)
89
+ url = "/trading/orders/#{currency_pair_id}"
90
+ StocksExchangeApiClient.make_api_request_v3(url, {})
91
+ end
92
+
93
+ def delete_trading_orders_by_pair(currency_pair_id)
94
+ url = "/trading/orders/#{currency_pair_id}"
95
+ StocksExchangeApiClient.make_api_request_v3(url, {}, :delete)
96
+ end
97
+
98
+ def add_trading_orders_by_pair(currency_pair_id, type, amount, price)
99
+ url = "/trading/orders/#{currency_pair_id}"
100
+ params = {
101
+ 'type' => type,
102
+ 'amount' => amount,
103
+ 'price' => price
104
+ }
105
+ StocksExchangeApiClient.make_api_request_v3(url, params, :post)
106
+ end
107
+
108
+ def trading_order_by_id(order_id)
109
+ url = "/trading/order/#{order_id}"
110
+ StocksExchangeApiClient.make_api_request_v3(url, {})
111
+ end
112
+
113
+ def delete_trading_order_by_id(order_id)
114
+ url = "/trading/order/#{order_id}"
115
+ StocksExchangeApiClient.make_api_request_v3(url, {}, :delete)
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,100 @@
1
+ module StocksExchangeApiClient
2
+ class PublicApiV3
3
+ class << self
4
+ def ping
5
+ StocksExchangeApiClient.make_api_request_v3('/public/ping',
6
+ {},
7
+ :get,
8
+ :url,
9
+ false)
10
+ end
11
+
12
+ def currencies
13
+ StocksExchangeApiClient.make_api_request_v3('/public/currencies',
14
+ {},
15
+ :get,
16
+ :url,
17
+ false)
18
+ end
19
+
20
+ def currencies_by_id(currency_id)
21
+ url = "/public/currencies/#{currency_id}"
22
+ StocksExchangeApiClient.make_api_request_v3(url,
23
+ {},
24
+ :get,
25
+ :url,
26
+ false)
27
+ end
28
+
29
+ def markets
30
+ StocksExchangeApiClient.make_api_request_v3('/public/markets',
31
+ {},
32
+ :get,
33
+ :url,
34
+ false)
35
+ end
36
+
37
+ def pairs_list_by_code(code = 'ALL')
38
+ url = "/public/currency_pairs/list/#{code}"
39
+ StocksExchangeApiClient.make_api_request_v3(url,
40
+ {},
41
+ :get,
42
+ :url,
43
+ false)
44
+ end
45
+
46
+ def pairs_list_by_id(id)
47
+ url = "/public/currency_pairs/#{id}"
48
+ StocksExchangeApiClient.make_api_request_v3(url,
49
+ {},
50
+ :get,
51
+ :url,
52
+ false)
53
+ end
54
+
55
+ def ticker
56
+ StocksExchangeApiClient.make_api_request_v3('/public/ticker',
57
+ {},
58
+ :get,
59
+ :url,
60
+ false)
61
+ end
62
+
63
+ def ticker_by_pair_id(id)
64
+ url = "/public/ticker/#{id}"
65
+ StocksExchangeApiClient.make_api_request_v3(url,
66
+ {},
67
+ :get,
68
+ :url,
69
+ false)
70
+ end
71
+
72
+ def trades(currency_pair_id, params)
73
+ url = "/public/trades/#{currency_pair_id}"
74
+ StocksExchangeApiClient.make_api_request_v3(url,
75
+ params,
76
+ :get,
77
+ :url,
78
+ false)
79
+ end
80
+
81
+ def orderbook_by_pair_id(id, params)
82
+ url = "/public/orderbook/#{id}"
83
+ StocksExchangeApiClient.make_api_request_v3(url, params,
84
+ :get,
85
+ :url,
86
+ false)
87
+ end
88
+
89
+ def chart(currency_pair_id, time_start, time_end, params, candles_type)
90
+ url = "/public/chart/#{currency_pair_id}/#{candles_type.nil? ? '1' : candles_type}"
91
+ params['timeStart'] = time_start
92
+ params['timeEnd'] = time_end
93
+ StocksExchangeApiClient.make_api_request_v3(url, params,
94
+ :get,
95
+ :url,
96
+ false)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -1,3 +1,3 @@
1
1
  module StocksExchangeApiClient
2
- VERSION = '0.1.2'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -6,10 +6,10 @@ require 'stocks_exchange_api_client/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'stocks_exchange_api_client'
8
8
  spec.version = StocksExchangeApiClient::VERSION
9
- spec.authors = ['Stocks Exchange']
9
+ spec.authors = ['STEX']
10
10
 
11
- spec.summary = 'Stocks Exchange API client for ruby.'
12
- spec.description = 'Stocks Exchange provides all the core exchange functionality, and additional merchant tools available via the HTTP API where all returned messages are in JSON. Its much easier to work with the API by using one of the clients provided by Stocks.Exchange, so while this page describes the API in case you want or need to build your own client, the examples use the Ruby client.'
11
+ spec.summary = 'STEX (former Stocks.Exchange) API client for ruby.'
12
+ spec.description = 'STEX (former Stocks.Exchange) provides all the core exchange functionality, and additional merchant tools available via the HTTP API where all returned messages are in JSON. Its much easier to work with the API by using one of the clients provided by Stocks.Exchange, so while this page describes the API in case you want or need to build your own client, the examples use the Ruby client.'
13
13
  spec.homepage = 'https://github.com/StocksExchange/ruby-client#readme'
14
14
  spec.license = 'MIT'
15
15
 
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ['lib']
30
30
 
31
31
  spec.add_development_dependency 'bundler', '~> 1.16'
32
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rake', '~> 12.3.3'
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
- end
34
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stocks_exchange_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Stocks Exchange
7
+ - STEX
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openssl
@@ -48,22 +48,22 @@ dependencies:
48
48
  name: json
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '2.1'
54
51
  - - ">="
55
52
  - !ruby/object:Gem::Version
56
53
  version: 2.1.0
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '2.1'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '2.1'
64
61
  - - ">="
65
62
  - !ruby/object:Gem::Version
66
63
  version: 2.1.0
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '2.1'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: bundler
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -84,14 +84,14 @@ dependencies:
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: '10.0'
87
+ version: 12.3.3
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '10.0'
94
+ version: 12.3.3
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rspec
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -106,11 +106,11 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: '3.0'
109
- description: Stocks Exchange provides all the core exchange functionality, and additional
110
- merchant tools available via the HTTP API where all returned messages are in JSON.
111
- Its much easier to work with the API by using one of the clients provided by Stocks.Exchange,
112
- so while this page describes the API in case you want or need to build your own
113
- client, the examples use the Ruby client.
109
+ description: STEX (former Stocks.Exchange) provides all the core exchange functionality,
110
+ and additional merchant tools available via the HTTP API where all returned messages
111
+ are in JSON. Its much easier to work with the API by using one of the clients provided
112
+ by Stocks.Exchange, so while this page describes the API in case you want or need
113
+ to build your own client, the examples use the Ruby client.
114
114
  email:
115
115
  executables: []
116
116
  extensions: []
@@ -127,8 +127,8 @@ files:
127
127
  - lib/stocks_exchange_api_client.rb
128
128
  - lib/stocks_exchange_api_client/configuration.rb
129
129
  - lib/stocks_exchange_api_client/errors/configuration_error.rb
130
- - lib/stocks_exchange_api_client/private.rb
131
- - lib/stocks_exchange_api_client/public.rb
130
+ - lib/stocks_exchange_api_client/private_v3.rb
131
+ - lib/stocks_exchange_api_client/public_v3.rb
132
132
  - lib/stocks_exchange_api_client/version.rb
133
133
  - stocks_exchange_api_client.gemspec
134
134
  homepage: https://github.com/StocksExchange/ruby-client#readme
@@ -150,9 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.7.6
153
+ rubygems_version: 3.0.3
155
154
  signing_key:
156
155
  specification_version: 4
157
- summary: Stocks Exchange API client for ruby.
156
+ summary: STEX (former Stocks.Exchange) API client for ruby.
158
157
  test_files: []
@@ -1,157 +0,0 @@
1
- module StocksExchangeApiClient
2
- ASC = 'ASC'.freeze
3
-
4
- ALL = 'ALL'.freeze
5
-
6
- MAX_COUNT = 50
7
-
8
- STATUS_ORDER = {
9
- pending: 1,
10
- processing: 2,
11
- finished: 3,
12
- canceled: 4
13
- }.freeze
14
-
15
- STATUS_ORDER_HUMAN_NAME = {
16
- 1 => 'PENDING',
17
- 2 => 'PROCESSING',
18
- 3 => 'FINISHED',
19
- 4 => 'CANCELED'
20
- }.freeze
21
-
22
- OWNER = {
23
- all: 'ALL',
24
- own: 'OWN'
25
- }.freeze
26
-
27
- INTERVAL = {
28
- day: '1D',
29
- month: '1M',
30
- three_month: '3M',
31
- year: '1Y'
32
- }.freeze
33
-
34
- DEFAULT_PAIRS = 'ETH_BTC'.freeze
35
-
36
- class Private
37
- class << self
38
- def get_info
39
- StocksExchangeApiClient.make_api_request(:post,
40
- {},
41
- METHOD_NAME[:get_info])
42
- end
43
-
44
- def active_order(params = {})
45
- params[:pair] = params[:pair].nil? ? ALL : params[:pair]
46
- params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
47
- params[:order] = params[:order].nil? ? ASC : params[:order]
48
- params[:type] = params[:type].nil? ? ALL : params[:type]
49
- params[:owner] = params[:owner].nil? ? ALL : params[:owner]
50
-
51
- params[:order] = ASC unless params[:since].nil? || params[:end].nil?
52
-
53
- StocksExchangeApiClient.make_api_request(:post,
54
- params,
55
- METHOD_NAME[:active_orders])
56
- end
57
-
58
- def trade(type = nil, pair = nil, amount = nil, rate = nil)
59
- params = {
60
- type: type,
61
- pair: pair,
62
- amount: amount,
63
- rate: rate
64
- }
65
- StocksExchangeApiClient.make_api_request(:post,
66
- params,
67
- METHOD_NAME[:trade])
68
- end
69
-
70
- def cancel_order(order_id)
71
- params = { order_id: order_id }
72
- StocksExchangeApiClient.make_api_request(:post,
73
- params,
74
- METHOD_NAME[:cancel_order])
75
- end
76
-
77
- def trade_history(params = {})
78
- params[:pair] = params[:pair].nil? ? ALL : params[:pair]
79
- params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
80
- params[:order] = params[:order].nil? ? ASC : params[:order]
81
- params[:owner] = params[:owner].nil? ? OWNER[:own] : params[:owner]
82
- params[:status] = params[:status].nil? ? STATUS_ORDER[:finished] : params[:status]
83
- params[:order] = ASC unless params[:since].nil? || params[:end].nil?
84
-
85
- StocksExchangeApiClient.make_api_request(:post,
86
- params,
87
- METHOD_NAME[:trade_history])
88
- end
89
-
90
- def trade_register_history(params = {})
91
- params[:currency] = params[:currency].nil? ? ALL : params[:currency]
92
-
93
- StocksExchangeApiClient.make_api_request(:post,
94
- params,
95
- METHOD_NAME[:trade_register_history])
96
- end
97
-
98
- def user_history(params = {})
99
- StocksExchangeApiClient.make_api_request(:post,
100
- params,
101
- METHOD_NAME[:user_history])
102
- end
103
-
104
- def trans_history(params = {})
105
- params[:currency] = params[:currency].nil? ? ALL : params[:currency]
106
- params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
107
- params[:order] = params[:order].nil? ? 'DESC' : params[:order]
108
- params[:operation] = params[:operation].nil? ? ALL : params[:operation]
109
- params[:status] = params[:status].nil? ? STATUS_ORDER_HUMAN_NAME[STATUS_ORDER[:finished]] : params[:status]
110
- params[:order] = ASC unless params[:since].nil? || params[:end].nil?
111
-
112
- params[:status] = STATUS_ORDER_HUMAN_NAME[STATUS_ORDER[:finished]] unless params[:operation].nil? && params[:operation] == ALL
113
-
114
- StocksExchangeApiClient.make_api_request(:post,
115
- params,
116
- METHOD_NAME[:trans_history])
117
- end
118
-
119
- def grafic(params = {})
120
- params[:pair] = params[:pair].nil? ? DEFAULT_PAIRS : params[:pair]
121
- params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
122
- params[:order] = params[:order].nil? ? ASC : params[:order]
123
- params[:interval] = params[:interval].nil? ? INTERVAL[:day] : params[:interval]
124
- params[:page] = params[:page].nil? ? 1 : params[:page]
125
- params[:order] = ASC unless params[:since].nil? || params[:end].nil?
126
-
127
- StocksExchangeApiClient.make_api_request(:post,
128
- params,
129
- METHOD_NAME[:grafic])
130
- end
131
-
132
- def generate_wallets(currency)
133
- StocksExchangeApiClient.make_api_request(:post,
134
- { currency: currency },
135
- METHOD_NAME[:generate_wallets])
136
- end
137
-
138
- def deposit(currency)
139
- StocksExchangeApiClient.make_api_request(:post,
140
- { currency: currency },
141
- METHOD_NAME[:deposit])
142
- end
143
-
144
- def withdraw(currency, address, amount)
145
- params = {
146
- currency: currency,
147
- address: address,
148
- amount: amount
149
- }
150
-
151
- StocksExchangeApiClient.make_api_request(:post,
152
- params,
153
- METHOD_NAME[:withdraw])
154
- end
155
- end
156
- end
157
- end
@@ -1,65 +0,0 @@
1
- module StocksExchangeApiClient
2
- class Public
3
- class << self
4
- def currencies
5
- StocksExchangeApiClient.make_api_request(:get,
6
- nil,
7
- 'currencies')
8
- end
9
-
10
- def markets
11
- StocksExchangeApiClient.make_api_request(:get,
12
- nil,
13
- 'markets')
14
- end
15
-
16
- def markets_summary(currency1 = 'ETH', currency2 = 'BTC')
17
- url = "market_summary/#{currency1}/#{currency2}"
18
- StocksExchangeApiClient.make_api_request(:get,
19
- nil,
20
- url)
21
- end
22
-
23
- def ticker
24
- StocksExchangeApiClient.make_api_request(:get,
25
- nil,
26
- 'ticker')
27
- end
28
-
29
- def prices
30
- StocksExchangeApiClient.make_api_request(:get,
31
- nil,
32
- 'prices')
33
- end
34
-
35
- def trade_history(pair = DEFAULT_PAIRS)
36
- url = "trades?pair=#{pair}"
37
- StocksExchangeApiClient.make_api_request(:get,
38
- nil,
39
- url)
40
- end
41
-
42
- def order_book(pair = DEFAULT_PAIRS)
43
- url = "orderbook?pair=#{pair}"
44
- StocksExchangeApiClient.make_api_request(:get,
45
- nil,
46
- url)
47
- end
48
-
49
- def grafic(params = {})
50
- params[:pair] = params[:pair].nil? ? DEFAULT_PAIRS : params[:pair]
51
- params[:count] = params[:count].nil? ? MAX_COUNT : params[:count]
52
- params[:order] = params[:order].nil? ? ASC : params[:order]
53
- params[:interval] = params[:interval].nil? ? INTERVAL[:day] : params[:interval]
54
- params[:page] = params[:page].nil? ? 1 : params[:page]
55
- params[:order] = ASC unless params[:since].nil? || params[:end].nil?
56
- encode_www_form = URI.encode_www_form(params)
57
-
58
- url = "grafic_public?#{encode_www_form}"
59
- StocksExchangeApiClient.make_api_request(:get,
60
- nil,
61
- url)
62
- end
63
- end
64
- end
65
- end