Class: Binance::Api::Configuration
- Inherits:
-
Object
- Object
- Binance::Api::Configuration
- Defined in:
- lib/binance/api/configuration.rb
Class Attribute Summary collapse
- .api_key(type: nil) ⇒ Object
-
.locale ⇒ Object
writeonly
Sets the attribute locale.
-
.read_info_api_key ⇒ Object
writeonly
Sets the attribute read_info_api_key.
- .secret_key ⇒ Object
-
.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
- .signed_request_signature(payload:, api_secret_key: nil) ⇒ Object
- .timestamp ⇒ Object
- .tld ⇒ Object
- .validate_tld!(tld) ⇒ Object
Class Attribute Details
.api_key(type: nil) ⇒ Object
11 12 13 14 |
# File 'lib/binance/api/configuration.rb', line 11 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) || ENV["BINANCE_#{type.to_s.humanize.upcase}_API_KEY"] || instance_api_key || ENV["BINANCE_API_KEY"] end |
.locale=(value) ⇒ Object (writeonly)
Sets the attribute locale
8 9 10 |
# File 'lib/binance/api/configuration.rb', line 8 def locale=(value) @locale = value end |
.read_info_api_key=(value) ⇒ Object (writeonly)
Sets the attribute read_info_api_key
8 9 10 |
# File 'lib/binance/api/configuration.rb', line 8 def read_info_api_key=(value) @read_info_api_key = value end |
.secret_key ⇒ Object
22 23 24 |
# File 'lib/binance/api/configuration.rb', line 22 def secret_key instance_variable_get("@secret_key") || ENV["BINANCE_SECRET_KEY"] end |
.trading_api_key=(value) ⇒ Object (writeonly)
Sets the attribute trading_api_key
8 9 10 |
# File 'lib/binance/api/configuration.rb', line 8 def trading_api_key=(value) @trading_api_key = value end |
.withdrawals_api_key=(value) ⇒ Object (writeonly)
Sets the attribute withdrawals_api_key
8 9 10 |
# File 'lib/binance/api/configuration.rb', line 8 def withdrawals_api_key=(value) @withdrawals_api_key = value end |
Class Method Details
.signed_request_signature(payload:, api_secret_key: nil) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/binance/api/configuration.rb', line 26 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 |
.timestamp ⇒ Object
33 34 35 |
# File 'lib/binance/api/configuration.rb', line 33 def Time.now.utc.strftime("%s%3N") end |
.tld ⇒ Object
16 17 18 19 20 |
# File 'lib/binance/api/configuration.rb', line 16 def tld tld = ENV["BINANCE_TLD"]&.downcase&.to_sym || :com validate_tld!(tld) tld end |