Class: MarketoChef::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/marketo_chef/client.rb

Overview

Faraday wrapper to handle communication with Marketo API

Instance Method Summary collapse

Instance Method Details

#sync_lead(lead) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/marketo_chef/client.rb', line 31

def sync_lead(lead)
  authenticate!

  connection.post do |req|
    req.url '/rest/v1/leads.json'
    req.headers[:authorization] = "Bearer #{@token}"
    req.body = { action: 'createOrUpdate', input: [lead] }
  end.body
end

#trigger_campaign(campaign_id, lead_id) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/marketo_chef/client.rb', line 41

def trigger_campaign(campaign_id, lead_id)
  authenticate!

  connection.post do |req|
    req.url "/rest/v1/campaigns/#{campaign_id}/trigger.json"
    req.headers[:authorization] = "Bearer #{@token}"
    req.body = { input: { leads: [{ id: lead_id }] } }
  end.body
end