Class: Amazon::MWS::Response

Inherits:
Object
  • Object
show all
Includes:
ROXML
Defined in:
lib/amazon/mws/response.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.format(response) ⇒ Object

This is the factoryish method that is called!, not new



9
10
11
12
13
14
15
# File 'lib/amazon/mws/response.rb', line 9

def self.format(response)
  if response.content_type =~ /xml/ || response.body =~ /<?xml/
    parse_xml(response)  
  else
    response.body
  end
end

.parse_xml(response) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/amazon/mws/response.rb', line 17

def self.parse_xml(response)
  if [Net::HTTPClientError, Net::HTTPServerError].any? {|error| response.is_a? error }
    return ResponseError.from_xml(response.body)
  else
    return self.from_xml(response.body)
  end
end

Instance Method Details

#accessorsObject



25
26
27
# File 'lib/amazon/mws/response.rb', line 25

def accessors
  roxml_references.map {|r| r.accessor}
end