Skip to content

Commit 10d01e9

Browse files
committed
updated readme to explain how to use the api wrapper and where to find more information on the api parameters
1 parent 5b46d3d commit 10d01e9

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

README.rdoc

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,76 @@ Add the following to your Gemfile
88

99
=== Authentication
1010

11+
The client will authenticate before performing other API calls, but you can manually authenticate as well
12+
1113
client = Pardot::Client.new email, password, user_key
1214

1315
# will raise a Pardot::ResponseError if login fails
1416
# will raise a Pardot::NetError if the http call fails
1517
client.authenticate
1618

17-
=== Accessing Prospects
19+
== Object Types
20+
21+
The available objects are:
22+
23+
* opportunities
24+
* prospects
25+
* users
26+
* visitor_activities
27+
* visitors
28+
* visits
29+
30+
== See Pardot API for details
31+
32+
=== How to query objects
1833

19-
prospects = client.prospects.query(:assigned => false)
34+
http://developer.pardot.com/kb/api-version-3/querying-prospects
35+
36+
Most objects accept limit, offset, sort_by, and sord_order parameters
37+
38+
prospects = client.prospects.query(:assigned => false, :sort_by => "last_activity_at", :limit => 20)
2039

2140
prospects["total_results"] # number of prospects found
2241

2342
prospects["prospect"].each do |prospect|
2443
puts prospect["first_name"]
2544
end
2645

46+
=== How to create and edit objects
47+
48+
See each individual object's API reference page for available methods
49+
50+
http://developer.pardot.com/kb/api-version-3/using-prospects
51+
52+
prospect = client.prospects.create("[email protected]", :first_name => "John", :last_name => "Doe")
53+
54+
prospect.each do |key, value|
55+
puts "#{key} is #{value}"
56+
end
57+
2758
=== Switching formats
2859

2960
client.format = "simple" # default
3061
client.format = "mobile"
31-
client.format = "full"
62+
client.format = "full"
63+
64+
=== Error handling
65+
66+
Pardot will respond with an error message when you provide invalid parameters
67+
68+
begin
69+
prospect = client.prospects.create("[email protected]")
70+
rescue Pardot::ResponseError => e
71+
# the request went through, but Pardot responded with an error, possibly because this email is already in use
72+
end
73+
74+
Performing API calls across the internet is inherently unsafe, so be sure to catch the exceptions
75+
76+
begin
77+
visitor = client.visitors.query(:id_greater_than => 200)
78+
rescue Pardot::NetError => e
79+
# the API request failed
80+
# - socket broke before the request was completed
81+
# - pi.pardot.com is under heavy load
82+
# - many number of other reasons
83+
end

0 commit comments

Comments
 (0)