Class: Cryptoexchange::Exchanges::Coinut::Authentication

Inherits:
Services::Authentication show all
Defined in:
lib/cryptoexchange/exchanges/coinut/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) ⇒ Object



9
10
11
12
# File 'lib/cryptoexchange/exchanges/coinut/authentication.rb', line 9

def headers(payload)
  username = HashHelper.dig(Cryptoexchange::Credentials.get(@exchange), 'username')
  { 'X-USER' => username, 'X-SIGNATURE' => signature(payload) }
end

#required_credentialsObject



14
15
16
# File 'lib/cryptoexchange/exchanges/coinut/authentication.rb', line 14

def required_credentials
  %i(api_key username)
end

#signature(payload) ⇒ Object



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

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