Class: MarketoAPI::Leads
- Inherits:
-
ClientProxy
- Object
- ClientProxy
- MarketoAPI::Leads
- Defined in:
- lib/marketo_api/leads.rb
Overview
Implements Lead operations for Marketo.
Instance Method Summary collapse
-
#activity(lead_key, options = {}) ⇒ Object
:nodoc:.
-
#changes(start_position, options = {}) ⇒ Object
:nodoc:.
-
#get(type_or_key, value = nil) ⇒ Object
Implements href="http://developers.marketo.com/documentation/soap/getlead/">, returning a MarketoAPI::Lead object.
-
#get_multiple(selector) ⇒ Object
:nodoc:.
-
#merge(winning_key, losing_keys) ⇒ Object
:nodoc:.
-
#name ⇒ Object
:method: get_by_salesforce_opportunity_id :call-seq: get_by_salesforce_opportunity_id(salesforce_opportunity_id).
-
#sync(lead_record) ⇒ Object
Implements href="http://developers.marketo.com/documentation/soap/synclead/">, returning a MarketoAPI::Lead object.
-
#sync_multiple(leads, options = { dedup_enabled: true }) ⇒ Object
Implements href="http://developers.marketo.com/documentation/soap/syncmultipleleads/">, returning an array of MarketoAPI::Lead objects.
Methods inherited from ClientProxy
Constructor Details
This class inherits a constructor from MarketoAPI::ClientProxy
Instance Method Details
#activity(lead_key, options = {}) ⇒ Object
:nodoc:
83 84 85 |
# File 'lib/marketo_api/leads.rb', line 83 def activity(lead_key, = {}) #:nodoc: raise NotImplementedError end |
#changes(start_position, options = {}) ⇒ Object
:nodoc:
87 88 89 |
# File 'lib/marketo_api/leads.rb', line 87 def changes(start_position, = {}) #:nodoc: raise NotImplementedError end |
#get(type_or_key, value = nil) ⇒ Object
Implements href="http://developers.marketo.com/documentation/soap/getlead/">, returning a MarketoAPI::Lead object.
:call-seq:
get(lead_key)
get(key_type, key_value)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/marketo_api/leads.rb', line 13 def get(type_or_key, value = nil) key = case type_or_key when Hash if lk = type_or_key[:leadKey] if MarketoAPI::Lead.send(:key_type, lk[:keyType]) type_or_key end end when MarketoAPI::Lead transform_param(__method__, type_or_key) else MarketoAPI::Lead.key(type_or_key, value) end unless key raise ArgumentError, "#{type_or_key} is not a valid lead key" end extract_from_response(call(:get_lead, key), :lead_record_list) { |record| MarketoAPI::Lead.from_soap_hash(record[:lead_record]) do |lead| lead.proxy = self end } end |
#get_multiple(selector) ⇒ Object
:nodoc:
50 51 52 |
# File 'lib/marketo_api/leads.rb', line 50 def get_multiple(selector) #:nodoc: raise NotImplementedError end |
#merge(winning_key, losing_keys) ⇒ Object
:nodoc:
79 80 81 |
# File 'lib/marketo_api/leads.rb', line 79 def merge(winning_key, losing_keys) #:nodoc: raise NotImplementedError end |
#name ⇒ Object
:method: get_by_salesforce_opportunity_id :call-seq: get_by_salesforce_opportunity_id(salesforce_opportunity_id)
Gets the Lead by the provided SFDC Opportunity ID.
145 146 147 148 149 |
# File 'lib/marketo_api/leads.rb', line 145 MarketoAPI::Lead::NAMED_KEYS.each_pair { |name, key| define_method(:"get_by_#{name}") do |value| get(key, value) end } |
#sync(lead_record) ⇒ Object
Implements href="http://developers.marketo.com/documentation/soap/synclead/">, returning a MarketoAPI::Lead object.
40 41 42 43 44 45 46 47 48 |
# File 'lib/marketo_api/leads.rb', line 40 def sync(lead_record) extract_from_response( call(:sync_lead, transform_param(__method__, lead_record)), ) { |record| MarketoAPI::Lead.from_soap_hash(record[:lead_record]) do |lead| lead.proxy = self end } end |
#sync_multiple(leads, options = { dedup_enabled: true }) ⇒ Object
Implements href="http://developers.marketo.com/documentation/soap/syncmultipleleads/">, returning an array of MarketoAPI::Lead objects.
May optionally disable de-duplication by passing dedup_enabled: false
.
:call-seq:
sync_multiple(leads)
sync_multiple(leads, dedup_enabled: false)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/marketo_api/leads.rb', line 64 def sync_multiple(leads, = { dedup_enabled: true }) response = call( :sync_multiple_leads, dedupEnabled: [:dedup_enabled], leadRecordList: transform_param_list(:sync, leads) ) extract_from_response(response, :lead_record_list) do |list| list.each do |record| MarketoAPI::Lead.from_soap_hash(record[:lead_record]) do |lead| lead.proxy = self end end end end |