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,44 +1,39 @@
|
|
1
1
|
module Pardot
|
2
2
|
module Objects
|
3
|
-
|
4
3
|
module Emails
|
5
|
-
|
6
4
|
def emails
|
7
5
|
@emails ||= Emails.new self
|
8
6
|
end
|
9
7
|
|
10
8
|
class Emails
|
11
|
-
|
12
|
-
def initialize client
|
9
|
+
def initialize(client)
|
13
10
|
@client = client
|
14
11
|
end
|
15
12
|
|
16
|
-
def read_by_id
|
13
|
+
def read_by_id(id)
|
17
14
|
get "/do/read/id/#{id}"
|
18
15
|
end
|
19
16
|
|
20
|
-
def send_to_prospect
|
17
|
+
def send_to_prospect(prospect_id, params)
|
21
18
|
post "/do/send/prospect_id/#{prospect_id}", params
|
22
19
|
end
|
23
20
|
|
24
|
-
def send_to_list
|
25
|
-
post
|
21
|
+
def send_to_list(params)
|
22
|
+
post '/do/send', params
|
26
23
|
end
|
27
24
|
|
28
25
|
protected
|
29
26
|
|
30
|
-
def get
|
31
|
-
response = @client.get
|
27
|
+
def get(path, params = {}, result = 'email')
|
28
|
+
response = @client.get 'email', path, params
|
32
29
|
result ? response[result] : response
|
33
30
|
end
|
34
31
|
|
35
|
-
def post
|
36
|
-
response = @client.post
|
32
|
+
def post(path, params = {}, result = 'email')
|
33
|
+
response = @client.post 'email', path, params
|
37
34
|
result ? response[result] : response
|
38
35
|
end
|
39
|
-
|
40
36
|
end
|
41
|
-
|
42
37
|
end
|
43
38
|
end
|
44
39
|
end
|
@@ -1,36 +1,32 @@
|
|
1
1
|
module Pardot
|
2
2
|
module Objects
|
3
3
|
module ListMemberships
|
4
|
-
|
5
4
|
def list_memberships
|
6
5
|
@list_memberships ||= ListMemberships.new self
|
7
6
|
end
|
8
7
|
|
9
8
|
class ListMemberships
|
10
|
-
|
11
|
-
def initialize client
|
9
|
+
def initialize(client)
|
12
10
|
@client = client
|
13
11
|
end
|
14
12
|
|
15
|
-
def query
|
16
|
-
result = get
|
17
|
-
result[
|
13
|
+
def query(params)
|
14
|
+
result = get '/do/query', params, 'result'
|
15
|
+
result['total_results'] = result['total_results'].to_i if result['total_results']
|
18
16
|
result
|
19
17
|
end
|
20
18
|
|
21
|
-
def read_by_id
|
19
|
+
def read_by_id(id, params = {})
|
22
20
|
get "/do/read/id/#{id}", params
|
23
21
|
end
|
24
22
|
|
25
23
|
protected
|
26
24
|
|
27
|
-
def get
|
28
|
-
response = @client.get
|
25
|
+
def get(path, params = {}, result = 'listMembership')
|
26
|
+
response = @client.get 'listMembership', path, params
|
29
27
|
result ? response[result] : response
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
33
|
-
|
34
30
|
end
|
35
31
|
end
|
36
|
-
end
|
32
|
+
end
|
data/lib/pardot/objects/lists.rb
CHANGED
@@ -1,50 +1,45 @@
|
|
1
1
|
module Pardot
|
2
2
|
module Objects
|
3
|
-
|
4
3
|
module Lists
|
5
|
-
|
6
4
|
def lists
|
7
5
|
@lists ||= Lists.new self
|
8
6
|
end
|
9
|
-
|
7
|
+
|
10
8
|
class Lists
|
11
|
-
|
12
|
-
def initialize client
|
9
|
+
def initialize(client)
|
13
10
|
@client = client
|
14
11
|
end
|
15
|
-
|
16
|
-
def create
|
17
|
-
post
|
12
|
+
|
13
|
+
def create(_id, params = {})
|
14
|
+
post '/do/create', params
|
18
15
|
end
|
19
|
-
|
20
|
-
def query
|
21
|
-
result = get
|
22
|
-
result[
|
16
|
+
|
17
|
+
def query(params)
|
18
|
+
result = get '/do/query', params, 'result'
|
19
|
+
result['total_results'] = result['total_results'].to_i if result['total_results']
|
23
20
|
result
|
24
21
|
end
|
25
|
-
|
26
|
-
def read_by_id
|
22
|
+
|
23
|
+
def read_by_id(id, params = {})
|
27
24
|
get "/do/read/id/#{id}", params
|
28
25
|
end
|
29
|
-
|
30
|
-
def update
|
26
|
+
|
27
|
+
def update(id, _params = {})
|
31
28
|
post "/do/update/#{id}"
|
32
29
|
end
|
33
|
-
|
30
|
+
|
34
31
|
protected
|
35
|
-
|
36
|
-
def get
|
37
|
-
response = @client.get
|
32
|
+
|
33
|
+
def get(path, params = {}, result = 'list')
|
34
|
+
response = @client.get 'list', path, params
|
38
35
|
result ? response[result] : response
|
39
36
|
end
|
40
|
-
|
41
|
-
def post
|
42
|
-
response = @client.post
|
37
|
+
|
38
|
+
def post(path, params = {}, result = 'list')
|
39
|
+
response = @client.post 'list', path, params
|
43
40
|
result ? response[result] : response
|
44
41
|
end
|
45
|
-
|
46
42
|
end
|
47
|
-
|
48
43
|
end
|
49
44
|
end
|
50
45
|
end
|
@@ -1,54 +1,49 @@
|
|
1
1
|
module Pardot
|
2
2
|
module Objects
|
3
|
-
|
4
3
|
module Opportunities
|
5
|
-
|
6
4
|
def opportunities
|
7
5
|
@opportunities ||= Opportunities.new self
|
8
6
|
end
|
9
|
-
|
7
|
+
|
10
8
|
class Opportunities
|
11
|
-
|
12
|
-
def initialize client
|
9
|
+
def initialize(client)
|
13
10
|
@client = client
|
14
11
|
end
|
15
|
-
|
16
|
-
def query
|
17
|
-
result = get
|
18
|
-
result[
|
12
|
+
|
13
|
+
def query(params)
|
14
|
+
result = get '/do/query', params, 'result'
|
15
|
+
result['total_results'] = result['total_results'].to_i if result['total_results']
|
19
16
|
result
|
20
17
|
end
|
21
|
-
|
22
|
-
def create_by_email
|
18
|
+
|
19
|
+
def create_by_email(email, params = {})
|
23
20
|
post "/do/create/prospect_email/#{email}", params
|
24
21
|
end
|
25
|
-
|
26
|
-
def create_by_id
|
22
|
+
|
23
|
+
def create_by_id(prospect_id, params = {})
|
27
24
|
post "/do/create/prospect_id/#{prospect_id}", params
|
28
25
|
end
|
29
|
-
|
30
|
-
def read_by_id
|
26
|
+
|
27
|
+
def read_by_id(id, params = {})
|
31
28
|
post "/do/read/id/#{id}", params
|
32
29
|
end
|
33
|
-
|
34
|
-
def update_by_id
|
30
|
+
|
31
|
+
def update_by_id(id, params = {})
|
35
32
|
post "/do/update/id/#{id}", params
|
36
33
|
end
|
37
|
-
|
34
|
+
|
38
35
|
protected
|
39
|
-
|
40
|
-
def get
|
41
|
-
response = @client.get
|
36
|
+
|
37
|
+
def get(path, params = {}, result = 'opportunity')
|
38
|
+
response = @client.get 'opportunity', path, params
|
42
39
|
result ? response[result] : response
|
43
40
|
end
|
44
|
-
|
45
|
-
def post
|
46
|
-
response = @client.post
|
41
|
+
|
42
|
+
def post(path, params = {}, result = 'opportunity')
|
43
|
+
response = @client.post 'opportunity', path, params
|
47
44
|
result ? response[result] : response
|
48
45
|
end
|
49
|
-
|
50
46
|
end
|
51
|
-
|
52
47
|
end
|
53
48
|
end
|
54
49
|
end
|
@@ -6,7 +6,6 @@ module Pardot
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class ProspectAccounts
|
9
|
-
|
10
9
|
def initialize(client)
|
11
10
|
@client = client
|
12
11
|
end
|
@@ -18,18 +17,18 @@ module Pardot
|
|
18
17
|
result
|
19
18
|
end
|
20
19
|
|
21
|
-
def describe(params={})
|
20
|
+
def describe(params = {})
|
22
21
|
post('/do/describe', params)
|
23
22
|
end
|
24
23
|
|
25
|
-
def create(params={})
|
24
|
+
def create(params = {})
|
26
25
|
post('/do/create', params)
|
27
26
|
end
|
28
27
|
|
29
28
|
# read_by_id
|
30
29
|
# update_by_id
|
31
|
-
[
|
32
|
-
define_method(verb) do |id, params={}|
|
30
|
+
%i[read update].each do |verb|
|
31
|
+
define_method(verb) do |id, params = {}|
|
33
32
|
post(api_url(verb, 'id', id), params)
|
34
33
|
end
|
35
34
|
end
|
@@ -40,12 +39,12 @@ module Pardot
|
|
40
39
|
"/do/#{verb}/#{direct_to}/#{value}"
|
41
40
|
end
|
42
41
|
|
43
|
-
def get(path, params={}, result='prospectAccount')
|
42
|
+
def get(path, params = {}, result = 'prospectAccount')
|
44
43
|
response = @client.get('prospectAccount', path, params)
|
45
44
|
result ? response[result] : response
|
46
45
|
end
|
47
46
|
|
48
|
-
def post(path, params={}, result='prospectAccount')
|
47
|
+
def post(path, params = {}, result = 'prospectAccount')
|
49
48
|
response = @client.post('prospectAccount', path, params)
|
50
49
|
result ? response[result] : response
|
51
50
|
end
|
@@ -3,109 +3,105 @@ require 'cgi'
|
|
3
3
|
module Pardot
|
4
4
|
module Objects
|
5
5
|
module Prospects
|
6
|
-
|
7
6
|
def prospects
|
8
7
|
@prospects ||= Prospects.new self
|
9
8
|
end
|
10
9
|
|
11
10
|
class Prospects
|
12
|
-
|
13
|
-
def initialize client
|
11
|
+
def initialize(client)
|
14
12
|
@client = client
|
15
13
|
end
|
16
14
|
|
17
|
-
def query
|
18
|
-
result = get
|
19
|
-
result[
|
15
|
+
def query(search_criteria)
|
16
|
+
result = get '/do/query', search_criteria, 'result'
|
17
|
+
result['total_results'] = result['total_results'].to_i if result['total_results']
|
20
18
|
result
|
21
19
|
end
|
22
20
|
|
23
|
-
def assign_by_email
|
21
|
+
def assign_by_email(email, params)
|
24
22
|
post "/do/assign/email/#{CGI.escape(email)}", params
|
25
23
|
end
|
26
24
|
|
27
|
-
def assign_by_id
|
25
|
+
def assign_by_id(id, params)
|
28
26
|
post "/do/assign/id/#{CGI.escape(id)}", params
|
29
27
|
end
|
30
28
|
|
31
|
-
def assign_by_fid
|
29
|
+
def assign_by_fid(fid, params)
|
32
30
|
post "/do/assign/fid/#{CGI.escape(fid)}", params
|
33
31
|
end
|
34
32
|
|
35
|
-
def create
|
33
|
+
def create(email, params = {})
|
36
34
|
post "/do/create/email/#{CGI.escape(email)}", params
|
37
35
|
end
|
38
36
|
|
39
|
-
def delete_by_id
|
37
|
+
def delete_by_id(id, params = {})
|
40
38
|
post "/do/delete/id/#{CGI.escape(id)}", params
|
41
39
|
end
|
42
40
|
|
43
|
-
def delete_by_fid
|
41
|
+
def delete_by_fid(fid, params = {})
|
44
42
|
post "/do/delete/fid/#{CGI.escape(fid)}", params
|
45
43
|
end
|
46
44
|
|
47
|
-
def read_by_email
|
45
|
+
def read_by_email(email, params = {})
|
48
46
|
post "/do/read/email/#{CGI.escape(email)}", params
|
49
47
|
end
|
50
48
|
|
51
|
-
def read_by_id
|
49
|
+
def read_by_id(id, params = {})
|
52
50
|
post "/do/read/id/#{CGI.escape(id)}", params
|
53
51
|
end
|
54
52
|
|
55
|
-
def read_by_fid
|
53
|
+
def read_by_fid(fid, params = {})
|
56
54
|
post "/do/read/fid/#{CGI.escape(fid)}", params
|
57
55
|
end
|
58
56
|
|
59
|
-
def unassign_by_email
|
57
|
+
def unassign_by_email(email, params = {})
|
60
58
|
post "/do/unassign/email/#{CGI.escape(email)}", params
|
61
59
|
end
|
62
60
|
|
63
|
-
def unassign_by_id
|
61
|
+
def unassign_by_id(id, params = {})
|
64
62
|
post "/do/unassign/id/#{CGI.escape(id)}", params
|
65
63
|
end
|
66
64
|
|
67
|
-
def unassign_by_fid
|
65
|
+
def unassign_by_fid(fid, params = {})
|
68
66
|
post "/do/unassign/fid/#{CGI.escape(fid)}", params
|
69
67
|
end
|
70
68
|
|
71
|
-
def update_by_email
|
69
|
+
def update_by_email(email, params = {})
|
72
70
|
post "/do/update/email/#{CGI.escape(email)}", params
|
73
71
|
end
|
74
72
|
|
75
|
-
def update_by_id
|
73
|
+
def update_by_id(id, params = {})
|
76
74
|
post "/do/update/id/#{CGI.escape(id)}", params
|
77
75
|
end
|
78
76
|
|
79
|
-
def update_by_fid
|
77
|
+
def update_by_fid(fid, params = {})
|
80
78
|
post "/do/update/fid/#{CGI.escape(fid)}", params
|
81
79
|
end
|
82
80
|
|
83
|
-
def upsert_by_email
|
81
|
+
def upsert_by_email(email, params = {})
|
84
82
|
post "/do/upsert/email/#{CGI.escape(email)}", params
|
85
83
|
end
|
86
84
|
|
87
|
-
def upsert_by_id
|
85
|
+
def upsert_by_id(id, params = {})
|
88
86
|
post "/do/upsert/id/#{CGI.escape(id)}", params
|
89
87
|
end
|
90
88
|
|
91
|
-
def upsert_by_fid
|
89
|
+
def upsert_by_fid(fid, params = {})
|
92
90
|
post "/do/upsert/fid/#{CGI.escape(fid)}", params
|
93
91
|
end
|
94
92
|
|
95
93
|
protected
|
96
94
|
|
97
|
-
def get
|
98
|
-
response = @client.get
|
95
|
+
def get(path, params = {}, result = 'prospect')
|
96
|
+
response = @client.get 'prospect', path, params
|
99
97
|
result ? response[result] : response
|
100
98
|
end
|
101
99
|
|
102
|
-
def post
|
103
|
-
response = @client.post
|
100
|
+
def post(path, params = {}, result = 'prospect')
|
101
|
+
response = @client.post 'prospect', path, params
|
104
102
|
result ? response[result] : response
|
105
103
|
end
|
106
|
-
|
107
104
|
end
|
108
|
-
|
109
105
|
end
|
110
106
|
end
|
111
107
|
end
|
data/lib/pardot/objects/users.rb
CHANGED
@@ -1,45 +1,41 @@
|
|
1
1
|
module Pardot
|
2
2
|
module Objects
|
3
3
|
module Users
|
4
|
-
|
5
4
|
def users
|
6
5
|
@users ||= Users.new self
|
7
6
|
end
|
8
|
-
|
7
|
+
|
9
8
|
class Users
|
10
|
-
|
11
|
-
def initialize client
|
9
|
+
def initialize(client)
|
12
10
|
@client = client
|
13
11
|
end
|
14
|
-
|
15
|
-
def query
|
16
|
-
result = get
|
17
|
-
result[
|
12
|
+
|
13
|
+
def query(params)
|
14
|
+
result = get '/do/query', params, 'result'
|
15
|
+
result['total_results'] = result['total_results'].to_i if result['total_results']
|
18
16
|
result
|
19
17
|
end
|
20
|
-
|
21
|
-
def read_by_email
|
18
|
+
|
19
|
+
def read_by_email(email, params = {})
|
22
20
|
post "/do/read/email/#{email}", params
|
23
21
|
end
|
24
|
-
|
25
|
-
def read_by_id
|
22
|
+
|
23
|
+
def read_by_id(id, params = {})
|
26
24
|
post "/do/read/id/#{id}", params
|
27
25
|
end
|
28
|
-
|
26
|
+
|
29
27
|
protected
|
30
|
-
|
31
|
-
def get
|
32
|
-
response = @client.get
|
28
|
+
|
29
|
+
def get(path, params = {}, result = 'user')
|
30
|
+
response = @client.get 'user', path, params
|
33
31
|
result ? response[result] : response
|
34
32
|
end
|
35
|
-
|
36
|
-
def post
|
37
|
-
response = @client.post
|
33
|
+
|
34
|
+
def post(path, params = {}, result = 'user')
|
35
|
+
response = @client.post 'user', path, params
|
38
36
|
result ? response[result] : response
|
39
37
|
end
|
40
|
-
|
41
38
|
end
|
42
|
-
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|