Giter VIP home page Giter VIP logo

ruby-pardot's Introduction

Install

Add the following to your Gemfile

gem "ruby-pardot"

Usage

Authentication

The client will authenticate before performing other API calls, but you can manually authenticate as well

require "ruby-pardot"

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

Object Types

The available objects are:

  • custom_fields

  • emails

  • lists

  • opportunities

  • prospects

  • users

  • visitor_activities

  • visitors

  • visits

Querying Objects

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

Creating, editing, and reading objects

See each individual object’s API reference page for available methods

developer.pardot.com/kb/api-version-3/using-prospects

prospect = client.prospects.create("[email protected]", :first_name => "John", :last_name => "Doe")

prospect.each do |key, value|
  puts "#{key} is #{value}"
end

Emails

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)

Output formats

client.format = "simple" # default
client.format = "mobile"
client.format = "full"

Error handling

Pardot will respond with an error message when you provide invalid parameters

begin
  prospect = client.prospects.create("[email protected]")
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

License

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.

ruby-pardot's People

Contributors

adelawalla avatar bentona avatar crim avatar dcunning avatar harvinder avatar znbailey avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.