Class: Economic::DebtorProxy

Inherits:
EntityProxy show all
Defined in:
lib/economic/proxies/debtor_proxy.rb

Instance Attribute Summary

Attributes inherited from EntityProxy

#items, #owner

Instance Method Summary collapse

Methods inherited from EntityProxy

#<<, #build, #each, #empty?, #entity_class, entity_class, #find, #get_data, #initialize, #session

Constructor Details

This class inherits a constructor from Economic::EntityProxy

Instance Method Details

#find_by_ci_number(ci_number) ⇒ Object

Returns Debtors that have the given ci_number. The Debtor objects will only be partially loaded



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/economic/proxies/debtor_proxy.rb', line 6

def find_by_ci_number(ci_number)
  # Get a list of DebtorHandles from e-conomic
  response = session.request entity_class.soap_action('FindByCINumber') do
    soap.body = {
      'ciNumber' => ci_number
    }
  end

  # Make sure we always have an array of handles even if the result only contains one
  handles = [response[:debtor_handle]].flatten.reject(&:blank?)

  # Create partial Debtor entities
  handles.collect do |handle|
    debtor = build
    debtor.partial = true
    debtor.persisted = true
    debtor.handle = handle
    debtor.number = handle[:number]
    debtor
  end
end

#next_available_numberObject

Returns the next available debtor number



29
30
31
# File 'lib/economic/proxies/debtor_proxy.rb', line 29

def next_available_number
  session.request Debtor.soap_action(:get_next_available_number)
end