@@ -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