class EcwidApi::Category
Public Instance Methods
all_sub_categories(params = {})
click to toggle source
Public: Returns an Array of all of the sub categories (deep) for the
Category
# File lib/ecwid_api/category.rb, line 17 def all_sub_categories(params = {}) @all_sub_categories ||= sub_categories(params) + sub_categories.flat_map do |sub| sub.all_sub_categories(params) end end
parent()
click to toggle source
Public: Returns the parent EcwidApi::Category
, or nil if there isn't one
# File lib/ecwid_api/category.rb, line 24 def parent @parent ||= begin parent_id = data["parentId"] client.categories.find(parent_id) if parent_id end end
parents()
click to toggle source
# File lib/ecwid_api/category.rb, line 31 def parents if parent parent.parents + [parent] else [] end end
product_ids()
click to toggle source
Calls superclass method
# File lib/ecwid_api/category.rb, line 50 def product_ids super || [] end
products(params = {})
click to toggle source
Public: Returns the Products that belong to the Category
params - a Hash of values that can be used for a Prdocut search
Returns an Enumeration of Products
# File lib/ecwid_api/category.rb, line 44 def products(params = {}) @products ||= product_ids.map do |product_id| client.products.find(product_id) end end
sub_categories(params = {})
click to toggle source
Public: Returns an Array of sub categories for the Category
# File lib/ecwid_api/category.rb, line 11 def sub_categories(params = {}) @sub_categories ||= client.categories.all(params.merge(parent: id)) end
upload_image!(filename)
click to toggle source