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
-
.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
Class Attribute Details
.api_key(type: nil) ⇒ Object
11 12 13 14 15 |
# File 'lib/binance/api/configuration.rb', line 11 def api_key(type: nil) raise Error.new(message: "invalid security_type 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 |
.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
17 18 19 |
# File 'lib/binance/api/configuration.rb', line 17 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:) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/binance/api/configuration.rb', line 21 def signed_request_signature(payload:) raise Error.new(message: "environment variable 'BINANCE_SECRET_KEY' is required " \ "for signed requests.") unless secret_key digest = OpenSSL::Digest::SHA256.new OpenSSL::HMAC.hexdigest(digest, secret_key, payload) end |
.timestamp ⇒ Object
28 29 30 |
# File 'lib/binance/api/configuration.rb', line 28 def Time.now.utc.strftime('%s%3N') end |