Class: Svpply::Product
- Inherits:
-
Object
- Object
- Svpply::Product
- Defined in:
- lib/svpply/product.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#currency_code ⇒ Object
readonly
Returns the value of attribute currency_code.
-
#date_created ⇒ Object
readonly
Returns the value of attribute date_created.
-
#date_updated ⇒ Object
readonly
Returns the value of attribute date_updated.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#discount_code ⇒ Object
readonly
Returns the value of attribute discount_code.
-
#formatted_price ⇒ Object
readonly
Returns the value of attribute formatted_price.
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#image_height ⇒ Object
readonly
Returns the value of attribute image_height.
-
#image_width ⇒ Object
readonly
Returns the value of attribute image_width.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#saves ⇒ Object
readonly
Returns the value of attribute saves.
-
#status_id ⇒ Object
readonly
Returns the value of attribute status_id.
-
#svpply_url ⇒ Object
readonly
Returns the value of attribute svpply_url.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
- .find(id) ⇒ Object
- .product_image_permalink(id, type = 'medium') ⇒ Object
- .products(attrs = nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(hash) ⇒ Product
constructor
A new instance of Product.
Constructor Details
#initialize(hash) ⇒ Product
Returns a new instance of Product.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/svpply/product.rb', line 24 def initialize(hash) @id = hash["id"] @title = hash["page_title"] @price = hash["price"] @formatted_price = hash["formatted_price"] @currency_code = hash["currency_code"] @discount = hash["discount"] @discount_code = hash["discount_code"] @category = hash["category"] @categories = hash["categories"] @gender = hash["gender"] @image = hash["image"] @image_width = hash["image_width"] @image_height = hash["image_height"] @saves = hash["saves"] @notes = hash["notes"] @status_id = hash["status_id"] @url = hash["page_url"] @date_created = hash["date_created"] @date_updated = hash["date_updated"] @svpply_url = "https://svpply.com/item/#{@id}" end |
Instance Attribute Details
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def categories @categories end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def category @category end |
#currency_code ⇒ Object (readonly)
Returns the value of attribute currency_code.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def currency_code @currency_code end |
#date_created ⇒ Object (readonly)
Returns the value of attribute date_created.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def date_created @date_created end |
#date_updated ⇒ Object (readonly)
Returns the value of attribute date_updated.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def date_updated @date_updated end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def discount @discount end |
#discount_code ⇒ Object (readonly)
Returns the value of attribute discount_code.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def discount_code @discount_code end |
#formatted_price ⇒ Object (readonly)
Returns the value of attribute formatted_price.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def formatted_price @formatted_price end |
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def gender @gender end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def id @id end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def image @image end |
#image_height ⇒ Object (readonly)
Returns the value of attribute image_height.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def image_height @image_height end |
#image_width ⇒ Object (readonly)
Returns the value of attribute image_width.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def image_width @image_width end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def notes @notes end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def price @price end |
#saves ⇒ Object (readonly)
Returns the value of attribute saves.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def saves @saves end |
#status_id ⇒ Object (readonly)
Returns the value of attribute status_id.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def status_id @status_id end |
#svpply_url ⇒ Object (readonly)
Returns the value of attribute svpply_url.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def svpply_url @svpply_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/svpply/product.rb', line 3 def url @url end |
Class Method Details
.find(id) ⇒ Object
16 17 18 |
# File 'lib/svpply/product.rb', line 16 def self.find(id) new(Client.get_response("/products/#{id}.json")["product"]) end |
.product_image_permalink(id, type = 'medium') ⇒ Object
20 21 22 |
# File 'lib/svpply/product.rb', line 20 def self.product_image_permalink(id, type='medium') "https://api.svpply.com/v1/products/#{id}/image?type=#{type}" end |
.products(attrs = nil) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/svpply/product.rb', line 8 def self.products(attrs=nil) unless attrs.empty? ProductCollection.new(Client.get_response('/products/search.json', attrs)).products else ProductCollection.new(Client.get_response('/shop.json')).products end end |