Class: Etsy::Category
Overview
Category
A category of listings for sale, formed from 1 to 3 tags.
A category has the following attributes:
- page_description
-
A short description of the category from the category’s landing page
- page_title
-
The title of the category’s landing page
- category_name
-
The category’s string ID
- short_name
-
A short display name for the category
- long_name
-
A longer display name for the category
- children_count
-
The number of subcategories below this one
Class Method Summary collapse
-
.all_top(options = {}) ⇒ Object
Retrieve a list of all top-level categories.
- .find(tag) ⇒ Object
-
.find_all_subcategories(category, options = {}) ⇒ Object
Retrieve a list of all subcategories of the specified category.
-
.find_top(*identifiers_and_options) ⇒ Object
Retrieve one or more top-level categories by name:.
Instance Method Summary collapse
-
#active_listings ⇒ Object
The collection of active listings associated with this category.
-
#subcategories ⇒ Object
The collection of subcategories associated with this category.
Methods included from Model
included, #initialize, #result, #secret, #token
Class Method Details
.all_top(options = {}) ⇒ Object
62 63 64 |
# File 'lib/etsy/category.rb', line 62 def self.all_top( = {}) self.get_all("/taxonomy/categories", ) end |
.find(tag) ⇒ Object
54 55 56 |
# File 'lib/etsy/category.rb', line 54 def self.find(tag) get("/categories/#{tag}") end |
.find_all_subcategories(category, options = {}) ⇒ Object
Retrieve a list of all subcategories of the specified category.
Etsy::Category.find_all_subcategories('accessories')
You can also find the subcategories of a subcategory.
Etsy::Category.find_all_subcategories('accessories/apron')
Etsy categories only go three levels deep, so this will return nil past the third level.
Etsy::Category.find_all_subcategories('accessories/apron/women')
=> nil
50 51 52 |
# File 'lib/etsy/category.rb', line 50 def self.find_all_subcategories(category, = {}) valid?(category) ? self.get_all("/taxonomy/categories/#{category}", ) : nil end |
.find_top(*identifiers_and_options) ⇒ Object
33 34 35 |
# File 'lib/etsy/category.rb', line 33 def self.find_top(*) self.find_one_or_more('categories', ) end |
Instance Method Details
#active_listings ⇒ Object
The collection of active listings associated with this category.
68 69 70 |
# File 'lib/etsy/category.rb', line 68 def active_listings @active_listings ||= Listing.find_all_active_by_category(category_name) end |
#subcategories ⇒ Object
The collection of subcategories associated with this category.
74 75 76 |
# File 'lib/etsy/category.rb', line 74 def subcategories @subcategories ||= Category.find_all_subcategories(category_name) end |