Class: Economic::DebtorContactProxy

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

Instance Attribute Summary

Attributes inherited from EntityProxy

#items, #owner

Instance Method Summary (collapse)

Methods inherited from EntityProxy

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

Constructor Details

This class inherits a constructor from Economic::EntityProxy

Instance Method Details

- (Object) build(properties = {})

Returns a new, unpersisted Economic::DebtorContact



7
8
9
10
11
# File 'lib/economic/proxies/debtor_contact_proxy.rb', line 7

def build(properties = {})
  contact = super
  initialize_properties_with_values_from_owner(contact) if owner.is_a?(Debtor)
  contact
end

- (Object) find(id)

Gets data for DebtorContact from the API



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/economic/proxies/debtor_contact_proxy.rb', line 14

def find(id)
  # This is basically EntityProxy::find duplicated so we can pass id to the API instead of
  # Number...
  entity_hash = session.request entity_class.soap_action(:get_data)  do
    soap.body = {
      'entityHandle' => {
        'Id' => id
      }
    }
  end
  entity = build(entity_hash)
  entity.persisted = true
  entity
end