lead_create 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lead_create.rb +17 -13
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08f17718741df5f1cf628b74d96e4296d5c4a908
4
- data.tar.gz: 6c0d3c754aec5a1e086c82a52c58a1eaaa443b1d
3
+ metadata.gz: d6dbcccb2ee4afc2fbad517682d4ba174e067824
4
+ data.tar.gz: e82578a7642d38d162efb45f752b51fc553f53fd
5
5
  SHA512:
6
- metadata.gz: 6b65585ab233e4e711afc84a401ee492b8c16d49018b2598f31ffcb3868506c035f4b2ea04f1fad63f803496afd6c0a753192e61110a60c2c57b2e38ed755c83
7
- data.tar.gz: b3fbe8f6472003a1fcfe7123f7c0262d40b8b07296aee1482c9739d26d6c38c1e2e76fb2c5b717e42ef7a558ada0ff275e38123dbbeff5a3ee1c0d9fa3aef6cd
6
+ metadata.gz: 882cabd5799c721bbd722240b6bc5fb5e9cada9bedc17b42be9509824e45041c6d9d0d221c74955249437ab59e510529cc92bbbc5ad1090e82fe82e42419ffaa
7
+ data.tar.gz: b8a0d07cb05080fb1bfdb790c620d9bc9dcba3b7e3c62ad79c5ea3c29b30297a1e8ec4619381a9b239fe4bb4a06344290144e207557eafd6695ce281060f0f93
data/lib/lead_create.rb CHANGED
@@ -2,8 +2,12 @@ class LeadCreate
2
2
  def self.create(contato)
3
3
  connect
4
4
  load_new_lead(contato)
5
- if @lead.save
6
- contato.name + ' successfully added'
5
+ if(@lead.all.select { |lead| lead.FirstName == @new_lead.FirstName }.empty?)
6
+ if @lead.save
7
+ contato.name + ' successfully added'
8
+ end
9
+ else
10
+ 'This contact has already been added'
7
11
  end
8
12
  end
9
13
 
@@ -26,17 +30,17 @@ class LeadCreate
26
30
 
27
31
  def self.load_new_lead(contato)
28
32
  @lead = @client.materialize('Lead')
29
- @lead = @lead.new
33
+ @new_lead = @lead.new
30
34
  user = @client.materialize('User')
31
- @lead.OwnerId = user.first.Id
32
- @lead.FirstName = contato.name
33
- @lead.LastName = contato.last_name
34
- @lead.Email = contato.email
35
- @lead.Company = contato.company
36
- @lead.Title = contato.job_title
37
- @lead.Phone = contato.phone
38
- @lead.Website = contato.website
39
- @lead.IsConverted = false
40
- @lead.IsUnreadByOwner = true
35
+ @new_lead.OwnerId = user.first.Id
36
+ @new_lead.FirstName = contato.name
37
+ @new_lead.LastName = contato.last_name
38
+ @new_lead.Email = contato.email
39
+ @new_lead.Company = contato.company
40
+ @new_lead.Title = contato.job_title
41
+ @new_lead.Phone = contato.phone
42
+ @new_lead.Website = contato.website
43
+ @new_lead.IsConverted = false
44
+ @new_lead.IsUnreadByOwner = true
41
45
  end
42
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lead_create
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Lucena