Class: RubyOmx::ItemPriceUpdateRequest

Inherits:
Request show all
Defined in:
lib/ruby_omx/request/item_price_update_request.rb

Instance Attribute Summary collapse

Attributes inherited from Request

#raw_xml

Instance Method Summary collapse

Methods inherited from Response

format, parse_xml

Methods inherited from Node

#accessors, #as_hash

Constructor Details

#initialize(attrs = {}) ⇒ ItemPriceUpdateRequest

Returns a new instance of ItemPriceUpdateRequest.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_omx/request/item_price_update_request.rb', line 13

def initialize(attrs={})
  return super unless attrs.any?
  required_fields = [:item_code] #:item_code, :product_status, :product_name, :product_group, :tax_code, :file_sub_code, :inventory_product_flag, :launch_date
raise MissingRequestOptions if required_fields.any? { |option| attrs[option].nil? }  		
  super
  self.version = attrs[:version] ||= '1.00'
  self.type = attrs[:keycode] ? 'Keycode' : 'DefaultPrice' # There are only 2 options, and if keycode is provided, it must be of type keycode, otherwise default
  self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'ItemCode', :value=>attrs[:item_code]})
  self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'Type', :value=>self.type})
  self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'Keycode', :value=>attrs[:keycode]}) if attrs[:keycode]
  self.price_points = attrs[:price_points].collect { |h| PricePoint.new(h) }
end

Instance Attribute Details

#item_codeObject

Returns the value of attribute item_code.



26
27
28
# File 'lib/ruby_omx/request/item_price_update_request.rb', line 26

def item_code
  @item_code
end

#keycodeObject

Returns the value of attribute keycode.



26
27
28
# File 'lib/ruby_omx/request/item_price_update_request.rb', line 26

def keycode
  @keycode
end

#typeObject

Returns the value of attribute type.



26
27
28
# File 'lib/ruby_omx/request/item_price_update_request.rb', line 26

def type
  @type
end