Add the following to your Gemfile
gem "ruby-pardot"
The client will authenticate before performing other API calls, but you can manually authenticate as well
client = Pardot::Client.new email, password, user_key # will raise a Pardot::ResponseError if login fails # will raise a Pardot::NetError if the http call fails client.authenticate
The available objects are:
-
emails
-
lists
-
opportunities
-
prospects
-
users
-
visitor_activities
-
visitors
-
visits
developer.pardot.com/kb/api-version-3/querying-prospects
Most objects accept limit, offset, sort_by, and sord_order parameters
prospects = client.prospects.query(:assigned => false, :sort_by => "last_activity_at", :limit => 20) prospects["total_results"] # number of prospects found prospects["prospect"].each do |prospect| puts prospect["first_name"] end
See each individual object’s API reference page for available methods
developer.pardot.com/kb/api-version-3/using-prospects
prospect = client.prospects.create("user@test.com", :first_name => "John", :last_name => "Doe") prospect.each do |key, value| puts "#{key} is #{value}" end
See each individual call’s [API reference page](developer.pardot.com/kb/api-version-3/introduction-table-of-contents).
# Sample usage @pardot.emails.read_by_id(email_id) @pardot.emails.send_to_list(:email_template_id => template_id, 'list_ids[]' => list_id, :campaign_id => campaign_id) @pardot.emails.send_to_prospect(prospect_id, :campaign_id => campaign_id, :email_template_id => template_id)
client.format = "simple" # default client.format = "mobile" client.format = "full"
Pardot will respond with an error message when you provide invalid parameters
begin prospect = client.prospects.create("user@test.com") rescue Pardot::ResponseError => e # the request went through, but Pardot responded with an error, possibly because this email is already in use end
Performing API calls across the internet is inherently unsafe, so be sure to catch the exceptions
begin visitor = client.visitors.query(:id_greater_than => 200) rescue Pardot::NetError => e # the API request failed # - socket broke before the request was completed # - pi.pardot.com is under heavy load # - many number of other reasons end
The MIT License (MIT) Copyright © 2012 Pardot
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.