stocks_exchange_api_client 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -86
- data/lib/stocks_exchange_api_client.rb +2 -27
- data/lib/stocks_exchange_api_client/configuration.rb +3 -10
- data/lib/stocks_exchange_api_client/version.rb +1 -1
- data/stocks_exchange_api_client.gemspec +5 -5
- metadata +18 -21
- data/lib/stocks_exchange_api_client/private.rb +0 -157
- data/lib/stocks_exchange_api_client/public.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ebadc56eaa5dd75311a797a40d4b6f910dc8b04b2da59a69f6ff78f2a4ce079
|
4
|
+
data.tar.gz: bd29fa6ecd9021eced24792c842f2d26a6a839e8b0fe07889459f557a157d476
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ec80c652cde01e7e39f764e39d6fc9a7f4f3bd4d293786a7f08eade46c4c1f81c62ac5d9f1c84398522faaea3df192b0ff3071d66522645e338cba1d16f20e
|
7
|
+
data.tar.gz: 6a0aca2fdedc4da1c1ed2498e935bcc8c95197d7d2433b1c49b8aade9e6d25be12a674d4885a92b463e69257137575b4b827059c168b8b87662111b8acf14bf3
|
data/README.md
CHANGED
@@ -12,13 +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.stex.com/api2
|
16
15
|
https://api3.stex.com
|
17
16
|
```
|
18
17
|
|
19
18
|
## Getting started
|
20
19
|
- [Documentation](http://help.stex.com/api-integration).
|
21
|
-
- [Sandbox API
|
20
|
+
- [Sandbox API](https://apidocs.stex.com).
|
22
21
|
|
23
22
|
To get started with the Ruby API client, here's a snippet for creating a client with existing credentials:
|
24
23
|
> In order to use the API functions, you must have an API key and API secret, which is generated in the user profile.
|
@@ -30,92 +29,10 @@ gem install stocks_exchange_api_client
|
|
30
29
|
|
31
30
|
After install use for example this code!
|
32
31
|
|
33
|
-
### Example
|
34
|
-
```ruby
|
35
|
-
require 'stocks_exchange_api_client'
|
36
|
-
|
37
|
-
StocksExchangeApiClient.configure do |conf|
|
38
|
-
conf.url = 'https://app.stocks.exchange/api2'
|
39
|
-
conf.api_key = '' # Your Api Key
|
40
|
-
conf.api_secret = '' # Your Api Secret
|
41
|
-
end
|
42
|
-
# Get information about your account
|
43
|
-
puts StocksExchangeApiClient::Private.get_info
|
44
|
-
|
45
|
-
# Get information about active orders.
|
46
|
-
# Params: pair, count, order, type, owner, since, end
|
47
|
-
puts StocksExchangeApiClient::Private.active_order
|
48
|
-
|
49
|
-
# Create orders for the purchase and sale.
|
50
|
-
# Params: type, pair, amount, rate
|
51
|
-
puts StocksExchangeApiClient::Private.trade('BUY', 'LTC_BTC', 0.1, 0.00002)
|
52
|
-
|
53
|
-
# Cancel selected order.
|
54
|
-
# Params: order_id
|
55
|
-
puts StocksExchangeApiClient::Private.cancel_order(2761025)
|
56
|
-
|
57
|
-
# Get information about all orders.
|
58
|
-
# Params: pair, count, order, status, owner, since, end
|
59
|
-
puts StocksExchangeApiClient::Private.trade_history
|
60
|
-
|
61
|
-
# Get information about all closed orders from Register
|
62
|
-
# Params: currency, since, end
|
63
|
-
puts StocksExchangeApiClient::Private.trade_register_history
|
64
|
-
|
65
|
-
# Get information about all orders User
|
66
|
-
# Params: since, end
|
67
|
-
puts StocksExchangeApiClient::Private.user_history
|
68
|
-
|
69
|
-
# Get information about your deposits and withdrawals.
|
70
|
-
# Params: currency, count, order, operation, status
|
71
|
-
puts StocksExchangeApiClient::Private.trans_history
|
72
|
-
|
73
|
-
# Get information about trade statistic.
|
74
|
-
# Params: currency, count, order, operation, status, since, end
|
75
|
-
puts StocksExchangeApiClient::Private.grafic
|
76
|
-
|
77
|
-
# Generate currency wallet address.
|
78
|
-
# Params: currency
|
79
|
-
puts StocksExchangeApiClient::Private.generate_wallets('ONION')
|
80
|
-
|
81
|
-
# Get information about your wallet to deposit funds.
|
82
|
-
# Params: currency
|
83
|
-
puts StocksExchangeApiClient::Private.deposit('ETH')
|
84
|
-
|
85
|
-
# Withdraw your funds.
|
86
|
-
# Params: currency, address, amount
|
87
|
-
puts StocksExchangeApiClient::Private.withdraw('EAG', '12345', 1.001)
|
88
|
-
|
89
|
-
# Get all available currencies with additional info.
|
90
|
-
puts StocksExchangeApiClient::Public.currencies
|
91
|
-
|
92
|
-
# Get all available currency pairs with additional info.
|
93
|
-
puts StocksExchangeApiClient::Public.markets
|
94
|
-
|
95
|
-
# Get currency pair with additional info.
|
96
|
-
# Params Currency1 and Currency2
|
97
|
-
puts StocksExchangeApiClient::Public.markets_summary('BTC', 'USDT')
|
98
|
-
|
99
|
-
# Use it to get the recommended retail exchange rates for all currency pairs.
|
100
|
-
puts StocksExchangeApiClient::Public.ticker
|
101
|
-
|
102
|
-
# Use it to get the new retail exchange rates for all currency pairs.
|
103
|
-
puts StocksExchangeApiClient::Public.prices
|
104
|
-
|
105
|
-
# Used to retrieve the latest trades that have occurred for a specific market.
|
106
|
-
# Params Pair
|
107
|
-
puts StocksExchangeApiClient::Public.trade_history('BTC_USDT')
|
108
|
-
|
109
|
-
# Used to get retrieve the orderbook for a given market.
|
110
|
-
# Params Pair
|
111
|
-
puts StocksExchangeApiClient::Public.order_book('BTC_USDT')
|
112
|
-
```
|
113
|
-
|
114
|
-
### Example V3
|
32
|
+
### Example
|
115
33
|
```ruby
|
116
34
|
StocksExchangeApiClient.configure do |conf|
|
117
35
|
conf.url = 'https://api3.stex.com'
|
118
|
-
conf.use_version = 3
|
119
36
|
conf.option = {
|
120
37
|
client_id: '',
|
121
38
|
client_secret: '',
|
@@ -130,8 +47,23 @@ end
|
|
130
47
|
|
131
48
|
puts StocksExchangeApiClient::PrivateApiV3.profile_info
|
132
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
|
61
|
+
|
62
|
+
puts StocksExchangeApiClient::PrivateApiV3.profile_info
|
63
|
+
```
|
64
|
+
|
133
65
|
## Lists Methods
|
134
|
-
- [Sandbox API
|
66
|
+
- [Sandbox API](https://apidocs.stex.com).
|
135
67
|
```
|
136
68
|
profile_info() // Get general information about the current user.
|
137
69
|
wallets() // Get a list of user wallets.
|
@@ -7,14 +7,10 @@ require 'date'
|
|
7
7
|
# Version
|
8
8
|
require 'stocks_exchange_api_client/version'
|
9
9
|
|
10
|
-
# Private API
|
11
|
-
require 'stocks_exchange_api_client/private'
|
12
|
-
# Private API V3 method
|
10
|
+
# Private API method
|
13
11
|
require 'stocks_exchange_api_client/private_v3'
|
14
12
|
|
15
|
-
#
|
16
|
-
require 'stocks_exchange_api_client/public'
|
17
|
-
# Private API V3 method
|
13
|
+
# Private API method
|
18
14
|
require 'stocks_exchange_api_client/public_v3'
|
19
15
|
|
20
16
|
# Configuration
|
@@ -44,27 +40,6 @@ module StocksExchangeApiClient
|
|
44
40
|
yield(configuration)
|
45
41
|
end
|
46
42
|
|
47
|
-
def make_api_request(method = :post, params = {}, type)
|
48
|
-
configuration.validate!
|
49
|
-
if method == :post
|
50
|
-
params[:method] = type
|
51
|
-
params[:nonce] = Time.now.to_i
|
52
|
-
encode_www_form = URI.encode_www_form(params)
|
53
|
-
sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new(HEX_ALGORITHM), configuration.option[:api_secret], encode_www_form)
|
54
|
-
response = JSON.parse(
|
55
|
-
HTTParty.post(configuration.url, body: params, headers: {
|
56
|
-
Sign: sign,
|
57
|
-
Key: configuration.option[:api_key]
|
58
|
-
}).body
|
59
|
-
)
|
60
|
-
response = OpenStruct.new(response)
|
61
|
-
end
|
62
|
-
if method == :get
|
63
|
-
response = JSON.parse(HTTParty.get("#{configuration.url}/#{type}").body)
|
64
|
-
end
|
65
|
-
response
|
66
|
-
end
|
67
|
-
|
68
43
|
def make_api_request_v3(url, params = {}, method = :get, _type = :url, auth = true)
|
69
44
|
configuration.validate!
|
70
45
|
post_data = URI.encode_www_form(params)
|
@@ -2,16 +2,11 @@ require 'stocks_exchange_api_client/errors/configuration_error'
|
|
2
2
|
|
3
3
|
module StocksExchangeApiClient
|
4
4
|
class Configuration
|
5
|
-
URL_V2 = 'https://app.stex.com/api2'.freeze
|
6
5
|
URL_V3 = 'https://api3.stex.com'.freeze
|
7
6
|
attr_accessor :url, :option, :use_version, :s2s
|
8
7
|
|
9
|
-
def initialize(url:
|
10
|
-
|
11
|
-
@url||= URL_V3
|
12
|
-
else
|
13
|
-
@url||= URL_V3
|
14
|
-
end
|
8
|
+
def initialize(url: URL_V3, option: {}, use_version: 3, s2s: false)
|
9
|
+
@url||= url
|
15
10
|
@option||= option
|
16
11
|
@use_version||= use_version
|
17
12
|
@s2s||= s2s
|
@@ -19,9 +14,7 @@ module StocksExchangeApiClient
|
|
19
14
|
|
20
15
|
def validate!
|
21
16
|
if use_version == 2
|
22
|
-
|
23
|
-
raise Errors::ConfigurationError
|
24
|
-
end
|
17
|
+
raise 'Disabled supporting version 2 API'
|
25
18
|
end
|
26
19
|
if use_version == 3 && !s2s
|
27
20
|
unless option[:client_id] && option[:client_secret] && option[:token_object][:access_token] && option[:token_object][:refresh_token]
|
@@ -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 = ['
|
9
|
+
spec.authors = ['STEX']
|
10
10
|
|
11
|
-
spec.summary = 'Stocks
|
12
|
-
spec.description = 'Stocks
|
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', '~>
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- STEX
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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:
|
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:
|
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
|
110
|
-
merchant tools available via the HTTP API where all returned messages
|
111
|
-
Its much easier to work with the API by using one of the clients provided
|
112
|
-
so while this page describes the API in case you want or need
|
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,9 +127,7 @@ 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
130
|
- lib/stocks_exchange_api_client/private_v3.rb
|
132
|
-
- lib/stocks_exchange_api_client/public.rb
|
133
131
|
- lib/stocks_exchange_api_client/public_v3.rb
|
134
132
|
- lib/stocks_exchange_api_client/version.rb
|
135
133
|
- stocks_exchange_api_client.gemspec
|
@@ -152,9 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
150
|
- !ruby/object:Gem::Version
|
153
151
|
version: '0'
|
154
152
|
requirements: []
|
155
|
-
|
156
|
-
rubygems_version: 2.7.6
|
153
|
+
rubygems_version: 3.0.3
|
157
154
|
signing_key:
|
158
155
|
specification_version: 4
|
159
|
-
summary: Stocks
|
156
|
+
summary: STEX (former Stocks.Exchange) API client for ruby.
|
160
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
|