Class: Binance::SDK::Configuration
- Inherits:
-
Object
- Object
- Binance::SDK::Configuration
- Defined in:
- lib/binance/sdk/configuration.rb
Class Attribute Summary collapse
- .api_key(type: nil) ⇒ Object
-
.futures ⇒ Object
writeonly
Sets the attribute futures.
-
.locale ⇒ Object
writeonly
Sets the attribute locale.
-
.read_info_api_key ⇒ Object
writeonly
Sets the attribute read_info_api_key.
- .secret_key ⇒ Object
-
.testnet ⇒ Object
writeonly
Sets the attribute testnet.
-
.trading_api_key ⇒ Object
writeonly
Sets the attribute trading_api_key.
-
.withdrawals_api_key ⇒ Object
writeonly
Sets the attribute withdrawals_api_key.
Class Method Summary collapse
- .futures? ⇒ Boolean
- .signed_request_signature(payload:, api_secret_key: nil) ⇒ Object
- .spot? ⇒ Boolean
- .testnet? ⇒ Boolean
- .timestamp ⇒ Object
- .tld ⇒ Object
- .validate_tld!(tld) ⇒ Object
Class Attribute Details
.api_key(type: nil) ⇒ Object
7 8 9 10 11 |
# File 'lib/binance/sdk/configuration.rb', line 7 def api_key(type: nil) raise Error.new(message: "Invalid api_key type: #{type}.") unless type.nil? || API_KEY_TYPES.include?(type) instance_api_key(type: type) end |
.futures=(value) ⇒ Object (writeonly)
Sets the attribute futures
5 6 7 |
# File 'lib/binance/sdk/configuration.rb', line 5 def futures=(value) @futures = value end |
.locale=(value) ⇒ Object (writeonly)
Sets the attribute locale
5 6 7 |
# File 'lib/binance/sdk/configuration.rb', line 5 def locale=(value) @locale = value end |
.read_info_api_key=(value) ⇒ Object (writeonly)
Sets the attribute read_info_api_key
5 6 7 |
# File 'lib/binance/sdk/configuration.rb', line 5 def read_info_api_key=(value) @read_info_api_key = value end |
.secret_key ⇒ Object
13 14 15 |
# File 'lib/binance/sdk/configuration.rb', line 13 def secret_key instance_variable_get("@secret_key") || ENV["BINANCE_SECRET_KEY"] end |
.testnet=(value) ⇒ Object (writeonly)
Sets the attribute testnet
5 6 7 |
# File 'lib/binance/sdk/configuration.rb', line 5 def testnet=(value) @testnet = value end |
.trading_api_key=(value) ⇒ Object (writeonly)
Sets the attribute trading_api_key
5 6 7 |
# File 'lib/binance/sdk/configuration.rb', line 5 def trading_api_key=(value) @trading_api_key = value end |
.withdrawals_api_key=(value) ⇒ Object (writeonly)
Sets the attribute withdrawals_api_key
5 6 7 |
# File 'lib/binance/sdk/configuration.rb', line 5 def withdrawals_api_key=(value) @withdrawals_api_key = value end |
Class Method Details
.futures? ⇒ Boolean
17 18 19 |
# File 'lib/binance/sdk/configuration.rb', line 17 def futures? (instance_variable_get("@futures") || ENV["BINANCE_FUTURES"]) == true end |
.signed_request_signature(payload:, api_secret_key: nil) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/binance/sdk/configuration.rb', line 29 def signed_request_signature(payload:, api_secret_key: nil) raise Error.new(message: "Environment variable 'BINANCE_SECRET_KEY' is required for signed requests.") unless api_secret_key || secret_key digest = OpenSSL::Digest::SHA256.new OpenSSL::HMAC.hexdigest(digest, api_secret_key || secret_key, payload) end |
.spot? ⇒ Boolean
21 22 23 |
# File 'lib/binance/sdk/configuration.rb', line 21 def spot? !futures? end |
.testnet? ⇒ Boolean
25 26 27 |
# File 'lib/binance/sdk/configuration.rb', line 25 def testnet? (instance_variable_get("@testnet") || ENV["BINANCE_TESTNET"]) == true end |
.timestamp ⇒ Object
43 44 45 |
# File 'lib/binance/sdk/configuration.rb', line 43 def Time.now.strftime("%s%3N") end |
.tld ⇒ Object
36 37 38 39 40 41 |
# File 'lib/binance/sdk/configuration.rb', line 36 def tld tld = ENV["BINANCE_TLD"]&.downcase&.to_sym || :com validate_tld!(tld) tld end |