Class: Amorail::Lead
Overview
AmoCRM lead entity
Instance Method Summary collapse
-
#contacts ⇒ Object
Return list of associated contacts.
- #reload ⇒ Object
Methods inherited from Entity
amo_field, amo_names, amo_property, attributes, find, find!, find_all, find_by_query, inherited, #initialize, #load_record, #new_record?, #params, #persisted?, properties, #reload_model, remote_url, #save, #save!, #update, #update!, where
Constructor Details
This class inherits a constructor from Amorail::Entity
Instance Method Details
#contacts ⇒ Object
Return list of associated contacts
18 19 20 21 22 23 24 25 26 |
# File 'lib/amorail/entities/lead.rb', line 18 def contacts fail NotPersisted if id.nil? @contacts ||= begin links = Amorail::ContactLink.find_by_leads(id) links.empty? ? [] : Amorail::Contact.find_all(links.map(&:contact_id)) end end |
#reload ⇒ Object
12 13 14 15 |
# File 'lib/amorail/entities/lead.rb', line 12 def reload @contacts = nil super end |