ruby-pardot 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +9 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +5 -5
- data/README.rdoc +19 -17
- data/Rakefile +2 -3
- data/lib/pardot/authentication.rb +23 -12
- data/lib/pardot/client.rb +17 -6
- data/lib/pardot/error.rb +6 -2
- data/lib/pardot/http.rb +47 -44
- data/lib/pardot/objects/custom_fields.rb +13 -17
- 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 +26 -30
- 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/ruby-pardot.gemspec +14 -12
- data/spec/pardot/authentication_spec.rb +78 -44
- data/spec/pardot/client_spec.rb +50 -15
- data/spec/pardot/error_spec.rb +6 -4
- data/spec/pardot/http_spec.rb +83 -92
- data/spec/pardot/objects/custom_fields_spec.rb +48 -53
- data/spec/pardot/objects/emails_spec.rb +34 -36
- data/spec/pardot/objects/lists_spec.rb +34 -38
- data/spec/pardot/objects/opportunities_spec.rb +58 -61
- data/spec/pardot/objects/prospect_accounts_spec.rb +72 -75
- data/spec/pardot/objects/prospects_spec.rb +56 -56
- data/spec/pardot/objects/users_spec.rb +58 -61
- data/spec/pardot/objects/visitor_activities_spec.rb +57 -61
- data/spec/pardot/objects/visitors_spec.rb +56 -61
- data/spec/pardot/objects/visits_spec.rb +56 -61
- data/spec/spec_helper.rb +2 -0
- data/spec/support/client_support.rb +40 -4
- data/spec/support/fakeweb.rb +13 -8
- metadata +8 -7
@@ -1,66 +1,63 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
4
|
|
3
5
|
describe Pardot::Objects::Opportunities 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
|
-
it "should return the prospect" do
|
57
|
-
fake_post "/api/opportunity/version/3/do/create/prospect_email/user@test.com?type=Good&format=simple&name=Jim", sample_results
|
58
|
-
|
59
|
-
expect(@client.opportunities.create_by_email("user@test.com", :name => "Jim", :type => "Good")).to eq({"name"=>"Jim", "type"=>"Good"})
|
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
|
+
<opportunity>
|
16
|
+
<name>Jim</name>
|
17
|
+
<type>Great</type>
|
18
|
+
</opportunity>
|
19
|
+
<opportunity>
|
20
|
+
<name>Sue</name>
|
21
|
+
<type>Good</type>
|
22
|
+
</opportunity>
|
23
|
+
</result>
|
24
|
+
</rsp>)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should take in some arguments' do
|
28
|
+
fake_get '/api/opportunity/version/3/do/query?id_greater_than=200&format=simple', sample_results
|
29
|
+
|
30
|
+
expected = {
|
31
|
+
'total_results' => 2,
|
32
|
+
'opportunity' => [
|
33
|
+
{ 'type' => 'Great', 'name' => 'Jim' },
|
34
|
+
{ 'type' => 'Good', 'name' => 'Sue' }
|
35
|
+
]
|
36
|
+
}
|
37
|
+
expect(client.opportunities.query(id_greater_than: 200)).to eq(expected)
|
38
|
+
assert_authorization_header auth_manager
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'create_by_email' do
|
43
|
+
def sample_results
|
44
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
45
|
+
<rsp stat="ok" version="1.0">
|
46
|
+
<opportunity>
|
47
|
+
<name>Jim</name>
|
48
|
+
<type>Good</type>
|
49
|
+
</opportunity>
|
50
|
+
</rsp>)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should return the prospect' do
|
54
|
+
fake_post '/api/opportunity/version/3/do/create/prospect_email/user@test.com?type=Good&format=simple&name=Jim', sample_results
|
55
|
+
|
56
|
+
expect(client.opportunities.create_by_email('user@test.com', name: 'Jim', type: 'Good')).to eq({ 'name' => 'Jim', 'type' => 'Good' })
|
60
57
|
|
61
|
-
|
58
|
+
assert_authorization_header auth_manager
|
59
|
+
end
|
60
|
+
end
|
62
61
|
end
|
63
|
-
|
64
62
|
end
|
65
|
-
|
66
|
-
end
|
63
|
+
end
|
@@ -1,80 +1,77 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
|
-
<prospectAccount>
|
17
|
-
<name>Spaceships R Us</name>
|
18
|
-
</prospectAccount>
|
19
|
-
<prospectAccount>
|
20
|
-
<name>Monsters Inc</name>
|
21
|
-
</prospectAccount>
|
22
|
-
</result>
|
23
|
-
</rsp>)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should take in some arguments and respond with valid items" do
|
27
|
-
fake_get "/api/prospectAccount/version/3/do/query?assigned=true&format=simple", sample_results
|
28
|
-
|
29
|
-
expect(@client.prospect_accounts.query(:assigned => true)).to eq({'total_results' => 2,
|
30
|
-
'prospectAccount'=>[
|
31
|
-
{'name'=>'Spaceships R Us'},
|
32
|
-
{'name'=>'Monsters Inc'}
|
33
|
-
]})
|
34
|
-
assert_authorization_header
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'read' do
|
40
|
-
def sample_results
|
41
|
-
%(<?xml version="1.0" encoding="UTF-8"?>
|
42
|
-
<rsp stat="ok" version="1.0">
|
43
|
-
<prospectAccount>
|
44
|
-
<id>1234</id>
|
45
|
-
<name>SupaDupaPanda</name>
|
46
|
-
</prospectAccount>
|
47
|
-
</rsp>)
|
48
|
-
end
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
49
4
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
5
|
+
describe Pardot::Objects::ProspectAccounts do
|
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"?>
|
13
|
+
<rsp stat="ok" version="1.0">
|
14
|
+
<result>
|
15
|
+
<total_results>2</total_results>
|
16
|
+
<prospectAccount>
|
17
|
+
<name>Spaceships R Us</name>
|
18
|
+
</prospectAccount>
|
19
|
+
<prospectAccount>
|
20
|
+
<name>Monsters Inc</name>
|
21
|
+
</prospectAccount>
|
22
|
+
</result>
|
23
|
+
</rsp>)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should take in some arguments and respond with valid items' do
|
27
|
+
fake_get '/api/prospectAccount/version/3/do/query?assigned=true&format=simple', sample_results
|
28
|
+
|
29
|
+
expect(client.prospect_accounts.query(assigned: true)).to eq({ 'total_results' => 2,
|
30
|
+
'prospectAccount' => [
|
31
|
+
{ 'name' => 'Spaceships R Us' },
|
32
|
+
{ 'name' => 'Monsters Inc' }
|
33
|
+
] })
|
34
|
+
assert_authorization_header auth_manager
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'read' do
|
39
|
+
def sample_results
|
40
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
41
|
+
<rsp stat="ok" version="1.0">
|
42
|
+
<prospectAccount>
|
43
|
+
<id>1234</id>
|
44
|
+
<name>SupaDupaPanda</name>
|
45
|
+
</prospectAccount>
|
46
|
+
</rsp>)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return a valid account' do
|
50
|
+
fake_post '/api/prospectAccount/version/3/do/read/id/1234?assigned=true&format=simple', sample_results
|
51
|
+
|
52
|
+
expect(client.prospect_accounts.read('1234',
|
53
|
+
assigned: true)).to eq({ 'id' => '1234', 'name' => 'SupaDupaPanda' })
|
54
|
+
assert_authorization_header auth_manager
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'create' do
|
59
|
+
def sample_results
|
60
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
61
|
+
<rsp stat="ok" version="1.0">
|
62
|
+
<prospectAccount>
|
63
|
+
<name>SuperPanda</name>
|
64
|
+
</prospectAccount>
|
65
|
+
</rsp>)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should return the prospect account' do
|
69
|
+
fake_post '/api/prospectAccount/version/3/do/create?format=simple&name=SuperPanda', sample_results
|
70
|
+
|
71
|
+
expect(client.prospect_accounts.create(name: 'SuperPanda')).to eq({ 'name' => 'SuperPanda' })
|
72
|
+
assert_authorization_header auth_manager
|
73
|
+
end
|
74
|
+
end
|
76
75
|
end
|
77
|
-
|
78
76
|
end
|
79
|
-
|
80
77
|
end
|
@@ -1,62 +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::Prospects 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
|
-
it "should return the prospect" do
|
54
|
-
fake_post "/api/prospect/version/3/do/create/email/user%40test.com?first_name=Jim&format=simple", sample_results
|
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"?>
|
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', sample_results
|
30
|
+
|
31
|
+
expect(client.prospects.query(assigned: true)).to eq({ 'total_results' => 2,
|
32
|
+
'prospect' => [
|
33
|
+
{ 'last_name' => 'Smith', 'first_name' => 'Jim' },
|
34
|
+
{ 'last_name' => 'Green', 'first_name' => 'Sue' }
|
35
|
+
] })
|
36
|
+
assert_authorization_header auth_manager
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'create' do
|
41
|
+
def sample_results
|
42
|
+
%(<?xml version="1.0" encoding="UTF-8"?>
|
43
|
+
<rsp stat="ok" version="1.0">
|
44
|
+
<prospect>
|
45
|
+
<first_name>Jim</first_name>
|
46
|
+
<last_name>Smith</last_name>
|
47
|
+
</prospect>
|
48
|
+
</rsp>)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should return the prospect' do
|
52
|
+
fake_post '/api/prospect/version/3/do/create/email/user%40test.com?first_name=Jim&format=simple',
|
53
|
+
sample_results
|
55
54
|
|
56
|
-
|
57
|
-
|
55
|
+
expect(client.prospects.create('user@test.com',
|
56
|
+
first_name: 'Jim')).to eq({ 'last_name' => 'Smith', 'first_name' => 'Jim' })
|
57
|
+
assert_authorization_header auth_manager
|
58
|
+
end
|
59
|
+
end
|
58
60
|
end
|
59
|
-
|
60
61
|
end
|
61
|
-
|
62
62
|
end
|
@@ -1,65 +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
|
-
|
59
|
-
expect(@client.users.read_by_email("user@test.com")).to eq({"email"=>"user@example.com", "first_name"=>"Sue"})
|
60
|
-
assert_authorization_header
|
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
|
61
60
|
end
|
62
|
-
|
63
61
|
end
|
64
|
-
|
65
|
-
end
|
62
|
+
end
|