binance 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93fa8d27b55c0314452ebe5ce297136461cf33bc
|
4
|
+
data.tar.gz: fe2d138b2c69481c3c31796c2addadf44e03fa0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2d91b7c1774dbda1ccc2cb993116a0938d543986d058d7b03b16d39164b47bce86653d0c494e7d225403e243e34dfdc8c80ce24bb039992fdd82665a3bbd515
|
7
|
+
data.tar.gz: 732ab2f1be0f5bca04a792d4a3386ac87b06db57e70246819d04fecdeff1aadd238497c57d4cebcf11df1f9ae12dff224694e064e43f61dfee4ebb6f5fb6a0d8
|
data/lib/binance/client/rest.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'rest/api_endpoints'
|
|
4
4
|
require_relative 'rest/public_api'
|
5
5
|
require_relative 'rest/account_api'
|
6
6
|
require_relative 'rest/withdraw_api'
|
7
|
+
require_relative 'rest/user_data_api'
|
7
8
|
|
8
9
|
module Binance
|
9
10
|
module Client
|
@@ -38,6 +39,7 @@ module Binance
|
|
38
39
|
extend Public_API
|
39
40
|
extend Account_API
|
40
41
|
extend Withdraw_API
|
42
|
+
extend UserData_API
|
41
43
|
end
|
42
44
|
|
43
45
|
private
|
@@ -30,7 +30,10 @@ module Binance
|
|
30
30
|
'depositHistory' => 'v3/depositHistory.html',
|
31
31
|
'withdrawHistory' => 'v3/withdrawHistory.html',
|
32
32
|
'depositAddress' => 'v3/depositAddress.html',
|
33
|
-
'accountStatus' => 'v3/accountStatus.html'
|
33
|
+
'accountStatus' => 'v3/accountStatus.html',
|
34
|
+
|
35
|
+
# User Data Stream API Endpoints
|
36
|
+
'userDataStream' => 'v1/userDataStream'
|
34
37
|
}.freeze
|
35
38
|
end
|
36
39
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
require 'faraday'
|
3
|
+
require 'faraday_middleware'
|
4
|
+
|
5
|
+
module Binance
|
6
|
+
module Client
|
7
|
+
class REST
|
8
|
+
# Public: A Module containing all of the User Data API endpoints
|
9
|
+
module UserData_API
|
10
|
+
# Internal: Create Lambda that returns a new Faraday client instance
|
11
|
+
# and add it to the REST class instance variable @api. This is called
|
12
|
+
# while a new instance of the REST class is created.
|
13
|
+
#
|
14
|
+
# base - The base class that is being extended into.
|
15
|
+
def self.extended(base)
|
16
|
+
REST.api[:user_data] = lambda do
|
17
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
18
|
+
conn.response :json, content_type: /\bjson$/
|
19
|
+
conn.headers['X-MBX-APIKEY'] = base.api_key
|
20
|
+
conn.adapter base.adapter
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Public: Retrieve the listen key for the given api key
|
26
|
+
#
|
27
|
+
# Returns a Hash with the request response
|
28
|
+
def listen_key
|
29
|
+
request :user_data, :post, 'userDataStream'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Public: Ping the server to keep User Data stream alive
|
33
|
+
#
|
34
|
+
# options - The Hash which hosts various REST query params.
|
35
|
+
# :listen_key - The String of which stream to keep alive
|
36
|
+
#
|
37
|
+
# Returns a Hash with the request response
|
38
|
+
def keep_stream_alive(options)
|
39
|
+
request :user_data, :put, 'userDataStream', options
|
40
|
+
end
|
41
|
+
|
42
|
+
# Public: Close the User Data stream associated with the listen key
|
43
|
+
#
|
44
|
+
# options - The Hash which hosts various REST query params.
|
45
|
+
# :listen_key - The String of which stream to close
|
46
|
+
#
|
47
|
+
# Returns a Hash with the request response
|
48
|
+
def close_stream(options)
|
49
|
+
request :user_data, :delete, 'userDataStream', options
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -153,6 +153,21 @@ module Binance
|
|
153
153
|
single stream: { symbol: symbol, type: 'depth' }, methods: methods
|
154
154
|
end
|
155
155
|
|
156
|
+
# Public: Create a User Data stream
|
157
|
+
#
|
158
|
+
# listen_key - The String key the stream will listen to, attained by
|
159
|
+
# interacting with the REST API userDataStream endpoint
|
160
|
+
#
|
161
|
+
# :methods - The Hash which contains the event handler methods to pass to
|
162
|
+
# the WebSocket client
|
163
|
+
# :open - The Proc called when a stream is opened (optional)
|
164
|
+
# :message - The Proc called when a stream receives a message
|
165
|
+
# :error - The Proc called when a stream receives an error (optional)
|
166
|
+
# :close - The Proc called when a stream is closed (optional)
|
167
|
+
def user_data(listen_key:, methods:)
|
168
|
+
create_stream "#{BASE_URL}/ws/#{listen_key}", methods: methods
|
169
|
+
end
|
170
|
+
|
156
171
|
private
|
157
172
|
|
158
173
|
# Internal: Create a valid URL for a WebSocket to use
|
data/lib/binance/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Ray Shisler III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/binance/client/rest/public_api.rb
|
111
111
|
- lib/binance/client/rest/sign_request_middleware.rb
|
112
112
|
- lib/binance/client/rest/timestamp_request_middleware.rb
|
113
|
+
- lib/binance/client/rest/user_data_api.rb
|
113
114
|
- lib/binance/client/rest/withdraw_api.rb
|
114
115
|
- lib/binance/client/websocket.rb
|
115
116
|
- lib/binance/version.rb
|