Class: Amorail::Lead

Inherits:
Entity show all
Defined in:
lib/amorail/entities/lead.rb

Overview

AmoCRM lead entity

Instance Method Summary collapse

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

#contactsObject

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

#reloadObject



12
13
14
15
# File 'lib/amorail/entities/lead.rb', line 12

def reload
  @contacts = nil
  super
end