Class: Ramazon::Configuration

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

Overview

the class that persists configuration information for Amazon requests

Constant Summary collapse

LOCALES =
[:ca, :de, :fr, :jp, :uk, :us]

Class Method Summary collapse

Class Method Details

.access_keyObject

get the current access key



23
24
25
# File 'lib/ramazon/configuration.rb', line 23

def access_key
  configatron.ramazon.access_key
end

.access_key=(key) ⇒ Object

set the current access key

Parameters:

  • key (String)

    access key you’re using to access the advertising api



29
30
31
# File 'lib/ramazon/configuration.rb', line 29

def access_key=(key)
  configatron.ramazon.access_key = key
end

.base_uriObject

get the correct host based on your locale



45
46
47
48
49
50
51
# File 'lib/ramazon/configuration.rb', line 45

def base_uri
  if locale == :us
    "http://ecs.amazonaws.com"
  else
    "http://ecs.amazonaws.#{locale}"
  end
end

.localeObject

get the current locale (defaults to the us)



18
19
20
# File 'lib/ramazon/configuration.rb', line 18

def locale
  configatron.ramazon.locale || :us
end

.locale=(locale) ⇒ Object

set the locale for future requests will raise an exception if the locale isn’t in the Configuration::LOCALES collection



9
10
11
12
13
14
15
# File 'lib/ramazon/configuration.rb', line 9

def locale=(locale)
  if LOCALES.include?(locale)
    configatron.ramazon.locale = locale
  else
    raise "unknown locale"
  end
end

.pathObject

get the path where requests should be dispatched to



59
60
61
# File 'lib/ramazon/configuration.rb', line 59

def path
  "/onca/xml"
end

.secret_keyObject

get the current secret key that is used for request signing



34
35
36
# File 'lib/ramazon/configuration.rb', line 34

def secret_key
  configatron.ramazon.secret_key
end

.secret_key=(key) ⇒ Object

set the secret key so that requests can be appropriately signed

Parameters:

  • key (String)

    secret key you’re using to sign advertising requests



40
41
42
# File 'lib/ramazon/configuration.rb', line 40

def secret_key=(key)
  configatron.ramazon.secret_key = key
end

.uriObject

get the full path including locale specific host and /onca/xml path



54
55
56
# File 'lib/ramazon/configuration.rb', line 54

def uri
  "#{base_uri}#{path}"
end