Class: Zanox::Product
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#delivery_time ⇒ Object
readonly
Returns the value of attribute delivery_time.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#excerpt ⇒ Object
readonly
Returns the value of attribute excerpt.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#manufacturer ⇒ Object
readonly
Returns the value of attribute manufacturer.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pagination ⇒ Object
Returns the value of attribute pagination.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#program ⇒ Object
readonly
Returns the value of attribute program.
-
#shipping_costs ⇒ Object
readonly
Returns the value of attribute shipping_costs.
-
#tracking_link ⇒ Object
readonly
Returns the value of attribute tracking_link.
Class Method Summary collapse
- .find(keyword, args = {}) ⇒ Object
- .from_id(product_id, args = {}) ⇒ Object
- .from_shop(shop_id, args = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(data) ⇒ Product
constructor
-
pid (String) Product ID - name (String) The name of the product - program (Hash) Hash containing the id and the name of the shop which sells this product (e.g. EuronicsIT) - description (HTML) The description of the product - excerpt (String) A short description of the product - manufacturer (String) The manufacturer of the product (e.g. Apple) - images (String[]) A collection of images representing the product in different sizes - currency (String) The currency used to calculate the price - price (Float) The price of the product calculated with the relative currency - shipping_costs (Float) The price of the shipping - delivery_time (Integer) The number of the days required by the shop to deliver the product - tracking_link (String ) The link that redirects to the advertiser’s shop.
-
Methods included from Hashable
Constructor Details
#initialize(data) ⇒ Product
-
pid (String) Product ID
-
name (String) The name of the product
-
program (Hash) Hash containing the id and the name of the shop which sells this product (e.g. EuronicsIT)
-
description (HTML) The description of the product
-
excerpt (String) A short description of the product
-
manufacturer (String) The manufacturer of the product (e.g. Apple)
-
images (String[]) A collection of images representing the product in different sizes
-
currency (String) The currency used to calculate the price
-
price (Float) The price of the product calculated with the relative currency
-
shipping_costs (Float) The price of the shipping
-
delivery_time (Integer) The number of the days required by the shop to deliver the product
-
tracking_link (String ) The link that redirects to the advertiser’s shop
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/zanox/resources/product.rb', line 45 def initialize(data) @pid = data['@id'] @name = data['name'] @program = { id: data['program']['@id'].to_i, name: data['program']['$'] } @description = strip_cdata(data['descriptionLong']) @excerpt = data['description'] @manufacturer = data['manufacturer'] @category = data['merchantCategory'] @images = { small: data['image'].try { |i| i['small'] }, medium: data['image'].try { |i| i['medium'] }, large: data['image'].try { |i| i['large'] }, } @currency = data['currency'] @price = data['price'].to_f @shipping_costs = data['shippingCosts'].try(:to_f) @delivery_time = only_numbers(data['deliveryTime']) @tracking_link = data['trackingLinks'].try { |d| d['trackingLink'] }.try { |d| d[0] }.try { |d| d['ppc'] } end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def category @category end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def currency @currency end |
#delivery_time ⇒ Object (readonly)
Returns the value of attribute delivery_time.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def delivery_time @delivery_time end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def description @description end |
#excerpt ⇒ Object (readonly)
Returns the value of attribute excerpt.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def excerpt @excerpt end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def images @images end |
#manufacturer ⇒ Object (readonly)
Returns the value of attribute manufacturer.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def manufacturer @manufacturer end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def name @name end |
#pagination ⇒ Object
Returns the value of attribute pagination.
29 30 31 |
# File 'lib/zanox/resources/product.rb', line 29 def pagination @pagination end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def pid @pid end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def price @price end |
#program ⇒ Object (readonly)
Returns the value of attribute program.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def program @program end |
#shipping_costs ⇒ Object (readonly)
Returns the value of attribute shipping_costs.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def shipping_costs @shipping_costs end |
#tracking_link ⇒ Object (readonly)
Returns the value of attribute tracking_link.
27 28 29 |
# File 'lib/zanox/resources/product.rb', line 27 def tracking_link @tracking_link end |
Class Method Details
.find(keyword, args = {}) ⇒ Object
69 70 71 72 73 |
# File 'lib/zanox/resources/product.rb', line 69 def find(keyword, args = {}) args.merge!({ q: keyword }) response = API.request(:products, args) from_product_items(response) end |