Class: Binance::Api::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/binance/api/configuration.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_key(type: nil) ⇒ Object

Raises:



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

Parameters:

  • value

    the value to set the attribute read_info_api_key to.



8
9
10
# File 'lib/binance/api/configuration.rb', line 8

def read_info_api_key=(value)
  @read_info_api_key = value
end

.secret_keyObject



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

Parameters:

  • value

    the value to set the attribute trading_api_key to.



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

Parameters:

  • value

    the value to set the attribute withdrawals_api_key to.



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

Raises:



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

.timestampObject



28
29
30
# File 'lib/binance/api/configuration.rb', line 28

def timestamp
  Time.now.utc.strftime('%s%3N')
end