class Sevennet::Api::Response

Response object returned after a REST call to sevennet api.

Public Class Methods

new(xml) click to toggle source

XML input is in string format

# File lib/sevennet/api.rb, line 141
def initialize(xml)
  @doc = Nokogiri::XML(xml, nil, 'UTF-8')
  @doc.remove_namespaces!
end

Public Instance Methods

categories() click to toggle source

Return an array of Sevennet::Element category objects.

# File lib/sevennet/api.rb, line 167
def categories
  @categories ||= (@doc/"Category").collect { |it| Element.new(it) }
end
doc() click to toggle source

Return Nokogiri::XML::Document object.

# File lib/sevennet/api.rb, line 147
def doc
  @doc
end
error() click to toggle source

Return error message.

# File lib/sevennet/api.rb, line 157
def error
  Element.get(@doc, "//ApiErrorMessage")
end
error_code() click to toggle source

Return error code

# File lib/sevennet/api.rb, line 162
def error_code
  Element.get(@doc, "//ApiErrorStatus")
end
has_error?() click to toggle source

Return true if response has an error.

# File lib/sevennet/api.rb, line 152
def has_error?
  !(error.nil? || error.empty?)
end
products() click to toggle source

Return an array of Sevennet::Element product objects.

# File lib/sevennet/api.rb, line 177
def products
  @products ||= (@doc/"Product").collect { |it| Element.new(it) }
end
reviews() click to toggle source

Return an array of Sevennet::Element review objects.

# File lib/sevennet/api.rb, line 182
def reviews
  @reviews ||= (@doc/"ProductReview").collect { |it| Element.new(it) }
end
shops() click to toggle source

Return an array of Sevennet::Element shop objects.

# File lib/sevennet/api.rb, line 172
def shops
  @shops ||= (@doc/"SpcShop").collect { |it| Element.new(it) }
end
total_amount() click to toggle source

Return total results.

# File lib/sevennet/api.rb, line 187
def total_amount
  @total_amount ||= Element.get(@doc, "//TotalAmount").to_i
end