binance-ruby 0.5 → 0.6

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
  SHA256:
3
- metadata.gz: bbd02bd36bb807895e727ed07261b63c4f8863862dd9016723b69e47d7033856
4
- data.tar.gz: 64c57054923d757d07cbec602af8a6cc687a8646f65c8c62c63691e872a4e325
3
+ metadata.gz: 9573431110b2ce6731230f3660f9023dbbea1064bff0c508072a4dc059c90d06
4
+ data.tar.gz: 0664dcff66ef95d5bdf96f8feb37d2f47fe00fc606d166df3c4846a63cee64b1
5
5
  SHA512:
6
- metadata.gz: 01de466a3ba9a8811493029f1eef4ee059f0934ea165854b842c2d655e78fcc3677806ea6fd562142143b8af51afa338fd0f98c5875696f33b75c57efd25b288
7
- data.tar.gz: cf17dfb48360a3a3ee089fb1461f50660f63344666dab63e3a2e42eb575a28a3bad121499795bae01f1e4d300deb385ed8c5128046a4be42cd3580ca0a8a37c5
6
+ metadata.gz: 4da7aa59ff6987dff9690848fe48df6774370e194cc10ac1a33692b18dfe9a00c7e39ccda67d13c565c6fd5ae1f15b8f22e9c45e0c4e47be92e9a15740c98fce
7
+ data.tar.gz: a9ac599985d66f28656e11b609c50888ecaf93f9450f3cfddc33a6b6ba37913e650f9f98573db4b4e9bd9a50fae2c5c37155ad634c4d871ca62ab27fb7ed0af2
@@ -16,8 +16,7 @@ module Binance
16
16
 
17
17
  def tld
18
18
  tld = ENV["BINANCE_TLD"]&.downcase&.to_sym || :com
19
- error_message = "Invalid tld (top-level-domain): #{tld}. Use one of: #{allowed_tlds.join(", ")}."
20
- raise Error.new(message: error_message) unless allowed_tlds.include?(tld)
19
+ validate_tld!(tld)
21
20
  tld
22
21
  end
23
22
 
@@ -36,6 +35,11 @@ module Binance
36
35
  Time.now.utc.strftime("%s%3N")
37
36
  end
38
37
 
38
+ def validate_tld!(tld)
39
+ error_message = "Invalid tld (top-level-domain): #{tld}. Use one of: #{allowed_tlds.join(", ")}."
40
+ raise Error.new(message: error_message) unless allowed_tlds.include?(tld&.to_sym)
41
+ end
42
+
39
43
  private
40
44
 
41
45
  def allowed_tlds
@@ -18,7 +18,7 @@ module Binance
18
18
  ensure_required_create_keys!(params: params)
19
19
  path = "/sapi/v1/margin/order"
20
20
  Request.send!(api_key_type: :trading, method: :post, path: path,
21
- params: params, security_type: :trade)
21
+ params: params, security_type: :trade, tld: Configuration.tld)
22
22
  end
23
23
 
24
24
  private
@@ -9,7 +9,7 @@ module Binance
9
9
  params = { limit: limit, orderId: orderId, recvWindow: recvWindow, symbol: symbol, timestamp: timestamp }
10
10
  Request.send!(api_key_type: :read_info, path: "/api/v3/allOrders",
11
11
  params: params.delete_if { |key, value| value.nil? },
12
- security_type: :user_data)
12
+ security_type: :user_data, tld: Configuration.tld)
13
13
  end
14
14
 
15
15
  # Be careful when accessing without a symbol!
@@ -17,7 +17,7 @@ module Binance
17
17
  timestamp = Configuration.timestamp
18
18
  params = { recvWindow: recvWindow, symbol: symbol, timestamp: timestamp }
19
19
  Request.send!(api_key_type: :read_info, path: "/api/v3/openOrders",
20
- params: params, security_type: :user_data)
20
+ params: params, security_type: :user_data, tld: Configuration.tld)
21
21
  end
22
22
 
23
23
  def cancel!(orderId: nil, originalClientOrderId: nil, newClientOrderId: nil, recvWindow: nil, symbol: nil)
@@ -29,7 +29,7 @@ module Binance
29
29
  newClientOrderId: newClientOrderId, recvWindow: recvWindow,
30
30
  symbol: symbol, timestamp: timestamp }.delete_if { |key, value| value.nil? }
31
31
  Request.send!(api_key_type: :trading, method: :delete, path: "/api/v3/order",
32
- params: params, security_type: :trade)
32
+ params: params, security_type: :trade, tld: Configuration.tld)
33
33
  end
34
34
 
35
35
  def create!(icebergQuantity: nil, newClientOrderId: nil, newOrderResponseType: nil,
@@ -45,7 +45,7 @@ module Binance
45
45
  ensure_required_create_keys!(params: params)
46
46
  path = "/api/v3/order#{"/test" if test}"
47
47
  Request.send!(api_key_type: :trading, method: :post, path: path,
48
- params: params, security_type: :trade)
48
+ params: params, security_type: :trade, tld: Configuration.tld)
49
49
  end
50
50
 
51
51
  def status!(orderId: nil, originalClientOrderId: nil, recvWindow: nil, symbol: nil)
@@ -58,7 +58,7 @@ module Binance
58
58
  symbol: symbol, timestamp: timestamp,
59
59
  }.delete_if { |key, value| value.nil? }
60
60
  Request.send!(api_key_type: :trading, path: "/api/v3/order",
61
- params: params, security_type: :user_data)
61
+ params: params, security_type: :user_data, tld: Configuration.tld)
62
62
  end
63
63
 
64
64
  private
@@ -3,8 +3,9 @@ module Binance
3
3
  class Request
4
4
  include HTTParty
5
5
  class << self
6
- def send!(api_key_type: :none, headers: {}, method: :get, path: "/", params: {}, security_type: :none)
7
- self.base_uri "https://api.binance.#{Configuration.tld}"
6
+ def send!(api_key_type: :none, headers: {}, method: :get, path: "/", params: {}, security_type: :none, tld: :com)
7
+ Configuration.validate_tld!(tld)
8
+ self.base_uri "https://api.binance.#{tld}"
8
9
 
9
10
  raise Error.new(message: "invalid security type #{security_type}") unless security_types.include?(security_type)
10
11
  all_headers = default_headers(api_key_type: api_key_type, security_type: security_type)
@@ -1,5 +1,5 @@
1
1
  module Binance
2
2
  module Api
3
- VERSION = "0.5"
3
+ VERSION = "0.6"
4
4
  end
5
5
  end
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.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Peterson
@@ -129,9 +129,6 @@ dependencies:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: 5.1.0
132
- - - "<"
133
- - !ruby/object:Gem::Version
134
- version: 7.0.0
135
132
  type: :runtime
136
133
  prerelease: false
137
134
  version_requirements: !ruby/object:Gem::Requirement
@@ -139,9 +136,6 @@ dependencies:
139
136
  - - ">="
140
137
  - !ruby/object:Gem::Version
141
138
  version: 5.1.0
142
- - - "<"
143
- - !ruby/object:Gem::Version
144
- version: 7.0.0
145
139
  - !ruby/object:Gem::Dependency
146
140
  name: awrence
147
141
  requirement: !ruby/object:Gem::Requirement
@@ -210,5 +204,5 @@ requirements: []
210
204
  rubygems_version: 3.0.8
211
205
  signing_key:
212
206
  specification_version: 4
213
- summary: binance-ruby-0.5
207
+ summary: binance-ruby-0.6
214
208
  test_files: []