Class: Mws::Apis::Feeds::ImageListing
- Inherits:
-
Object
- Object
- Mws::Apis::Feeds::ImageListing
- Defined in:
- lib/mws/apis/feeds/image_listing.rb
Constant Summary collapse
- Type =
Mws::Enum.for( main: 'Main', alt1: 'PT1', alt2: 'PT2', alt3: 'PT3', alt4: 'PT4', alt5: 'PT5' )
Instance Attribute Summary collapse
-
#sku ⇒ Object
readonly
Returns the value of attribute sku.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(sku, url, type = nil) ⇒ ImageListing
constructor
A new instance of ImageListing.
- #to_xml(name = 'ProductImage', parent = nil) ⇒ Object
Constructor Details
#initialize(sku, url, type = nil) ⇒ ImageListing
Returns a new instance of ImageListing.
20 21 22 23 24 25 26 |
# File 'lib/mws/apis/feeds/image_listing.rb', line 20 def initialize(sku, url, type=nil) raise Mws::Errors::ValidationError, 'SKU is required.' if sku.nil? or sku.strip.empty? @sku = sku raise Mws::Errors::ValidationError, 'URL must be an unsecured http address.' unless url =~ URI::regexp('http') @url = url @type = Type.for(type) || Type.MAIN end |
Instance Attribute Details
#sku ⇒ Object (readonly)
Returns the value of attribute sku.
16 17 18 |
# File 'lib/mws/apis/feeds/image_listing.rb', line 16 def sku @sku end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
16 17 18 |
# File 'lib/mws/apis/feeds/image_listing.rb', line 16 def url @url end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 32 |
# File 'lib/mws/apis/feeds/image_listing.rb', line 28 def ==(other) return true if equal? other return false unless other.class == self.class sku == other.sku and url == other.url and type == other.type end |
#to_xml(name = 'ProductImage', parent = nil) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/mws/apis/feeds/image_listing.rb', line 34 def to_xml(name='ProductImage', parent=nil) Mws::Serializer.tree name, parent do | xml | xml.SKU @sku xml.ImageType @type.val xml.ImageLocation @url end end |