Class: RakutenWebService::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rakuten_web_service/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.


9
10
11
12
13
# File 'lib/rakuten_web_service/configuration.rb', line 9

def initialize
  @application_id = ENV['RWS_APPLICATION_ID']
  @affiliate_id = ENV['RWS_AFFILIATE_ID']
  @max_retries = 5
end

Instance Attribute Details

#affiliate_idObject

Returns the value of attribute affiliate_id


7
8
9
# File 'lib/rakuten_web_service/configuration.rb', line 7

def affiliate_id
  @affiliate_id
end

#application_idObject

Returns the value of attribute application_id


7
8
9
# File 'lib/rakuten_web_service/configuration.rb', line 7

def application_id
  @application_id
end

#debugObject

Returns the value of attribute debug


7
8
9
# File 'lib/rakuten_web_service/configuration.rb', line 7

def debug
  @debug
end

#max_retriesObject

Returns the value of attribute max_retries


7
8
9
# File 'lib/rakuten_web_service/configuration.rb', line 7

def max_retries
  @max_retries
end

Instance Method Details

#debug_mode?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/rakuten_web_service/configuration.rb', line 28

def debug_mode?
  ENV.key?('RWS_SDK_DEBUG') || debug
end

#default_parametersObject


19
20
21
22
# File 'lib/rakuten_web_service/configuration.rb', line 19

def default_parameters
  raise 'Application ID is not defined' unless has_required_options?
  { application_id: application_id, affiliate_id: affiliate_id, format_version: '2' }
end

#generate_parameters(params) ⇒ Object


15
16
17
# File 'lib/rakuten_web_service/configuration.rb', line 15

def generate_parameters(params)
  convert_snake_key_to_camel_key(default_parameters.merge(params))
end

#has_required_options?Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/rakuten_web_service/configuration.rb', line 24

def has_required_options?
  application_id && application_id != ''
end