Sha256: 34212be65b0dc5fb1656d9fc4b3f2145fdc02ad0421bad7108d25eef89910b3c

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 Bytes

Contents

module Amazon
  module MWS
    
    class Response
      include ROXML
      xml_convention :camelcase
      
      # This is the factoryish method that is called!, not new
      def self.format(response)
        if response.content_type =~ /xml/ || response.body =~ /<?xml/
          parse_xml(response)  
        else
          response.body
        end
      end
      
      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
      
      def accessors
        roxml_references.map {|r| r.accessor}
      end
      
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amazon-mws-0.1.0 lib/amazon/mws/response.rb