Class: EbayClient::Configuration

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

Defined Under Namespace

Classes: ApiKey

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(presets) ⇒ Configuration

Returns a new instance of Configuration.



14
15
16
17
18
19
20
21
22
23
# File 'lib/ebay_client/configuration.rb', line 14

def initialize(presets)
  presets.each do |key, val|
    instance_variable_set "@#{key}", val
  end

  @api_keys = @api_keys.map do |key_values|
    ApiKey.new key_values
  end.shuffle
  @current_key = @api_keys.first
end

Instance Attribute Details

#api_keysObject

Returns the value of attribute api_keys.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def api_keys
  @api_keys
end

#current_keyObject

Returns the value of attribute current_key.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def current_key
  @current_key
end

#error_languageObject

Returns the value of attribute error_language.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def error_language
  @error_language
end

#http_read_timeoutObject

Returns the value of attribute http_read_timeout.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def http_read_timeout
  @http_read_timeout
end

#routingObject

Returns the value of attribute routing.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def routing
  @routing
end

#savon_log_levelObject

Returns the value of attribute savon_log_level.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def savon_log_level
  @savon_log_level
end

#siteidObject

Returns the value of attribute siteid.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def siteid
  @siteid
end

#urlObject

Returns the value of attribute url.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def url
  @url
end

#versionObject

Returns the value of attribute version.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def version
  @version
end

#warning_levelObject

Returns the value of attribute warning_level.



12
13
14
# File 'lib/ebay_client/configuration.rb', line 12

def warning_level
  @warning_level
end

Class Method Details

.load(file) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ebay_client/configuration.rb', line 56

def load(file)
  defaults = load_defaults
  configs = YAML.load(ERB.new(File.read(file)).result)

  configs.each_pair do |env, presets|
    env_defaults = defaults[env] || {}
    presets = presets || {}

    configs[env] = new env_defaults.merge(presets)
  end

  configs
end

Instance Method Details

#appidObject



31
32
33
# File 'lib/ebay_client/configuration.rb', line 31

def appid
  @current_key.appid
end

#certidObject



39
40
41
# File 'lib/ebay_client/configuration.rb', line 39

def certid
  @current_key.certid
end

#devidObject



35
36
37
# File 'lib/ebay_client/configuration.rb', line 35

def devid
  @current_key.devid
end

#next_key!Object



25
26
27
28
29
# File 'lib/ebay_client/configuration.rb', line 25

def next_key!
  i = @api_keys.index(@current_key) + 1
  i = 0 if i >= @api_keys.count
  @current_key = @api_keys[i]
end

#preload?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/ebay_client/configuration.rb', line 51

def preload?
  !!@preload
end

#tokenObject



43
44
45
# File 'lib/ebay_client/configuration.rb', line 43

def token
  @current_key.token
end

#wsdl_fileObject



47
48
49
# File 'lib/ebay_client/configuration.rb', line 47

def wsdl_file
  @wsdl_file ||= File.expand_path "../../../vendor/ebay/#{version}.wsdl", __FILE__
end