Skip to content

Commit 1bdb82e

Browse files
committed
Fix for Accept Header
1 parent bfc79bf commit 1bdb82e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/cybersource_rest_client/api_client.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class ApiClient
2828
attr_accessor :default_headers
2929

3030
# Defines the client ID for the SDK
31-
attr_accessor :client_id
31+
attr_accessor :client_id
32+
33+
# Defines the user-defined Accept Header Type
34+
attr_accessor :accept_header
3235

3336
# Initializes the ApiClient
3437
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
@@ -43,6 +46,10 @@ def initialize(config = Configuration.default)
4346
@client_id = 'cybs-rest-sdk-ruby-' + Gem.loaded_specs["cybersource_rest_client"].version.to_s
4447
end
4548

49+
def set_user_defined_accept_header(accept_type)
50+
@accept_header = accept_type
51+
end
52+
4653
def self.default
4754
@@default ||= ApiClient.new
4855
end
@@ -52,6 +59,11 @@ def self.default
5259
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
5360
# the data deserialized from response body (could be nil), response status code and response headers.
5461
def call_api(http_method, path, opts = {})
62+
if @accept_header != ''
63+
default_accept_header = ',' + (opts[:header_params])['Accept']
64+
default_accept_header = @accept_header + default_accept_header.sub(',' + @accept_header, '')
65+
opts[:header_params]['Accept'] = default_accept_header
66+
end
5567
request = build_request(http_method, path, opts)
5668
response = request.run
5769

0 commit comments

Comments
 (0)