Skip to content

Commit

Permalink
handles duplicate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ij committed Sep 22, 2015
1 parent 331a124 commit e193762
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/sf/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Sf::Contact
'Title', 'Email', 'HasOptedOutOfEmail', 'Phone', 'MailingStreet',
'MailingCity', 'MailingState', 'MailingPostalCode', 'MailingCountry',
'Status__c', 'Functional_Title__c', 'Informal_Name__c',
'Meeting_Reg_Pre_Population_Opt_Out__c', 'Meeting_Reg_Hold__c',
'Meeting_Reg_Pre_Population_Opt_Out__c', 'Meeting_Reg_Hold__c',
'gs_executive__c', 'techex_executive__c', 'gender__c', 'Contact_ID__c']
FIELDS_SELECT_STR = FIELDS.join(', ')

Expand Down Expand Up @@ -63,11 +63,21 @@ def attrs_from_person
end

def create_from_person!
Sf.client.create("Contact", self.attrs_from_person)
begin
Sf.client.create!("Contact", self.attrs_from_person)
rescue Exception => e
self.person.errors[:base] << e.to_s
nil
end
end

def update_from_person!
update(self.attrs_from_person) if self.Id.present?
begin
update!(self.attrs_from_person) if self.Id.present?
rescue Exception => e
self.person.errors[:base] << e.to_s
nil
end
end

def sf_person_mapping
Expand Down
2 changes: 1 addition & 1 deletion lib/sf/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Sf
VERSION = "0.1.28"
VERSION = "0.1.29"
end

0 comments on commit e193762

Please sign in to comment.