Class: Cryptoexchange::Exchanges::BitboxPrivate::Authentication

Inherits:
Services::Authentication show all
Defined in:
lib/cryptoexchange/exchanges/bitbox_private/authentication.rb

Instance Method Summary collapse

Methods inherited from Services::Authentication

#initialize, #is_missing_credentials?, #missing_credentials, #raise_credentials_missing_error, #validate_credentials!

Constructor Details

This class inherits a constructor from Cryptoexchange::Services::Authentication

Instance Method Details

#headers(payload, timestamp) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/cryptoexchange/exchanges/bitbox_private/authentication.rb', line 9

def headers(payload, timestamp)
  api_key = HashHelper.dig(Cryptoexchange::Credentials.get(@exchange), 'api_key')
  {
    "X-API-Key" => api_key,
    "X-API-SIGN" => signature(payload),
    "X-API-TIMESTAMP" => timestamp,
    "X-API-NONCE" => "12345"
  }
end

#required_credentialsObject



19
20
21
# File 'lib/cryptoexchange/exchanges/bitbox_private/authentication.rb', line 19

def required_credentials
  %i(api_key api_secret)
end

#signature(payload) ⇒ Object



4
5
6
7
# File 'lib/cryptoexchange/exchanges/bitbox_private/authentication.rb', line 4

def signature(payload)
  api_secret = HashHelper.dig(Cryptoexchange::Credentials.get(@exchange), 'api_secret')
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_secret, payload)
end