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,41 +1,38 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
4
|
|
3
5
|
describe Pardot::Objects::Lists 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
|
-
{"name"=>"Asdf List"},
|
35
|
-
{"name"=>"Qwerty List"}
|
36
|
-
]}
|
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
|
+
<list>
|
16
|
+
<name>Asdf List</name>
|
17
|
+
</list>
|
18
|
+
<list>
|
19
|
+
<name>Qwerty List</name>
|
20
|
+
</list>
|
21
|
+
</result>
|
22
|
+
</rsp>)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should take in some arguments' do
|
26
|
+
fake_get '/api/list/version/3/do/query?id_greater_than=200&format=simple', sample_results
|
27
|
+
|
28
|
+
expect(client.lists.query(id_greater_than: 200)).to eq({ 'total_results' => 2,
|
29
|
+
'list' => [
|
30
|
+
{ 'name' => 'Asdf List' },
|
31
|
+
{ 'name' => 'Qwerty List' }
|
32
|
+
] })
|
33
|
+
assert_authorization_header auth_manager
|
34
|
+
end
|
35
|
+
end
|
37
36
|
end
|
38
|
-
|
39
37
|
end
|
40
|
-
|
41
|
-
end
|
38
|
+
end
|
@@ -1,64 +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
|
-
|
57
|
-
|
58
|
-
|
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
|
+
<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' })
|
57
|
+
|
58
|
+
assert_authorization_header auth_manager
|
59
|
+
end
|
60
|
+
end
|
60
61
|
end
|
61
|
-
|
62
62
|
end
|
63
|
-
|
64
|
-
end
|
63
|
+
end
|
@@ -1,78 +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&user_key=bar&api_key=my_api_key", sample_results
|
28
|
-
|
29
|
-
@client.prospect_accounts.query(:assigned => true).should == {'total_results' => 2,
|
30
|
-
'prospectAccount'=>[
|
31
|
-
{'name'=>'Spaceships R Us'},
|
32
|
-
{'name'=>'Monsters Inc'}
|
33
|
-
]}
|
34
|
-
end
|
35
|
-
|
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&user_key=bar&api_key=my_api_key', sample_results
|
51
|
-
|
52
|
-
@client.prospect_accounts.read('1234', :assigned => true).should == {'id' => '1234', 'name' => 'SupaDupaPanda' }
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
describe 'create' do
|
59
|
-
|
60
|
-
def sample_results
|
61
|
-
%(<?xml version="1.0" encoding="UTF-8"?>
|
62
|
-
<rsp stat="ok" version="1.0">
|
63
|
-
<prospectAccount>
|
64
|
-
<name>SuperPanda</name>
|
65
|
-
</prospectAccount>
|
66
|
-
</rsp>)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should return the prospect account' do
|
70
|
-
fake_post '/api/prospectAccount/version/3/do/create?api_key=my_api_key&user_key=bar&format=simple&name=SuperPanda', sample_results
|
71
|
-
|
72
|
-
@client.prospect_accounts.create(:name => 'SuperPanda').should == {"name"=>"SuperPanda"}
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
73
4
|
|
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
|
74
75
|
end
|
75
|
-
|
76
76
|
end
|
77
|
-
|
78
77
|
end
|
@@ -1,61 +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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
54
|
+
|
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
|
57
60
|
end
|
58
|
-
|
59
61
|
end
|
60
|
-
|
61
|
-
end
|
62
|
+
end
|