ruby-pardot 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Pardot::Objects::Prospects do
4
+
5
+ before do
6
+ @client = create_client
7
+ end
8
+
9
+ describe "query" do
10
+
11
+ def sample_results
12
+ %(<?xml version="1.0" encoding="UTF-8"?>
13
+ <rsp stat="ok" version="1.0">
14
+ <result>
15
+ <total_results>2</total_results>
16
+ <prospect>
17
+ <first_name>Jim</first_name>
18
+ <last_name>Smith</last_name>
19
+ </prospect>
20
+ <prospect>
21
+ <first_name>Sue</first_name>
22
+ <last_name>Green</last_name>
23
+ </prospect>
24
+ </result>
25
+ </rsp>)
26
+ end
27
+
28
+ it "should take in some arguments" do
29
+ fake_get "/api/prospect/version/3/do/query?assigned=true&format=simple&user_key=bar&api_key=my_api_key", sample_results
30
+
31
+ @client.prospects.query(:assigned => true).should == {"total_results" => 2,
32
+ "prospect"=>[
33
+ {"last_name"=>"Smith", "first_name"=>"Jim"},
34
+ {"last_name"=>"Green", "first_name"=>"Sue"}
35
+ ]}
36
+ end
37
+
38
+ end
39
+
40
+ describe "create" do
41
+
42
+ def sample_results
43
+ %(<?xml version="1.0" encoding="UTF-8"?>
44
+ <rsp stat="ok" version="1.0">
45
+ <prospect>
46
+ <first_name>Jim</first_name>
47
+ <last_name>Smith</last_name>
48
+ </prospect>
49
+ </rsp>)
50
+ end
51
+
52
+ it "should return the prospect" do
53
+ fake_post "/api/prospect/version/3/do/create/email/user@test.com?api_key=my_api_key&user_key=bar&format=simple&first_name=Jim", sample_results
54
+
55
+ @client.prospects.create("user@test.com", :first_name => "Jim").should == {"last_name"=>"Smith", "first_name"=>"Jim"}
56
+
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Pardot::Objects::Users do
4
+
5
+ before do
6
+ @client = create_client
7
+ end
8
+
9
+ describe "query" do
10
+
11
+ def sample_results
12
+ %(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
13
+ <result>
14
+ <total_results>2</total_results>
15
+ <user>
16
+ <email>user@test.com</email>
17
+ <first_name>Jim</first_name>
18
+ </user>
19
+ <user>
20
+ <email>user@example.com</email>
21
+ <first_name>Sue</first_name>
22
+ </user>
23
+ </result>
24
+ </rsp>)
25
+ end
26
+
27
+ before do
28
+ @client = create_client
29
+ end
30
+
31
+ it "should take in some arguments" do
32
+ fake_get "/api/user/version/3/do/query?api_key=my_api_key&user_key=bar&id_greater_than=200&format=simple", sample_results
33
+
34
+ @client.users.query(:id_greater_than => 200).should == {"total_results" => 2,
35
+ "user"=>[
36
+ {"email"=>"user@test.com", "first_name"=>"Jim"},
37
+ {"email"=>"user@example.com", "first_name"=>"Sue"}
38
+ ]}
39
+ end
40
+
41
+ end
42
+
43
+ describe "read_by_email" do
44
+
45
+ def sample_results
46
+ %(<?xml version="1.0" encoding="UTF-8"?>
47
+ <rsp stat="ok" version="1.0">
48
+ <user>
49
+ <email>user@example.com</email>
50
+ <first_name>Sue</first_name>
51
+ </user>
52
+ </rsp>)
53
+ end
54
+
55
+ it "should return the prospect" do
56
+ fake_post "/api/user/version/3/do/read/email/user@test.com?api_key=my_api_key&user_key=bar&format=simple", sample_results
57
+
58
+ @client.users.read_by_email("user@test.com").should == {"email"=>"user@example.com", "first_name"=>"Sue"}
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Pardot::Objects::VisitorActivities do
4
+
5
+ before do
6
+ @client = create_client
7
+ end
8
+
9
+ describe "query" do
10
+
11
+ def sample_results
12
+ %(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
13
+ <result>
14
+ <total_results>2</total_results>
15
+ <visitorActivity>
16
+ <type_name>Read</type_name>
17
+ <details>Some details</details>
18
+ </visitorActivity>
19
+ <visitorActivity>
20
+ <type_name>Write</type_name>
21
+ <details>More details</details>
22
+ </visitorActivity>
23
+ </result>
24
+ </rsp>)
25
+ end
26
+
27
+ before do
28
+ @client = create_client
29
+ end
30
+
31
+ it "should take in some arguments" do
32
+ fake_get "/api/visitorActivity/version/3/do/query?user_key=bar&api_key=my_api_key&id_greater_than=200&format=simple", sample_results
33
+
34
+ @client.visitor_activities.query(:id_greater_than => 200).should == {"total_results" => 2,
35
+ "visitorActivity"=>[
36
+ {"type_name"=>"Read", "details"=>"Some details"},
37
+ {"type_name"=>"Write", "details"=>"More details"}
38
+ ]}
39
+ end
40
+
41
+ end
42
+
43
+ describe "read" do
44
+
45
+ def sample_results
46
+ %(<?xml version="1.0" encoding="UTF-8"?>
47
+ <rsp stat="ok" version="1.0">
48
+ <visitorActivity>
49
+ <type_name>Write</type_name>
50
+ <details>More details</details>
51
+ </visitorActivity>
52
+ </rsp>)
53
+ end
54
+
55
+ it "should return the prospect" do
56
+ fake_post "/api/visitorActivity/version/3/do/read/id/10?user_key=bar&api_key=my_api_key&format=simple", sample_results
57
+
58
+ @client.visitor_activities.read(10).should == {"details"=>"More details", "type_name"=>"Write"}
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Pardot::Objects::Visitors do
4
+
5
+ before do
6
+ @client = create_client
7
+ end
8
+
9
+ describe "query" do
10
+
11
+ def sample_results
12
+ %(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
13
+ <result>
14
+ <total_results>2</total_results>
15
+ <visitor>
16
+ <browser>Firefox</browser>
17
+ <language>en</language>
18
+ </visitor>
19
+ <visitor>
20
+ <browser>Chrome</browser>
21
+ <language>es</language>
22
+ </visitor>
23
+ </result>
24
+ </rsp>)
25
+ end
26
+
27
+ before do
28
+ @client = create_client
29
+ end
30
+
31
+ it "should take in some arguments" do
32
+ fake_get "/api/visitor/version/3/do/query?api_key=my_api_key&user_key=bar&id_greater_than=200&format=simple", sample_results
33
+
34
+ @client.visitors.query(:id_greater_than => 200).should == {"total_results" => 2,
35
+ "visitor"=>[
36
+ {"browser"=>"Firefox", "language"=>"en"},
37
+ {"browser"=>"Chrome", "language"=>"es"}
38
+ ]}
39
+ end
40
+
41
+ end
42
+
43
+ describe "assign" do
44
+
45
+ def sample_results
46
+ %(<?xml version="1.0" encoding="UTF-8"?>
47
+ <rsp stat="ok" version="1.0">
48
+ <visitor>
49
+ <browser>Chrome</browser>
50
+ <language>es</language>
51
+ </visitor>
52
+ </rsp>)
53
+ end
54
+
55
+ it "should return the prospect" do
56
+ fake_post "/api/visitor/version/3/do/assign/id/10?type=Good&api_key=my_api_key&user_key=bar&format=simple&name=Jim", sample_results
57
+
58
+ @client.visitors.assign(10, :name => "Jim", :type => "Good").should == {"browser"=>"Chrome", "language"=>"es"}
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe Pardot::Objects::Visits do
4
+
5
+ before do
6
+ @client = create_client
7
+ end
8
+
9
+ describe "query" do
10
+
11
+ def sample_results
12
+ %(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
13
+ <result>
14
+ <total_results>2</total_results>
15
+ <visit>
16
+ <duration_in_seconds>50</duration_in_seconds>
17
+ <visitor_page_view_count>3</visitor_page_view_count>
18
+ </visit>
19
+ <visit>
20
+ <duration_in_seconds>10</duration_in_seconds>
21
+ <visitor_page_view_count>1</visitor_page_view_count>
22
+ </visit>
23
+ </result>
24
+ </rsp>)
25
+ end
26
+
27
+ before do
28
+ @client = create_client
29
+ end
30
+
31
+ it "should take in some arguments" do
32
+ fake_get "/api/visit/version/3/do/query?api_key=my_api_key&user_key=bar&id_greater_than=200&format=simple", sample_results
33
+
34
+ @client.visits.query(:id_greater_than => 200).should == {"total_results" => 2,
35
+ "visit"=>[
36
+ {"duration_in_seconds"=>"50", "visitor_page_view_count"=>"3"},
37
+ {"duration_in_seconds"=>"10", "visitor_page_view_count"=>"1"}
38
+ ]}
39
+ end
40
+
41
+ end
42
+
43
+ describe "read" do
44
+
45
+ def sample_results
46
+ %(<?xml version="1.0" encoding="UTF-8"?>
47
+ <rsp stat="ok" version="1.0">
48
+ <visit>
49
+ <duration_in_seconds>10</duration_in_seconds>
50
+ <visitor_page_view_count>1</visitor_page_view_count>
51
+ </visit>
52
+ </rsp>)
53
+ end
54
+
55
+ it "should return the prospect" do
56
+ fake_post "/api/visit/version/3/do/read/id/10?user_key=bar&api_key=my_api_key&format=simple", sample_results
57
+
58
+ @client.visits.read(10).should == {"visitor_page_view_count"=>"1", "duration_in_seconds"=>"10"}
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'cgi'
3
+ require 'tempfile'
4
+ require 'rspec'
5
+
6
+ require 'crack'
7
+ require 'httparty'
8
+
9
+ require 'ruby-pardot'
10
+
11
+ Dir[File.join("spec/support/**/*.rb")].each {|f| require f}
@@ -0,0 +1,6 @@
1
+
2
+ def create_client
3
+ @client = Pardot::Client.new "user@test.com", "foo", "bar"
4
+ @client.api_key = "my_api_key"
5
+ @client
6
+ end
@@ -0,0 +1,14 @@
1
+ require 'fakeweb'
2
+ FakeWeb.allow_net_connect = false
3
+
4
+ def fake_post path, response
5
+ FakeWeb.register_uri(:post, "https://pi.pardot.com#{path}", :body => response)
6
+ end
7
+
8
+ def fake_get path, response
9
+ FakeWeb.register_uri(:get, "https://pi.pardot.com#{path}", :body => response)
10
+ end
11
+
12
+ def fake_authenticate client, api_key
13
+ client.api_key = api_key
14
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-pardot
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Cunning
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: crack
16
+ requirement: &70243888377720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70243888377720
25
+ - !ruby/object:Gem::Dependency
26
+ name: httparty
27
+ requirement: &70243888377000 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70243888377000
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70243888376480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70243888376480
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70243888375960 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70243888375960
58
+ - !ruby/object:Gem::Dependency
59
+ name: fakeweb
60
+ requirement: &70243888375480 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70243888375480
69
+ description: Library for interacting with the Pardot API
70
+ email:
71
+ - support@pardot.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.rdoc
81
+ - Rakefile
82
+ - lib/pardot/authentication.rb
83
+ - lib/pardot/client.rb
84
+ - lib/pardot/error.rb
85
+ - lib/pardot/http.rb
86
+ - lib/pardot/objects/lists.rb
87
+ - lib/pardot/objects/opportunities.rb
88
+ - lib/pardot/objects/prospects.rb
89
+ - lib/pardot/objects/users.rb
90
+ - lib/pardot/objects/visitor_activities.rb
91
+ - lib/pardot/objects/visitors.rb
92
+ - lib/pardot/objects/visits.rb
93
+ - lib/pardot/version.rb
94
+ - lib/ruby-pardot.rb
95
+ - ruby-pardot.gemspec
96
+ - spec/pardot/authentication_spec.rb
97
+ - spec/pardot/http_spec.rb
98
+ - spec/pardot/objects/lists_spec.rb
99
+ - spec/pardot/objects/opportunities_spec.rb
100
+ - spec/pardot/objects/prospects_spec.rb
101
+ - spec/pardot/objects/users_spec.rb
102
+ - spec/pardot/objects/visitor_activities_spec.rb
103
+ - spec/pardot/objects/visitors_spec.rb
104
+ - spec/pardot/objects/visits_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/support/client_support.rb
107
+ - spec/support/fakeweb.rb
108
+ homepage: http://github.com/pardot/ruby-pardot
109
+ licenses: []
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 1.3.6
126
+ requirements: []
127
+ rubyforge_project: ruby-pardot
128
+ rubygems_version: 1.8.12
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: Library for interacting with the Pardot API
132
+ test_files: []