class Alexandria::Amazon::Ecs::Response

Response object returned after a REST call to Amazon service.

Attributes

doc[R]

Return Hpricot object.

Public Class Methods

new(xml) click to toggle source

XML input is in string format

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 112
def initialize(xml)
  @doc = Hpricot(xml)
end

Public Instance Methods

error() click to toggle source

Return error message.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 130
def error
  Element.get(@doc, "error/message")
end
first_item() click to toggle source

Return the first item (Amazon::Element)

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 141
def first_item
  items.first
end
has_error?() click to toggle source

Return true if response has an error.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 125
def has_error?
  !(error.nil? || error.empty?)
end
is_valid_request?() click to toggle source

Return true if request is valid.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 120
def is_valid_request?
  (@doc / "isvalid").inner_html == "True"
end
item_page() click to toggle source

Return current page no if :item_page option is when initiating the request.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 146
def item_page
  @item_page ||= (@doc / "itemsearchrequest/itempage").inner_html.to_i
  @item_page
end
items() click to toggle source

Return an array of Amazon::Element item objects.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 135
def items
  @items ||= (@doc / "item").map { |item| Element.new(item) }
  @items
end
total_pages() click to toggle source

Return total pages.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 158
def total_pages
  @total_pages ||= (@doc / "totalpages").inner_html.to_i
  @total_pages
end
total_results() click to toggle source

Return total results.

# File lib/alexandria/book_providers/amazon_ecs_util.rb, line 152
def total_results
  @total_results ||= (@doc / "totalresults").inner_html.to_i
  @total_results
end