Sha256: 4c495f858ac4df00527b56e35a60a784c70e7098f16f16dc881845499c15e534
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
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 # render a ROXML object as a normal hash, eliminating the @ and some unneeded admin fields def as_hash obj_hash = {} self.instance_variables.each do |v| m = v.to_s.sub('@','') if m != 'roxml_references' && m!= 'promotion_ids' obj_hash[m.to_sym] = self.instance_variable_get(v) end end obj_hash end end end end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
amazon-mws-plus-0.1.3 | lib/amazon/mws/response.rb |
amazon-mws-plus-0.1.3 | lib/amazon/mws/response/response.rb |