Class: Mws::Apis::Feeds::Product
- Inherits:
-
Object
- Object
- Mws::Apis::Feeds::Product
- Defined in:
- lib/mws/apis/feeds/product.rb
Defined Under Namespace
Classes: DelegatingBuilder, DetailBuilder, Dimensions, DimensionsBuilder, ProductBuilder
Constant Summary collapse
- CategorySerializer =
Mws::Serializer.new ce: 'CE', fba: 'FBA', eu_compliance: 'EUCompliance'
Instance Attribute Summary collapse
-
#brand ⇒ Object
Returns the value of attribute brand.
-
#bullet_points ⇒ Object
Returns the value of attribute bullet_points.
-
#category ⇒ Object
Returns the value of attribute category.
-
#description ⇒ Object
Returns the value of attribute description.
-
#details ⇒ Object
Returns the value of attribute details.
-
#item_dimensions ⇒ Object
Returns the value of attribute item_dimensions.
-
#manufacturer ⇒ Object
Returns the value of attribute manufacturer.
-
#msrp ⇒ Object
Returns the value of attribute msrp.
-
#name ⇒ Object
Returns the value of attribute name.
-
#package_dimensions ⇒ Object
Returns the value of attribute package_dimensions.
-
#package_weight ⇒ Object
Returns the value of attribute package_weight.
-
#shipping_weight ⇒ Object
Returns the value of attribute shipping_weight.
-
#sku ⇒ Object
readonly
Returns the value of attribute sku.
-
#tax_code ⇒ Object
Returns the value of attribute tax_code.
-
#upc ⇒ Object
Returns the value of attribute upc.
Instance Method Summary collapse
-
#initialize(sku, &block) ⇒ Product
constructor
A new instance of Product.
- #to_xml(name = 'Product', parent = nil) ⇒ Object
Constructor Details
#initialize(sku, &block) ⇒ Product
Returns a new instance of Product.
13 14 15 16 17 18 |
# File 'lib/mws/apis/feeds/product.rb', line 13 def initialize(sku, &block) @sku = sku @bullet_points = [] ProductBuilder.new(self).instance_eval &block if block_given? raise Mws::Errors::ValidationError, 'Product must have a category when details are specified.' if @details and @category.nil? end |
Instance Attribute Details
#brand ⇒ Object
Returns the value of attribute brand.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def brand @brand end |
#bullet_points ⇒ Object
Returns the value of attribute bullet_points.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def bullet_points @bullet_points end |
#category ⇒ Object
Returns the value of attribute category.
11 12 13 |
# File 'lib/mws/apis/feeds/product.rb', line 11 def category @category end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/mws/apis/feeds/product.rb', line 7 def description @description end |
#details ⇒ Object
Returns the value of attribute details.
11 12 13 |
# File 'lib/mws/apis/feeds/product.rb', line 11 def details @details end |
#item_dimensions ⇒ Object
Returns the value of attribute item_dimensions.
10 11 12 |
# File 'lib/mws/apis/feeds/product.rb', line 10 def item_dimensions @item_dimensions end |
#manufacturer ⇒ Object
Returns the value of attribute manufacturer.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def manufacturer @manufacturer end |
#msrp ⇒ Object
Returns the value of attribute msrp.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def msrp @msrp end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def name @name end |
#package_dimensions ⇒ Object
Returns the value of attribute package_dimensions.
10 11 12 |
# File 'lib/mws/apis/feeds/product.rb', line 10 def package_dimensions @package_dimensions end |
#package_weight ⇒ Object
Returns the value of attribute package_weight.
10 11 12 |
# File 'lib/mws/apis/feeds/product.rb', line 10 def package_weight @package_weight end |
#shipping_weight ⇒ Object
Returns the value of attribute shipping_weight.
10 11 12 |
# File 'lib/mws/apis/feeds/product.rb', line 10 def shipping_weight @shipping_weight end |
#sku ⇒ Object (readonly)
Returns the value of attribute sku.
7 8 9 |
# File 'lib/mws/apis/feeds/product.rb', line 7 def sku @sku end |
#tax_code ⇒ Object
Returns the value of attribute tax_code.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def tax_code @tax_code end |
#upc ⇒ Object
Returns the value of attribute upc.
9 10 11 |
# File 'lib/mws/apis/feeds/product.rb', line 9 def upc @upc end |
Instance Method Details
#to_xml(name = 'Product', parent = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mws/apis/feeds/product.rb', line 20 def to_xml(name='Product', parent=nil) Mws::Serializer.tree name, parent do |xml| xml.SKU @sku xml.StandardProductID { xml.Type 'UPC' xml.Value @upc } unless @upc.nil? xml.ProductTaxCode @tax_code unless @upc.nil? xml.DescriptionData { xml.Title @name unless @name.nil? xml.Brand @brand unless @brand.nil? xml.Description @description unless @description.nil? bullet_points.each do | bullet_point | xml.BulletPoint bullet_point end @item_dimensions.to_xml('ItemDimensions', xml) unless @item_dimensions.nil? @package_dimensions.to_xml('PackageDimensions', xml) unless @item_dimensions.nil? @package_weight.to_xml('PackageWeight', xml) unless @package_weight.nil? @shipping_weight.to_xml('ShippingWeight', xml) unless @shipping_weight.nil? @msrp.to_xml 'MSRP', xml unless @msrp.nil? xml.Manufacturer @manufacturer unless @manufacturer.nil? } unless @details.nil? xml.ProductData { CategorySerializer.xml_for @category, {product_type: @details}, xml } end end end |