55module RakutenWebService
66 class Configuration
77 attr_accessor :application_id , :affiliate_id , :max_retries , :debug , :access_key
8+ attr_reader :access_key_transport
9+
10+ ALLOWED_ACCESS_KEY_TRANSPORTS = [ :access_key_header , :query ] . freeze
811
912 def initialize
1013 @application_id = ENV [ 'RWS_APPLICATION_ID' ]
1114 @affiliate_id = ENV [ 'RWS_AFFILIATE_ID' ]
1215 @max_retries = 5
1316 @access_key = ENV [ 'RWS_ACCESS_KEY' ]
17+ @access_key_transport = :access_key_header
1418 end
1519
1620 def generate_parameters ( params )
@@ -19,7 +23,11 @@ def generate_parameters(params)
1923
2024 def default_parameters
2125 raise 'Application ID and access key are not defined' unless has_required_options?
22- { application_id : application_id , affiliate_id : affiliate_id , format_version : '2' }
26+ params = { application_id : application_id , affiliate_id : affiliate_id , format_version : '2' }
27+ if access_key_transport == :query
28+ params [ :access_key ] = access_key
29+ end
30+ params
2331 end
2432
2533 def has_required_options?
@@ -30,6 +38,13 @@ def debug_mode?
3038 ENV . key? ( 'RWS_SDK_DEBUG' ) || debug
3139 end
3240
41+ def access_key_transport = ( value )
42+ unless ALLOWED_ACCESS_KEY_TRANSPORTS . include? ( value &.to_sym )
43+ raise ArgumentError , "Invalid access_key_transport value: #{ value } , expected one of: #{ ALLOWED_ACCESS_KEY_TRANSPORTS . inspect } "
44+ end
45+ @access_key_transport = value &.to_sym
46+ end
47+
3348 private
3449
3550 using RakutenWebService ::StringSupport
0 commit comments