Permalink
Browse files

fix delete, add update, move find to public method

  • Loading branch information...
1 parent ac5a3da commit 024c24e05fa2b17aeffe1926d4eb8c12ff57ddf2 @nolastan nolastan committed Sep 18, 2012
Showing with 19 additions and 7 deletions.
  1. +19 −7 lib/zohoho/crm.rb
View
@@ -43,10 +43,21 @@ def add_lead(company, last_name, info = {})
def remove_lead(email)
leads = find_leads_by_email(email)
if leads.count > 0
- leads.first['LEADID']
id = leads.first['LEADID']
xmlData = parse_data({'id' => id}, 'Leads')
- @conn.call('Leads', "deleteRecords", {:xmlData => xmlData, :newFormat => 1}, :get)
+ @conn.call('Leads', "deleteRecords?id=#{id}", {:xmlData => xmlData, :newFormat => 1}, :post)
+ else
+ false
+ end
+ end
+
+ def update_lead(email, info = {})
+ leads = find_leads_by_email(email)
+ if leads.count > 0
+ id = leads.first['LEADID']
+ info.merge!({'id' => id})
+ xmlData = parse_data(info, 'Leads')
+ record = @conn.call('Leads', "deleteRecords?id=#{id}", {:xmlData => xmlData, :newFormat => 1}, :post)
else
false
end
@@ -81,7 +92,12 @@ def tasks_by_due_date(due_date)
def call(*params)
@conn.call(*params)
end
-
+
+ def find_leads_by_email(email)
+ search_condition = "(email|=|#{email})"
+ @conn.call('Leads', 'getSearchRecords', :searchCondition => "(Email|=|#{email})", :selectColumns => 'All')
+ end
+
private
def parse_name(name)
@@ -106,9 +122,5 @@ def find_contacts_by_last_name(last_name)
@conn.call('Contacts', 'getSearchRecords', :searchCondition => search_condition, :selectColumns => 'All')
end
- def find_leads_by_email(email)
- search_condition = "(email|=|#{email})"
- @conn.call('Leads', 'getSearchRecords', :searchCondition => "(Email|=|#{email})", :selectColumns => 'All')
- end
end
end

0 comments on commit 024c24e

Please sign in to comment.