Class: RubyOmx::Base
- Inherits:
-
Object
- Object
- RubyOmx::Base
- Defined in:
- lib/ruby_omx/base.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#request(verb, body = nil, attempts = 0, &block) ⇒ Object
Wraps the current connection’s request method and picks the appropriate response class to wrap the response in.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 |
# File 'lib/ruby_omx/base.rb', line 8 def initialize( ={}) @http_biz_id = ['http_biz_id'] @udi_auth_token = ['udi_auth_token'] raise RubyOmx::MissingAccessKey.new(['udi auth token', 'http biz id']) unless @udi_auth_token && @http_biz_id @connection = RubyOmx::Connection.connect() end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6 7 8 |
# File 'lib/ruby_omx/base.rb', line 6 def connection @connection end |
Instance Method Details
#request(verb, body = nil, attempts = 0, &block) ⇒ Object
Wraps the current connection’s request method and picks the appropriate response class to wrap the response in. If the response is an error, it will raise that error as an exception. All such exceptions can be caught by rescuing their superclass, the ResponseError exception class.
It is unlikely that you would call this method directly. Subclasses of Base have convenience methods for each http request verb that wrap calls to request.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_omx/base.rb', line 22 def request(verb, body = nil, attempts = 0, &block) # Find the connection method in connection/management.rb which is evaled into Amazon::MWS::Base response = @connection.request(verb, body, attempts, &block) # Each calling class is responsible for formatting the result return response rescue InternalError, RequestTimeout if attempts == 3 raise else attempts += 1 retry end end |