class Amazon::Awis::Response

Response object returned after a REST call to Amazon service.

Public Class Methods

new(xml) click to toggle source

XML input is in string format

# File lib/awis-wrapper.rb, line 107
def initialize(xml)
        @doc = Nokogiri::XML(xml)
  @namespace = Awis::NAMESPACE
end

Public Instance Methods

doc() click to toggle source
# File lib/awis-wrapper.rb, line 112
def doc
  @doc
end
error() click to toggle source

Return error code

# File lib/awis-wrapper.rb, line 129
def error
  @doc.at_xpath("//aws:StatusMessage").content
end
get(tag) click to toggle source
# File lib/awis-wrapper.rb, line 120
def get(tag)
  Element.new @doc.at_xpath("//aws:#{Amazon::Awis.camel_case tag}", @namespace)
end
get_all(tag) click to toggle source
# File lib/awis-wrapper.rb, line 124
def get_all(tag)
  @doc.xpath("//aws:#{Amazon::Awis.camel_case tag}", @namespace).collect{|data|Element.new data}
end
method_missing(methodId) click to toggle source

returns inner html of any tag in awis response i.e resp.rank => 3

# File lib/awis-wrapper.rb, line 139
def method_missing(methodId)
  puts methodId
  @doc.send methodId 
end
success?() click to toggle source

Return error message.

# File lib/awis-wrapper.rb, line 134
def success?
  (@doc.at_xpath "//aws:StatusCode").content == "Success"                            
end
xpath(path) click to toggle source
# File lib/awis-wrapper.rb, line 116
def xpath(path)
  @doc.xpath(path, @namesapce)
end