binance-ruby 0.1.3 → 0.1.4
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 +4 -4
- data/lib/binance-ruby.rb +12 -0
- data/lib/binance/api.rb +12 -12
- data/lib/binance/api/error.rb +3 -6
- data/lib/binance/api/request.rb +5 -4
- data/lib/binance/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d665e850e7696104e6a32308124893ed544646b
|
4
|
+
data.tar.gz: 4e2649522dbf15dc576e1f5b48a1351442bba294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d9940eaed2ee15e32bbdf44b12998353330c03d7db74323a7d167a2119b6440feb6a5ea40349f6a71a41240f95f7c7dce5efe1fd0e62a726c3032979318f58
|
7
|
+
data.tar.gz: 2795defbbb967a66ba9095e88ad6db907a2c3eeaf55521dec277468fd6c1859474093de9e4639c4aeca45ea036d8c3c7159d2a1988eae1ff30cbd882df9446b2
|
data/lib/binance-ruby.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'active_support/core_ext/string'
|
2
|
+
require 'awrence'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
require 'binance/api'
|
6
|
+
require 'binance/api/account'
|
7
|
+
require 'binance/api/configuration'
|
8
|
+
require 'binance/api/data_stream'
|
9
|
+
require 'binance/api/error'
|
10
|
+
require 'binance/api/order'
|
11
|
+
require 'binance/api/request'
|
12
|
+
require "binance/api/version"
|
data/lib/binance/api.rb
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/string'
|
2
|
-
require 'awrence'
|
3
|
-
require 'httparty'
|
4
|
-
require 'binance/api/account'
|
5
|
-
require 'binance/api/configuration'
|
6
|
-
require 'binance/api/data_stream'
|
7
|
-
require 'binance/api/error'
|
8
|
-
require 'binance/api/order'
|
9
|
-
require 'binance/api/request'
|
10
|
-
require "binance/api/version"
|
11
|
-
|
12
1
|
module Binance
|
13
2
|
module Api
|
14
3
|
class << self
|
@@ -51,7 +40,7 @@ module Binance
|
|
51
40
|
error_message = "type must be one of: #{ticker_types.join(', ')}. #{type} was provided."
|
52
41
|
raise Error.new(message: error_message) unless ticker_types.include? ticker_type
|
53
42
|
params = symbol ? { symbol: symbol } : {}
|
54
|
-
Request.send!(api_key_type: :read_info, path:
|
43
|
+
Request.send!(api_key_type: :read_info, path: ticker_path(type: type), params: params)
|
55
44
|
end
|
56
45
|
|
57
46
|
def time!
|
@@ -66,6 +55,17 @@ module Binance
|
|
66
55
|
|
67
56
|
private
|
68
57
|
|
58
|
+
def ticker_path(type:)
|
59
|
+
case type
|
60
|
+
when :daily
|
61
|
+
'/api/v1/ticker/24hr'
|
62
|
+
when :price, :book_ticker
|
63
|
+
"/api/v3/ticker/#{type.to_s.camelize(:lower)}"
|
64
|
+
else
|
65
|
+
raise Error.new(message: "invalid type #{type}")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
69
|
def ticker_types
|
70
70
|
[:daily, :price, :book_ticker].freeze
|
71
71
|
end
|
data/lib/binance/api/error.rb
CHANGED
@@ -5,10 +5,8 @@ module Binance
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
# https://github.com/binance-exchange/binance-official-api-docs/blob/master/errors.md
|
8
|
-
def is_error_response?(
|
9
|
-
|
10
|
-
code = json[:code]&.to_i
|
11
|
-
code && code >= 400
|
8
|
+
def is_error_response?(response:)
|
9
|
+
response.code >= 400
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
@@ -20,8 +18,7 @@ module Binance
|
|
20
18
|
def inspect
|
21
19
|
message = "Binance::Api::Error"
|
22
20
|
message += " (#{code})" unless code.nil?
|
23
|
-
message += ": #{msg}"
|
24
|
-
message += "\nbacktrace: #{backtrace}"
|
21
|
+
message += ": #{msg}" unless msg.nil?
|
25
22
|
end
|
26
23
|
|
27
24
|
def message
|
data/lib/binance/api/request.rb
CHANGED
@@ -35,14 +35,15 @@ module Binance
|
|
35
35
|
|
36
36
|
def default_headers(api_key_type:, security_type:)
|
37
37
|
headers = {}
|
38
|
+
headers['Content-Type'] = 'application/json; charset=utf-8'
|
38
39
|
headers['X-MBX-APIKEY'] = Configuration.api_key(type: api_key_type) unless security_type == :none
|
39
40
|
headers
|
40
41
|
end
|
41
42
|
|
42
|
-
def process!(response:
|
43
|
-
json = JSON.parse(response, symbolize_names: true)
|
44
|
-
raise Error.new(json: json) if Error.is_error_response?(
|
45
|
-
json
|
43
|
+
def process!(response:)
|
44
|
+
json = JSON.parse(response.body, symbolize_names: true)
|
45
|
+
raise Error.new(json: json) if Error.is_error_response?(response: response)
|
46
|
+
json
|
46
47
|
end
|
47
48
|
|
48
49
|
def security_types
|
data/lib/binance/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binance-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Peterson
|
@@ -157,6 +157,7 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
+
- lib/binance-ruby.rb
|
160
161
|
- lib/binance/api.rb
|
161
162
|
- lib/binance/api/account.rb
|
162
163
|
- lib/binance/api/configuration.rb
|
@@ -189,5 +190,5 @@ rubyforge_project:
|
|
189
190
|
rubygems_version: 2.5.2
|
190
191
|
signing_key:
|
191
192
|
specification_version: 4
|
192
|
-
summary: binance-ruby-0.1.
|
193
|
+
summary: binance-ruby-0.1.4
|
193
194
|
test_files: []
|