@@ -8,24 +8,76 @@ Add the following to your Gemfile
8
8
9
9
=== Authentication
10
10
11
+ The client will authenticate before performing other API calls, but you can manually authenticate as well
12
+
11
13
client = Pardot::Client.new email, password, user_key
12
14
13
15
# will raise a Pardot::ResponseError if login fails
14
16
# will raise a Pardot::NetError if the http call fails
15
17
client.authenticate
16
18
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
18
33
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)
20
39
21
40
prospects["total_results"] # number of prospects found
22
41
23
42
prospects["prospect"].each do |prospect|
24
43
puts prospect["first_name"]
25
44
end
26
45
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
+
27
58
=== Switching formats
28
59
29
60
client.format = "simple" # default
30
61
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