Class: Economic::OrderLineProxy

Inherits:
EntityProxy show all
Includes:
FindByHandleWithNumber
Defined in:
lib/economic/proxies/order_line_proxy.rb

Instance Attribute Summary

Attributes inherited from EntityProxy

#owner

Instance Method Summary collapse

Methods inherited from EntityProxy

#all, #append, #build, entity_class, #entity_class, entity_class_name, #entity_class_name, #get_data, #initialize, #session

Constructor Details

This class inherits a constructor from Economic::EntityProxy

Instance Method Details

#find(handle) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/economic/proxies/order_line_proxy.rb', line 25

def find(handle)
  if handle.is_a?(Hash)
    super handle
  else
    super({:id => handle})
  end
end

#find_by_order(handle) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/economic/proxies/order_line_proxy.rb', line 10

def find_by_order(handle)
  response = request(:find_by_order_list, "orderHandles" => {"OrderHandle" => handle})

  handle_key = "#{Support::String.underscore(entity_class_name)}_handle".intern
  handles = [response[handle_key]].flatten.reject(&:blank?).collect do |handle|
    Entity::Handle.build(handle)
  end

  get_data_array(handles).collect do |entity_hash|
    entity = build(entity_hash)
    entity.persisted = true
    entity
  end
end