Class: Mws::Apis::Feeds::Inventory

Inherits:
Object
  • Object
show all
Defined in:
lib/mws/apis/feeds/inventory.rb

Defined Under Namespace

Classes: Fulfillment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sku, options) ⇒ Inventory

Returns a new instance of Inventory.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mws/apis/feeds/inventory.rb', line 7

def initialize(sku, options)
  @sku = sku
  @available = options[:available]
  @quantity = options[:quantity]
  @lookup = options[:lookup]
  @fulfillment = Fulfillment.new(
    options[:fulfillment_center],
    options[:fulfillment_latency],
    options[:fulfillment_type]
  )
  @restock = options[:restock]
  validate
end

Instance Attribute Details

#availableObject (readonly)

Returns the value of attribute available.



5
6
7
# File 'lib/mws/apis/feeds/inventory.rb', line 5

def available
  @available
end

#fulfillmentObject (readonly)

Returns the value of attribute fulfillment.



5
6
7
# File 'lib/mws/apis/feeds/inventory.rb', line 5

def fulfillment
  @fulfillment
end

#lookupObject (readonly)

Returns the value of attribute lookup.



5
6
7
# File 'lib/mws/apis/feeds/inventory.rb', line 5

def lookup
  @lookup
end

#quantityObject (readonly)

Returns the value of attribute quantity.



5
6
7
# File 'lib/mws/apis/feeds/inventory.rb', line 5

def quantity
  @quantity
end

#restockObject (readonly)

Returns the value of attribute restock.



5
6
7
# File 'lib/mws/apis/feeds/inventory.rb', line 5

def restock
  @restock
end

#skuObject (readonly)

Returns the value of attribute sku.



5
6
7
# File 'lib/mws/apis/feeds/inventory.rb', line 5

def sku
  @sku
end

Instance Method Details

#to_xml(name = 'Inventory', parent = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mws/apis/feeds/inventory.rb', line 21

def to_xml(name='Inventory', parent=nil)
  Mws::Serializer.tree name, parent do |xml| 
    xml.SKU @sku
    xml.FulfillmentCenterID @fulfillment.center unless @fulfillment.center.nil?
    xml.Available @available unless @available.nil?
    xml.Quantity @quantity unless @quantity.nil?
    xml.Lookup @lookup unless @lookup.nil?
    xml.RestockDate @restock.iso8601 unless @restock.nil?
    xml.FulfillmentLatency @fulfillment.latency unless @fulfillment.latency.nil?
    xml.SwitchFulfillmentTo Fulfillment::Type.for(@fulfillment.type).val unless @fulfillment.type.nil?
  end
end