Skip to content

Commit 4234b13

Browse files
committed
+ Fixed issues
1 parent 1b0cfe5 commit 4234b13

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

lib/AuthenticationSDK/core/Authorization.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def getToken(merchantconfig_obj, gmtdatetime, log_obj)
1616
elsif authenticationType == Constants::AUTH_TYPE_JWT
1717
token = GenerateJwtToken.new.getToken(merchantconfig_obj, gmtdatetime, log_obj)
1818
elsif authenticationType == Constants::AUTH_TYPE_OAUTH
19-
token = GenerateOAuthToken.new.getToken((merchantconfig_obj, gmtdatetime, log_obj)
19+
token = GenerateOAuthToken.new.getToken(merchantconfig_obj, gmtdatetime, log_obj)
2020
else
2121
raise StandardError.ner(Constants::ERROR_PREFIX + Constants::AUTH_ERROR)
2222
end

lib/AuthenticationSDK/core/MerchantConfig.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ def validateMerchantDetails()
9090
@requestHost = Constants::SANDBOX_URL
9191
elsif @runEnvironment.upcase == Constants::BOA_RUN_ENV_PROD
9292
@requestHost = Constants::BOA_PRODUCTION_URL
93-
elsif @runEnvironment.upcase == Constants.BOA_RUN_ENV_SANDBOX
93+
elsif @runEnvironment.upcase == Constants::BOA_RUN_ENV_SANDBOX
9494
@requestHost = Constants::BOA_SANDBOX_URL
9595
elsif @runEnvironment.upcase == Constants::IDC_RUN_ENV_PROD
9696
@requestHost = Constants::IDC_PRODUCTION_URL
97-
elsif @runEnvironment.upcase == Constants.IDC_RUN_ENV_SANDBOX
97+
elsif @runEnvironment.upcase == Constants::IDC_RUN_ENV_SANDBOX
9898
@requestHost = Constants::IDC_SANDBOX_URL
99-
elsif @runEnvironment.upcase == Constants.RUN_ENV_MUTUAL_AUTH_SANDBOX
99+
elsif @runEnvironment.upcase == Constants::RUN_ENV_MUTUAL_AUTH_SANDBOX
100100
@requestHost = Constants::MA_SANDBOX_URL
101-
elsif @runEnvironment.upcase == Constants.RUN_ENV_MUTUAL_AUTH_PROD
101+
elsif @runEnvironment.upcase == Constants::RUN_ENV_MUTUAL_AUTH_PROD
102102
@requestHost = Constants::MA_PRODUCTION_URL
103-
elsif @runEnvironment.upcase == Constants.RUN_ENV_SIT
103+
elsif @runEnvironment.upcase == Constants::RUN_ENV_SIT
104104
@requestHost = Constants::SIT_URL
105-
elsif @runEnvironment.upcase == Constants.RUN_ENV_MUTUAL_AUTH_SIT
105+
elsif @runEnvironment.upcase == Constants::RUN_ENV_MUTUAL_AUTH_SIT
106106
@requestHost = Constants::MA_SIT_URL
107107
else
108108
@requestHost = @runEnvironment

lib/cybersource_rest_client/api_client.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class ApiClient
3838
def initialize(config = Configuration.default)
3939
@config = config
4040
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
41-
@default_headers = {
42-
'Content-Type' => 'application/json',
41+
@default_headers = {
4342
'User-Agent' => @user_agent
4443
}
4544

@@ -116,21 +115,23 @@ def build_request(http_method, path, opts = {})
116115
query_params = Addressable::URI.form_encode(query_params)
117116
end
118117

119-
if merchantconfig_obj.authenticationType.upcase != Constants::AUTH_TYPE_MUTUAL_AUTH
120-
headers = CallAuthenticationHeader(http_method, path, body_params, opts[:header_params], query_params)
118+
119+
headers = opts[:header_params]
120+
if $merchantconfig_obj.authenticationType.upcase != Constants::AUTH_TYPE_MUTUAL_AUTH
121+
headers = CallAuthenticationHeader(http_method, path, body_params, headers, query_params)
121122
end
122123
http_method = http_method.to_sym.downcase
123-
header_params = @default_headers.merge(headers || {})
124+
header_params = headers.merge(@default_headers)
124125
form_params = opts[:form_params] || {}
125126

126127

127128
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
128129
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
129130

130131
# client cert
131-
if merchantconfig_obj.enableClientCert
132-
@config.cert_file = File.join(merchantconfig_obj.clientCertDirectory, merchantconfig_obj.publicKey)
133-
@config.key_file = File.join(merchantconfig_obj.clientCertDirectory, merchantconfig_obj.privateKey)
132+
if $merchantconfig_obj.enableClientCert
133+
@config.cert_file = File.join($merchantconfig_obj.clientCertDirectory, $merchantconfig_obj.sslClientCert)
134+
@config.key_file = File.join($merchantconfig_obj.clientCertDirectory, $merchantconfig_obj.privateKey)
134135
end
135136

136137
req_opts = {
@@ -142,7 +143,7 @@ def build_request(http_method, path, opts = {})
142143
:ssl_verifypeer => @config.verify_ssl,
143144
:ssl_verifyhost => _verify_ssl_host,
144145
:sslcert => @config.cert_file,
145-
:sslkeypasswd => merchantconfig_obj.clientCertPassword || "",
146+
:sslkeypasswd => $merchantconfig_obj.sslKeyPassword || "",
146147
:sslkey => @config.key_file,
147148
:verbose => @config.debugging
148149
}
@@ -396,6 +397,15 @@ def build_request_body(header_params, form_params, body)
396397
data[key] = value.to_s
397398
end
398399
end
400+
JSON.parse(body).each do |key, value|
401+
case value
402+
when ::File, ::Array, nil
403+
# let typhoeus handle File, Array and nil parameters
404+
data[key] = value
405+
else
406+
data[key] = value.to_s
407+
end
408+
end
399409
elsif body
400410
data = body.is_a?(String) ? body : body.to_json
401411
else

0 commit comments

Comments
 (0)