Class: Shirtsio::Product::Category

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/shirtsio/product.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize, #method_missing, #respond_to?

Constructor Details

This class inherits a constructor from Shirtsio::Endpoint

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Shirtsio::Endpoint

Class Method Details

.listArray

Get a list of all available product categories.

Returns:

  • (Array)

    an array of category objects



38
39
40
41
42
43
44
45
# File 'lib/shirtsio/product.rb', line 38

def self.list
  categories = []
  response = Shirtsio.get('/products/category/')
  response.each do |category|
    categories << new(category)
  end
  categories
end

Instance Method Details

#productsArray

Note:

This endpoint does not return complete product objects

Get a list of products in the current category.

Returns:

  • (Array)

    an array of simple product objects

See Also:

  • Shirtsio::Product::Category.{Shirtsio{Shirtsio::Product{Shirtsio::Product::Simple{Shirtsio::Product::Simple#full_product}


26
27
28
29
30
31
32
33
# File 'lib/shirtsio/product.rb', line 26

def products
  products = []
  response = Shirtsio.get("/products/category/#{category_id}/")
  response.each do |product|
    products << Shirtsio::Product::Simple.new(product)
  end
  products
end