Class: Mws::Apis::Feeds::Shipping

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

Defined Under Namespace

Classes: Builder, Option, Override, Restriction

Constant Summary collapse

Region =
Mws::Enum.for(
  continental_us: 'Cont US',
  us_protectorates: 'US Prot',
  alaska_hawaii: 'Alaska Hawaii',
  apo_fpo: 'APO/FPO',
  canada: 'Canada',
  europe: 'Europe',
  asia: 'Asia',
  other: 'Outside US, EU, CA, Asia'
)
Variant =
Mws::Enum.for(
  street: 'Street Addr', 
  po_box: 'PO Box'
)
Speed =
Mws::Enum.for(
  standard: 'Std',
  expedited: 'Exp',
  two_day: 'Second',
  one_day: 'Next'
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sku, &block) ⇒ Shipping

Returns a new instance of Shipping.



32
33
34
35
36
37
# File 'lib/mws/apis/feeds/shipping.rb', line 32

def initialize(sku, &block)
  raise Mws::Errors::ValidationError.new('SKU is required.') if sku.nil? or sku.to_s.strip.empty?
  @sku = sku
  @options = []
  Builder.new(self).instance_eval &block if block_given?
end

Instance Attribute Details

#skuObject (readonly)

Returns the value of attribute sku.



30
31
32
# File 'lib/mws/apis/feeds/shipping.rb', line 30

def sku
  @sku
end

Instance Method Details

#<<(option) ⇒ Object



43
44
45
# File 'lib/mws/apis/feeds/shipping.rb', line 43

def <<(option)
  @options << option
end

#optionsObject



39
40
41
# File 'lib/mws/apis/feeds/shipping.rb', line 39

def options
  @options.dup
end

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



47
48
49
50
51
52
# File 'lib/mws/apis/feeds/shipping.rb', line 47

def to_xml(name='Override', parent=nil)
  Mws::Serializer.tree name, parent do |xml|
    xml.SKU @sku
    @options.each { |option| option.to_xml 'ShippingOverride', xml }
  end
end