Class: Economic::OrderProxy
- Inherits:
-
EntityProxy
- Object
- EntityProxy
- Economic::OrderProxy
- Includes:
- FindByDateInterval, FindByHandleWithNumber
- Defined in:
- lib/economic/proxies/order_proxy.rb
Instance Attribute Summary
Attributes inherited from EntityProxy
Instance Method Summary collapse
-
#current ⇒ Object
Fetches all current orders from the API.
- #find(handle) ⇒ Object
- #find_by_other_reference(reference) ⇒ Object
Methods included from FindByDateInterval
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
#current ⇒ Object
Fetches all current orders from the API.
13 14 15 16 17 18 19 20 |
# File 'lib/economic/proxies/order_proxy.rb', line 13 def current response = request(:get_all_current) handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) } initialize_items get_data_for_handles(handles) self end |
#find(handle) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/economic/proxies/order_proxy.rb', line 37 def find(handle) if handle.is_a?(Hash) super handle else super({:id => handle}) end end |
#find_by_other_reference(reference) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/economic/proxies/order_proxy.rb', line 22 def find_by_other_reference(reference) response = request(:find_by_other_reference, "otherReference" => reference) 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 |