ruby-pardot 1.2.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +9 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +26 -19
- data/README.rdoc +23 -18
- data/Rakefile +2 -3
- data/lib/pardot/authentication.rb +23 -12
- data/lib/pardot/client.rb +18 -6
- data/lib/pardot/error.rb +6 -2
- data/lib/pardot/http.rb +51 -41
- data/lib/pardot/objects/custom_fields.rb +33 -0
- data/lib/pardot/objects/emails.rb +9 -14
- data/lib/pardot/objects/list_memberships.rb +8 -12
- data/lib/pardot/objects/lists.rb +20 -25
- data/lib/pardot/objects/opportunities.rb +21 -26
- data/lib/pardot/objects/prospect_accounts.rb +6 -7
- data/lib/pardot/objects/prospects.rb +69 -71
- data/lib/pardot/objects/users.rb +17 -21
- data/lib/pardot/objects/visitor_activities.rb +15 -19
- data/lib/pardot/objects/visitors.rb +17 -21
- data/lib/pardot/objects/visits.rb +15 -19
- data/lib/pardot/version.rb +1 -1
- data/lib/ruby-pardot.rb +1 -0
- data/ruby-pardot.gemspec +15 -13
- data/spec/pardot/authentication_spec.rb +84 -50
- data/spec/pardot/client_spec.rb +52 -17
- data/spec/pardot/error_spec.rb +6 -4
- data/spec/pardot/http_spec.rb +96 -104
- data/spec/pardot/objects/custom_fields_spec.rb +53 -0
- data/spec/pardot/objects/emails_spec.rb +34 -33
- data/spec/pardot/objects/lists_spec.rb +34 -37
- data/spec/pardot/objects/opportunities_spec.rb +59 -60
- data/spec/pardot/objects/prospect_accounts_spec.rb +72 -73
- data/spec/pardot/objects/prospects_spec.rb +58 -57
- data/spec/pardot/objects/users_spec.rb +58 -60
- data/spec/pardot/objects/visitor_activities_spec.rb +57 -60
- data/spec/pardot/objects/visitors_spec.rb +56 -60
- data/spec/pardot/objects/visits_spec.rb +56 -60
- data/spec/spec_helper.rb +2 -0
- data/spec/support/client_support.rb +40 -4
- data/spec/support/fakeweb.rb +14 -5
- metadata +17 -18
@@ -1,64 +1,62 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
4
|
|
3
5
|
describe Pardot::Objects::Users do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
</
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
@client.users.read_by_email("user@test.com").should == {"email"=>"user@example.com", "first_name"=>"Sue"}
|
59
|
-
|
6
|
+
create_auth_managers.each do |auth_manager|
|
7
|
+
context auth_manager.test_name_suffix do
|
8
|
+
let(:client) { auth_manager.create_client }
|
9
|
+
|
10
|
+
describe 'query' do
|
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
|
+
it 'should take in some arguments' do
|
28
|
+
fake_get '/api/user/version/3/do/query?id_greater_than=200&format=simple', sample_results
|
29
|
+
|
30
|
+
expect(client.users.query(id_greater_than: 200)).to eq({ 'total_results' => 2,
|
31
|
+
'user' => [
|
32
|
+
{ 'email' => 'user@test.com',
|
33
|
+
'first_name' => 'Jim' },
|
34
|
+
{ 'email' => 'user@example.com',
|
35
|
+
'first_name' => 'Sue' }
|
36
|
+
] })
|
37
|
+
assert_authorization_header auth_manager
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'read_by_email' do
|
42
|
+
def sample_results
|
43
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
44
|
+
<rsp stat="ok" version="1.0">
|
45
|
+
<user>
|
46
|
+
<email>user@example.com</email>
|
47
|
+
<first_name>Sue</first_name>
|
48
|
+
</user>
|
49
|
+
</rsp>)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return the prospect' do
|
53
|
+
fake_post '/api/user/version/3/do/read/email/user@test.com?format=simple', sample_results
|
54
|
+
|
55
|
+
expect(client.users.read_by_email('user@test.com')).to eq({ 'email' => 'user@example.com',
|
56
|
+
'first_name' => 'Sue' })
|
57
|
+
assert_authorization_header auth_manager
|
58
|
+
end
|
59
|
+
end
|
60
60
|
end
|
61
|
-
|
62
61
|
end
|
63
|
-
|
64
|
-
end
|
62
|
+
end
|
@@ -1,64 +1,61 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
4
|
|
3
5
|
describe Pardot::Objects::VisitorActivities do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
</
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
@client.visitor_activities.read(10).should == {"details"=>"More details", "type_name"=>"Write"}
|
59
|
-
|
6
|
+
create_auth_managers.each do |auth_manager|
|
7
|
+
context auth_manager.test_name_suffix do
|
8
|
+
let(:client) { auth_manager.create_client }
|
9
|
+
|
10
|
+
describe 'query' do
|
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
|
+
it 'should take in some arguments' do
|
28
|
+
fake_get '/api/visitorActivity/version/3/do/query?id_greater_than=200&format=simple', sample_results
|
29
|
+
|
30
|
+
expect(client.visitor_activities.query(id_greater_than: 200)).to eq({ 'total_results' => 2,
|
31
|
+
'visitorActivity' => [
|
32
|
+
{ 'type_name' => 'Read',
|
33
|
+
'details' => 'Some details' },
|
34
|
+
{ 'type_name' => 'Write',
|
35
|
+
'details' => 'More details' }
|
36
|
+
] })
|
37
|
+
assert_authorization_header auth_manager
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'read' do
|
42
|
+
def sample_results
|
43
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
44
|
+
<rsp stat="ok" version="1.0">
|
45
|
+
<visitorActivity>
|
46
|
+
<type_name>Write</type_name>
|
47
|
+
<details>More details</details>
|
48
|
+
</visitorActivity>
|
49
|
+
</rsp>)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return the prospect' do
|
53
|
+
fake_post '/api/visitorActivity/version/3/do/read/id/10?format=simple', sample_results
|
54
|
+
|
55
|
+
expect(client.visitor_activities.read(10)).to eq({ 'details' => 'More details', 'type_name' => 'Write' })
|
56
|
+
assert_authorization_header auth_manager
|
57
|
+
end
|
58
|
+
end
|
60
59
|
end
|
61
|
-
|
62
60
|
end
|
63
|
-
|
64
|
-
end
|
61
|
+
end
|
@@ -1,64 +1,60 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
4
|
|
3
5
|
describe Pardot::Objects::Visitors do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
6
|
+
create_auth_managers.each do |auth_manager|
|
7
|
+
context auth_manager.test_name_suffix do
|
8
|
+
let(:client) { auth_manager.create_client }
|
9
|
+
describe 'query' do
|
10
|
+
def sample_results
|
11
|
+
%(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
|
12
|
+
<result>
|
13
|
+
<total_results>2</total_results>
|
14
|
+
<visitor>
|
15
|
+
<browser>Firefox</browser>
|
16
|
+
<language>en</language>
|
17
|
+
</visitor>
|
18
|
+
<visitor>
|
19
|
+
<browser>Chrome</browser>
|
20
|
+
<language>es</language>
|
21
|
+
</visitor>
|
22
|
+
</result>
|
23
|
+
</rsp>)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should take in some arguments' do
|
27
|
+
fake_get '/api/visitor/version/3/do/query?id_greater_than=200&format=simple', sample_results
|
28
|
+
|
29
|
+
expect(client.visitors.query(id_greater_than: 200)).to eq({ 'total_results' => 2,
|
30
|
+
'visitor' => [
|
31
|
+
{ 'browser' => 'Firefox',
|
32
|
+
'language' => 'en' },
|
33
|
+
{ 'browser' => 'Chrome', 'language' => 'es' }
|
34
|
+
] })
|
35
|
+
assert_authorization_header auth_manager
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'assign' do
|
40
|
+
def sample_results
|
41
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
42
|
+
<rsp stat="ok" version="1.0">
|
43
|
+
<visitor>
|
44
|
+
<browser>Chrome</browser>
|
45
|
+
<language>es</language>
|
46
|
+
</visitor>
|
47
|
+
</rsp>)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should return the prospect' do
|
51
|
+
fake_post '/api/visitor/version/3/do/assign/id/10?type=Good&format=simple&name=Jim', sample_results
|
52
|
+
|
53
|
+
expect(client.visitors.assign(10, name: 'Jim',
|
54
|
+
type: 'Good')).to eq({ 'browser' => 'Chrome', 'language' => 'es' })
|
55
|
+
assert_authorization_header auth_manager
|
56
|
+
end
|
57
|
+
end
|
60
58
|
end
|
61
|
-
|
62
59
|
end
|
63
|
-
|
64
|
-
end
|
60
|
+
end
|
@@ -1,64 +1,60 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
4
|
|
3
5
|
describe Pardot::Objects::Visits do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
6
|
+
create_auth_managers.each do |auth_manager|
|
7
|
+
context auth_manager.test_name_suffix do
|
8
|
+
let(:client) { auth_manager.create_client }
|
9
|
+
describe 'query' do
|
10
|
+
def sample_results
|
11
|
+
%(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0">
|
12
|
+
<result>
|
13
|
+
<total_results>2</total_results>
|
14
|
+
<visit>
|
15
|
+
<duration_in_seconds>50</duration_in_seconds>
|
16
|
+
<visitor_page_view_count>3</visitor_page_view_count>
|
17
|
+
</visit>
|
18
|
+
<visit>
|
19
|
+
<duration_in_seconds>10</duration_in_seconds>
|
20
|
+
<visitor_page_view_count>1</visitor_page_view_count>
|
21
|
+
</visit>
|
22
|
+
</result>
|
23
|
+
</rsp>)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should take in some arguments' do
|
27
|
+
fake_get '/api/visit/version/3/do/query?id_greater_than=200&format=simple', sample_results
|
28
|
+
|
29
|
+
expect(client.visits.query(id_greater_than: 200)).to eq({ 'total_results' => 2,
|
30
|
+
'visit' => [
|
31
|
+
{ 'duration_in_seconds' => '50',
|
32
|
+
'visitor_page_view_count' => '3' },
|
33
|
+
{ 'duration_in_seconds' => '10',
|
34
|
+
'visitor_page_view_count' => '1' }
|
35
|
+
] })
|
36
|
+
assert_authorization_header auth_manager
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'read' do
|
41
|
+
def sample_results
|
42
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
43
|
+
<rsp stat="ok" version="1.0">
|
44
|
+
<visit>
|
45
|
+
<duration_in_seconds>10</duration_in_seconds>
|
46
|
+
<visitor_page_view_count>1</visitor_page_view_count>
|
47
|
+
</visit>
|
48
|
+
</rsp>)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should return the prospect' do
|
52
|
+
fake_post '/api/visit/version/3/do/read/id/10?format=simple', sample_results
|
53
|
+
|
54
|
+
expect(client.visits.read(10)).to eq({ 'visitor_page_view_count' => '1', 'duration_in_seconds' => '10' })
|
55
|
+
assert_authorization_header auth_manager
|
56
|
+
end
|
57
|
+
end
|
60
58
|
end
|
61
|
-
|
62
59
|
end
|
63
|
-
|
64
|
-
end
|
60
|
+
end
|