Class: Authorization

Inherits:
Object
  • Object
show all
Defined in:
lib/AuthenticationSDK/core/Authorization.rb

Overview

This function calls for the generation of Signature message depending on the authentication type.

Instance Method Summary collapse

Instance Method Details

#getToken(merchantconfig_obj, gmtdatetime, log_obj) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/AuthenticationSDK/core/Authorization.rb', line 8

def getToken(merchantconfig_obj, gmtdatetime, log_obj)
  authenticationType = merchantconfig_obj.authenticationType.upcase
  if merchantconfig_obj.requestType.to_s.empty?
    raise StandardError.new(Constants::ERROR_PREFIX + Constants::REQUEST_TYPE_EMPTY)
  end
  if authenticationType == Constants::AUTH_TYPE_HTTP
    token = GenerateHttpSignature.new.getToken(merchantconfig_obj, gmtdatetime, log_obj)
  elsif authenticationType == Constants::AUTH_TYPE_JWT
    token = GenerateJwtToken.new.getToken(merchantconfig_obj, gmtdatetime, log_obj)
  elsif authenticationType != Constants::AUTH_TYPE_HTTP || authenticationType != Constants::AUTH_TYPE_JWT
    raise StandardError.ner(Constants::ERROR_PREFIX + Constants::AUTH_ERROR)
  end
rescue StandardError => err
  ApiException.new.apiexception(err,log_obj)
  exit!
end