Class: Merchantconfig

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

Overview

This fuction has all the merchantConfig properties getters and setters methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cybsPropertyObj) ⇒ Merchantconfig

Returns a new instance of Merchantconfig.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 7

def initialize(cybsPropertyObj)
# Common Parameters
@merchantId = cybsPropertyObj['merchantID']
@runEnvironment = cybsPropertyObj['runEnvironment']
@authenticationType = cybsPropertyObj['authenticationType']
@logDirectory = cybsPropertyObj['logDirectory']
@logSize = cybsPropertyObj['logSize']
@enableLog = cybsPropertyObj['enableLog']
@proxyAddress = cybsPropertyObj['proxyAddress']
@proxyPort = cybsPropertyObj['proxyPort']
@getId = ''
@requestHost = ''
@requestTarget = ''
@requestJsonData = ''
# HTTP Parameters
@merchantSecretKey = cybsPropertyObj['merchantsecretKey']
@merchantKeyId = cybsPropertyObj['merchantKeyId']
# JWT Parameters
@keysDirectory = cybsPropertyObj['keysDirectory']
@keyAlias = cybsPropertyObj['keyAlias']
@keyPass = cybsPropertyObj['keyPass']
@keyFilename = cybsPropertyObj['keyFilename']
@useMetaKey = cybsPropertyObj['useMetaKey']
@portfolioID = cybsPropertyObj['portfolioID']
@logFilename = cybsPropertyObj['logFilename']
@solutionId = cybsPropertyObj['solutionId']
validateMerchantDetails()
logAllProperties(cybsPropertyObj)
end

Instance Attribute Details

#authenticationTypeObject

Returns the value of attribute authenticationType.



178
179
180
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 178

def authenticationType
  @authenticationType
end

#enableLogObject

Returns the value of attribute enableLog.



192
193
194
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 192

def enableLog
  @enableLog
end

#getIdObject

Returns the value of attribute getId.



189
190
191
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 189

def getId
  @getId
end

#keyAliasObject

Returns the value of attribute keyAlias.



181
182
183
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 181

def keyAlias
  @keyAlias
end

#keyFilenameObject

Returns the value of attribute keyFilename.



183
184
185
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 183

def keyFilename
  @keyFilename
end

#keyPassObject

Returns the value of attribute keyPass.



182
183
184
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 182

def keyPass
  @keyPass
end

#keysDirectoryObject

Returns the value of attribute keysDirectory.



179
180
181
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 179

def keysDirectory
  @keysDirectory
end

#log_objObject

Returns the value of attribute log_obj.



198
199
200
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 198

def log_obj
  @log_obj
end

#logDirectoryObject

Returns the value of attribute logDirectory.



190
191
192
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 190

def logDirectory
  @logDirectory
end

#logFilenameObject

Returns the value of attribute logFilename.



191
192
193
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 191

def logFilename
  @logFilename
end

#loggerObject

Returns the value of attribute logger.



194
195
196
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 194

def logger
  @logger
end

#logSizeObject

Returns the value of attribute logSize.



193
194
195
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 193

def logSize
  @logSize
end

#merchantIdObject

getter and setter methods



175
176
177
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 175

def merchantId
  @merchantId
end

#merchantKeyIdObject

Returns the value of attribute merchantKeyId.



177
178
179
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 177

def merchantKeyId
  @merchantKeyId
end

#merchantSecretKeyObject

Returns the value of attribute merchantSecretKey.



176
177
178
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 176

def merchantSecretKey
  @merchantSecretKey
end

#portfolioIDObject

Returns the value of attribute portfolioID.



185
186
187
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 185

def portfolioID
  @portfolioID
end

#proxyAddressObject

Returns the value of attribute proxyAddress.



195
196
197
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 195

def proxyAddress
  @proxyAddress
end

#proxyPortObject

Returns the value of attribute proxyPort.



196
197
198
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 196

def proxyPort
  @proxyPort
end

#requestHostObject

Returns the value of attribute requestHost.



180
181
182
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 180

def requestHost
  @requestHost
end

#requestJsonDataObject

Returns the value of attribute requestJsonData.



186
187
188
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 186

def requestJsonData
  @requestJsonData
end

#requestTargetObject

Returns the value of attribute requestTarget.



197
198
199
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 197

def requestTarget
  @requestTarget
end

#requestTypeObject

Returns the value of attribute requestType.



188
189
190
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 188

def requestType
  @requestType
end

#requestUrlObject

Returns the value of attribute requestUrl.



187
188
189
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 187

def requestUrl
  @requestUrl
end

#solutionIdObject

Returns the value of attribute solutionId.



199
200
201
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 199

def solutionId
  @solutionId
end

#useMetaKeyObject

Returns the value of attribute useMetaKey.



184
185
186
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 184

def useMetaKey
  @useMetaKey
end

Instance Method Details

#logAllProperties(propertyObj) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 157

def logAllProperties(propertyObj)
  merchantConfig = ''
  hiddenProperties = (Constants::HIDDEN_MERCHANT_PROPERTIES).split(',')
  hiddenPropArray = Array.new
  hiddenProperties.each do |value|
    hiddenPropArray << value.strip
  end
  hiddenPropArray.each do |prop|
    propertyObj.each do |key, value|
      if key == prop
        propertyObj.delete(key)
      end
    end
  end
  @log_obj.logger.info('MERCHCFG >' + propertyObj.to_s)
end

#validateMerchantDetailsObject

fall back logic



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/AuthenticationSDK/core/MerchantConfig.rb', line 37

def validateMerchantDetails()
  logmessage=''
  if @enableLog.to_s.empty?
    @enableLog = true
  elsif @enableLog.instance_of? Integer
    @enableLog = @enableLog.to_s
  end
  if @logSize.to_s.empty?
    @logSize = Constants::DEFAULT_LOG_SIZE
  elsif !@logSize.instance_of? Integer
    @logSize=@logSize.to_i
  end
  if @logDirectory.to_s.empty? || !Dir.exist?(@logDirectory)
    @logDirectory = Constants::DEFAULT_LOG_DIRECTORY
    unless Dir.exist?(@logDirectory)
      Dir.mkdir(Constants::DEFAULT_LOG_DIRECTORY)
    end
    logmessage = Constants::WARNING_PREFIX + Constants::INVALID_LOG_DIRECTORY + File.expand_path(@logDirectory)
  end
  if @logFilename.to_s.empty?
    @logFilename = Constants::DEFAULT_LOGFILE_NAME
  elsif !@logFilename.instance_of? String
    @logFilename=@logFilename.to_s
  end
  @log_obj = Log.new @logDirectory,@logFilename,@logSize,@enableLog
  @log_obj.logger.info('START> =======================================')
  if !logmessage.to_s.empty?
    ApiException.new.apiwarning(logmessage,log_obj)
  end
  if @merchantId.to_s.empty?
    err = raise StandardError.new(Constants::ERROR_PREFIX + Constants::MERCHANT_ID_NULL)
    ApiException.new.apiexception(err,log_obj)
  elsif !@merchantId.instance_of? String
    @merchantId=@merchantId.to_s
  end
  if @authenticationType.to_s.empty?
    err = raise StandardError.new(Constants::ERROR_PREFIX + Constants::AUTH_TYPE_MANDATORY)
    ApiException.new.apiexception(err,log_obj) 
  end
  if !@authenticationType.instance_of? String 
    err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::AUTH_ERROR)
    ApiException.new.apiexception(err,log_obj)
  end
  if !@runEnvironment.to_s.empty?
    if !@runEnvironment.instance_of? String
      @requestHost = @runEnvironment.to_s
    elsif @runEnvironment.upcase == Constants::RUN_ENV_PROD
      @requestHost = Constants::PRODUCTION_URL
    elsif @runEnvironment.upcase == Constants::RUN_ENV_SANDBOX
      @requestHost = Constants::SANDBOX_URL
    elsif @runEnvironment.upcase == Constants::BOA_RUN_ENV_PROD
      @requestHost = Constants::BOA_PRODUCTION_URL
    elsif @runEnvironment.upcase == Constants.BOA_RUN_ENV_SANDBOX
      @requestHost = Constants::BOA_SANDBOX_URL
    elsif @runEnvironment.upcase == Constants::IDC_RUN_ENV_PROD
      @requestHost = Constants::IDC_PRODUCTION_URL
    elsif @runEnvironment.upcase == Constants.IDC_RUN_ENV_SANDBOX
      @requestHost = Constants::IDC_SANDBOX_URL
    else
      @requestHost = @runEnvironment
    end
  elsif @runEnvironment.to_s.empty?
    err = raise StandardError.new(Constants::ERROR_PREFIX + Constants::RUN_ENVIRONMENT)
    ApiException.new.apiexception(err,log_obj)
  end
  if @authenticationType.upcase == Constants::AUTH_TYPE_JWT
    if @keyAlias.to_s.empty?
      @keyAlias = @merchantId
      ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_ALIAS_NULL_EMPTY, log_obj)
    elsif !@keyAlias.instance_of? String
      @keyAlias=@keyAlias.to_s
    elsif @keyAlias != @merchantId
      @keyAlias = @merchantId
      ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::INCORRECT_KEY_ALIAS, log_obj)
    end
    if @keyPass.to_s.empty?
      @keyPass = @merchantId
      ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_PASS_NULL, log_obj)
    elsif !@keyPass.instance_of? String
      @keyPass=@keyPass.to_s
    end
    if @keysDirectory.to_s.empty?
      @keysDirectory = Constants::DEFAULT_KEY_DIRECTORY
      ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_DIRECTORY_EMPTY + @keysDirectory, log_obj)
    elsif !@keysDirectory.instance_of? String
      @keysDirectory=@keysDirectory.to_s
    end
    if @keyFilename.to_s.empty?
      @keyFilename = @merchantId
      ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_FILE_NAME_NULL_EMPTY, log_obj)
    elsif !@keyFilename.instance_of? String
      @keyFilename=@keyFilename.to_s
    end
  end
  if @authenticationType.upcase == Constants::AUTH_TYPE_HTTP
    if @merchantKeyId.to_s.empty?
      err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::MERCHANT_KEY_ID_MANDATORY)
      ApiException.new.apiexception(err,log_obj)
    elsif !@merchantKeyId.instance_of? String
      @merchantKeyId=@merchantKeyId.to_s
    end
    if @merchantSecretKey.to_s.empty?
      err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::MERCHANT_SECRET_KEY_MANDATORY) 
      ApiException.new.apiexception(err,log_obj)
    elsif !@merchantSecretKey.instance_of? String
      @merchantSecretKey=@merchantSecretKey.to_s
    end
  end
  if @useMetaKey && @portfolioID.to_s.empty?
    err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::PORTFOLIO_ID_MANDATORY) 
    ApiException.new.apiexception(err,log_obj)
  end

  if !@proxyAddress.instance_of? String
    @proxyAddress=@proxyAddress.to_s
  end
  if !@proxyPort.instance_of? String
    @proxyPort=@proxyPort.to_s
  end
end