class MarketoAPI::Leads

Implements Lead operations for Marketo.

Public Instance Methods

get(lead_key) → Lead click to toggle source
get(key_type, key_value) → Lead

Implements {getLead}, returning a MarketoAPI::Lead object.

# File lib/marketo_api/leads.rb, line 24
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_by_email(email) → Lead click to toggle source

Gets the Lead by the provided lead email.

# File lib/marketo_api/leads.rb, line 119
  
get_by_id(marketo_id) click to toggle source

Gets the Lead by the provided Marketo ID.

# File lib/marketo_api/leads.rb, line 106
  
get_by_lead_owner_email(lead_owner_email) → Lead click to toggle source

Gets the Lead by the provided Lead Owner email.

# File lib/marketo_api/leads.rb, line 126
  
get_by_salesforce_account_id(salesforce_account_id) → Lead click to toggle source

Gets the Lead by the provided SFDC Account ID.

# File lib/marketo_api/leads.rb, line 133
  
get_by_salesforce_contact_id(salesforce_contact_id) → Lead click to toggle source

Gets the Lead by the provided SFDC Contact ID.

# File lib/marketo_api/leads.rb, line 140
  
get_by_salesforce_lead_id(salesforce_lead_id) → Lead click to toggle source

Gets the Lead by the provided SFDC Lead ID.

# File lib/marketo_api/leads.rb, line 147
  
get_by_salesforce_lead_owner_id(salesforce_lead_owner_id) → Lead click to toggle source

Gets the Lead by the provided SFDC Lead Owner ID.

# File lib/marketo_api/leads.rb, line 154
  
get_by_salesforce_opportunity_id(salesforce_opportunity_id) click to toggle source

Gets the Lead by the provided SFDC Opportunity ID.

# File lib/marketo_api/leads.rb, line 161
  
new → Lead click to toggle source
new { |lead| ... } → Lead
new(options) → Lead
new(options) { |lead| ... } → Lead

Creates a new lead with a proxy to this Leads instance.

# File lib/marketo_api/leads.rb, line 13
def new(options = {}, &block)
  MarketoAPI::Lead.new(options.merge(proxy: self), &block)
end
sync(Lead) → Lead click to toggle source

Implements {syncLead}, returning a MarketoAPI::Lead object.

# File lib/marketo_api/leads.rb, line 54
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) → array of Lead click to toggle source
sync_multiple(leads, dedup_enabled: false) → array of Lead

Implements {syncMultipleLeads}, returning an array of MarketoAPI::Lead objects.

May optionally disable de-duplication by passing dedup_enabled: false.

# File lib/marketo_api/leads.rb, line 78
def sync_multiple(leads, options = { dedup_enabled: true })
  response = call(
    :sync_multiple_leads,
    dedupEnabled:   options[: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