Class: LeadCreate
- Inherits:
-
Object
- Object
- LeadCreate
- Defined in:
- lib/lead_create.rb
Class Method Summary collapse
- .connect ⇒ Object
- .create(contato) ⇒ Object
- .list_leads ⇒ Object
- .load_new_lead(contato) ⇒ Object
- .take_lead ⇒ Object
Class Method Details
.connect ⇒ Object
21 22 23 24 |
# File 'lib/lead_create.rb', line 21 def self.connect @client = Databasedotcom::Client.new('config/databasedotcom.yml') @client.authenticate :username => '[email protected]', :password => 'slayer666DT0tilUUmpLca7X5kWKGCKDf' end |
.create(contato) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/lead_create.rb', line 2 def self.create(contato) connect load_new_lead(contato) if(@lead.all.select { |lead| lead.FirstName == @new_lead.FirstName }.empty?) if @new_lead.save contato.name + ' successfully added' end else 'This contact has already been added' end end |
.list_leads ⇒ Object
14 15 16 17 18 |
# File 'lib/lead_create.rb', line 14 def self.list_leads connect lead = take_lead lead.all end |
.load_new_lead(contato) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lead_create.rb', line 31 def self.load_new_lead(contato) @lead = @client.materialize('Lead') @new_lead = @lead.new user = @client.materialize('User') @new_lead.OwnerId = user.first.Id @new_lead.FirstName = contato.name @new_lead.LastName = contato.last_name @new_lead.Email = contato.email @new_lead.Company = contato.company @new_lead.Title = contato.job_title @new_lead.Phone = contato.phone @new_lead.Website = contato.website @new_lead.IsConverted = false @new_lead.IsUnreadByOwner = true end |
.take_lead ⇒ Object
26 27 28 29 |
# File 'lib/lead_create.rb', line 26 def self.take_lead connect @client.materialize('Lead') end |