Class: Alexa::API::CategoryListings

Inherits:
Base
  • Object
show all
Defined in:
lib/alexa/api/category_listings.rb

Instance Attribute Summary

Attributes inherited from Base

#arguments, #response_body

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parsed_body

Methods included from Utils

camelize, safe_retrieve

Constructor Details

This class inherits a constructor from Alexa::API::Base

Instance Method Details

#countObject

Response attributes



22
23
24
25
26
# 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 = {}) ⇒ Object

Raises:



6
7
8
9
10
11
12
13
14
15
16
17
18
# 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

#listingsObject



34
35
36
# 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_countObject



28
29
30
31
32
# 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_idObject



42
43
44
# File 'lib/alexa/api/category_listings.rb', line 42

def request_id
  @request_id ||= safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "OperationRequest", "RequestId")
end

#status_codeObject



38
39
40
# File 'lib/alexa/api/category_listings.rb', line 38

def status_code
  @status_code ||= safe_retrieve(parsed_body, "CategoryListingsResponse", "Response", "ResponseStatus", "StatusCode")
end