Skip to content

Commit

Permalink
Merge pull request #31 from markadrianagbuya/sync_lead_by_marketo_id_fix
Browse files Browse the repository at this point in the history
Fix sync lead by marketo id
  • Loading branch information
davidsantoso committed May 7, 2015
2 parents f88a9e6 + 21b206d commit 052d892
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/markety/command/sync_lead.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def sync_lead(lead, sync_method)
end

private

def create_sync_lead_request_hash(lead, sync_method)
raise "missing sync method" unless sync_method

case sync_method
when SyncMethod::MARKETO_ID
raise "lead has no idnum" unless lead.idnum
Expand All @@ -26,7 +26,7 @@ def create_sync_lead_request_hash(lead, sync_method)
else
raise "unrecognized Markety::SyncMethod '#{sync_method}'"
end

# note from gbirchmeier:
# A Marketo support guy told me the fields must come in a very particular order,
# thus why this flow is a little janky.
Expand All @@ -37,16 +37,16 @@ def create_sync_lead_request_hash(lead, sync_method)
lead_record: { },
return_lead: true,
}

# id fields must come first in lead_record
request_hash[:lead_record][:id]=lead.idnum if sync_method==SyncMethod::MARKETO_ID
request_hash[:lead_record]["Id"]=lead.idnum if sync_method==SyncMethod::MARKETO_ID
use_foreign_id = lead.foreign_sys_person_id && [SyncMethod::MARKETO_ID,SyncMethod::FOREIGN_ID].include?(sync_method)
request_hash[:lead_record][:foreignSysPersonId]=lead.foreign_sys_person_id if use_foreign_id
request_hash[:lead_record]["Email"]=lead.email if lead.email

# now lead attributes (which must be ordered name/type/value) (type is optional, but must precede value if present)
request_hash[:lead_record][:lead_attribute_list] = { attribute: lead.send(:attributes_soap_array) }

request_hash
end

Expand Down

0 comments on commit 052d892

Please sign in to comment.