Class: Vacuum::Endpoint::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vacuum/endpoint/base.rb

Overview

An Amazon Web Services (AWS) API endpoint.

Direct Known Subclasses

MWS, ProductAdvertising

Constant Summary collapse

LOCALES =
%w(CA CN DE ES FR IT JP UK US)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject

Returns the String AWS access key ID.

Raises a Missing Key error if key is missing.



17
18
19
# File 'lib/vacuum/endpoint/base.rb', line 17

def key
  @key or raise MissingKey
end

#localeObject

Returns the String AWS API locale (default: US).

Raises a Bad Locale error if locale is not valid.



27
28
29
30
31
32
# File 'lib/vacuum/endpoint/base.rb', line 27

def locale
  @locale ||= 'US'
  LOCALES.include? @locale or raise BadLocale

  @locale
end

#secretObject

Returns the String AWS access secret key.

Raises a Missing Secret error if secret is missing.



40
41
42
# File 'lib/vacuum/endpoint/base.rb', line 40

def secret
  @secret or raise MissingSecret
end

Instance Method Details

#hostObject

Raises a Not Implemented Error.

When implemented, this should return a String AWS API host.

Raises:

  • (NotImplementedError)


10
11
12
# File 'lib/vacuum/endpoint/base.rb', line 10

def host
  raise NotImplementedError
end

#user_agentObject

Returns a String user agent for the AWS API request.



48
49
50
51
52
53
54
55
# File 'lib/vacuum/endpoint/base.rb', line 48

def user_agent
  engine   = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
  language = [engine, RUBY_VERSION, "p#{RUBY_PATCHLEVEL}"].join ' '
  hostname = `hostname`.chomp
  version  = Vacuum::VERSION

  "Vacuum/#{version} (Language=#{language}; Host=#{hostname})"
end