class Alexa::API::CategoryListings

Public Instance Methods

count() click to toggle source

Response attributes

# File lib/alexa/api/category_listings.rb, line 22
def count
  return @count if defined?(@count)
  count = safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "CategoryListingsResult", "Alexa", "CategoryListings", "Count")
  @count = count ? count.to_i : nil
end
fetch(arguments = {}) click to toggle source
# File lib/alexa/api/category_listings.rb, line 6
def fetch(arguments = {})
  raise ArgumentError, "You must specify path" unless arguments.has_key?(:path)
  @arguments = arguments

  @arguments[:sort_by]      = arguments.fetch(:sort_by, "popularity")
  @arguments[:recursive]    = arguments.fetch(:recursive, true)
  @arguments[:descriptions] = arguments.fetch(:descriptions, true)
  @arguments[:start]        = arguments.fetch(:start, 0)
  @arguments[:count]        = arguments.fetch(:count, 20)

  @response_body = Alexa::Connection.new(@credentials).get(params)
  self
end
listings() click to toggle source
# File lib/alexa/api/category_listings.rb, line 34
def listings
  @listings ||= safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "CategoryListingsResult", "Alexa", "CategoryListings", "Listings", "Listing")
end
recursive_count() click to toggle source
# File lib/alexa/api/category_listings.rb, line 28
def recursive_count
  return @recursive_count if defined?(@recursive_count)
  recursive_count = safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "CategoryListingsResult", "Alexa", "CategoryListings", "RecursiveCount")
  @recursive_count = recursive_count ? recursive_count.to_i : nil
end
request_id() click to toggle source
# File lib/alexa/api/category_listings.rb, line 42
def request_id
  @request_id ||= safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "OperationRequest", "RequestId")
end
status_code() click to toggle source
# File lib/alexa/api/category_listings.rb, line 38
def status_code
  @status_code ||= safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "ResponseStatus", "StatusCode")
end

Private Instance Methods

descriptions_param() click to toggle source
# File lib/alexa/api/category_listings.rb, line 65
def descriptions_param
  arguments[:descriptions].to_s.capitalize
end
params() click to toggle source
# File lib/alexa/api/category_listings.rb, line 48
def params
  {
    "Action"        => "CategoryListings",
    "ResponseGroup" => "Listings",
    "Path"          => arguments[:path],
    "Recursive"     => recursive_param,
    "Descriptions"  => descriptions_param,
    "SortBy"        => sort_by_param,
    "Count"         => arguments[:count],
    "Start"         => arguments[:start],
  }
end
recursive_param() click to toggle source
# File lib/alexa/api/category_listings.rb, line 61
def recursive_param
  arguments[:recursive].to_s.capitalize
end
sort_by_param() click to toggle source
# File lib/alexa/api/category_listings.rb, line 69
def sort_by_param
  camelize(arguments[:sort_by])
end