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
@@ -0,0 +1,33 @@
|
|
1
|
+
module Pardot
|
2
|
+
module Objects
|
3
|
+
module CustomFields
|
4
|
+
def custom_fields
|
5
|
+
@custom_fields ||= CustomFields.new self
|
6
|
+
end
|
7
|
+
|
8
|
+
class CustomFields
|
9
|
+
def initialize(client)
|
10
|
+
@client = client
|
11
|
+
end
|
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']
|
16
|
+
result
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def get(path, params = {}, result = 'customField')
|
22
|
+
response = @client.get 'customField', path, params
|
23
|
+
result ? response[result] : response
|
24
|
+
end
|
25
|
+
|
26
|
+
def post(path, params = {}, result = 'user')
|
27
|
+
response = @client.post 'customField', path, params
|
28
|
+
result ? response[result] : response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -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
|
@@ -1,109 +1,107 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module Pardot
|
2
4
|
module Objects
|
3
5
|
module Prospects
|
4
|
-
|
5
6
|
def prospects
|
6
7
|
@prospects ||= Prospects.new self
|
7
8
|
end
|
8
|
-
|
9
|
+
|
9
10
|
class Prospects
|
10
|
-
|
11
|
-
def initialize client
|
11
|
+
def initialize(client)
|
12
12
|
@client = client
|
13
13
|
end
|
14
|
-
|
15
|
-
def query
|
16
|
-
result = get
|
17
|
-
result[
|
14
|
+
|
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']
|
18
18
|
result
|
19
19
|
end
|
20
|
-
|
21
|
-
def assign_by_email
|
22
|
-
post "/do/assign/email/#{email}", params
|
20
|
+
|
21
|
+
def assign_by_email(email, params)
|
22
|
+
post "/do/assign/email/#{CGI.escape(email)}", params
|
23
23
|
end
|
24
|
-
|
25
|
-
def assign_by_id
|
26
|
-
post "/do/assign/id/#{id}", params
|
24
|
+
|
25
|
+
def assign_by_id(id, params)
|
26
|
+
post "/do/assign/id/#{CGI.escape(id)}", params
|
27
27
|
end
|
28
|
-
|
29
|
-
def assign_by_fid
|
30
|
-
post "/do/assign/fid/#{fid}", params
|
28
|
+
|
29
|
+
def assign_by_fid(fid, params)
|
30
|
+
post "/do/assign/fid/#{CGI.escape(fid)}", params
|
31
31
|
end
|
32
|
-
|
33
|
-
def create
|
34
|
-
post "/do/create/email/#{email}", params
|
32
|
+
|
33
|
+
def create(email, params = {})
|
34
|
+
post "/do/create/email/#{CGI.escape(email)}", params
|
35
35
|
end
|
36
|
-
|
37
|
-
def delete_by_id
|
38
|
-
post "/do/delete/id/#{id}", params
|
36
|
+
|
37
|
+
def delete_by_id(id, params = {})
|
38
|
+
post "/do/delete/id/#{CGI.escape(id)}", params
|
39
39
|
end
|
40
|
-
|
41
|
-
def delete_by_fid
|
42
|
-
post "/do/delete/fid/#{fid}", params
|
40
|
+
|
41
|
+
def delete_by_fid(fid, params = {})
|
42
|
+
post "/do/delete/fid/#{CGI.escape(fid)}", params
|
43
43
|
end
|
44
|
-
|
45
|
-
def read_by_email
|
46
|
-
post "/do/read/email/#{email}", params
|
44
|
+
|
45
|
+
def read_by_email(email, params = {})
|
46
|
+
post "/do/read/email/#{CGI.escape(email)}", params
|
47
47
|
end
|
48
|
-
|
49
|
-
def read_by_id
|
50
|
-
post "/do/read/id/#{id}", params
|
48
|
+
|
49
|
+
def read_by_id(id, params = {})
|
50
|
+
post "/do/read/id/#{CGI.escape(id)}", params
|
51
51
|
end
|
52
|
-
|
53
|
-
def read_by_fid
|
54
|
-
post "/do/read/fid/#{fid}", params
|
52
|
+
|
53
|
+
def read_by_fid(fid, params = {})
|
54
|
+
post "/do/read/fid/#{CGI.escape(fid)}", params
|
55
55
|
end
|
56
|
-
|
57
|
-
def unassign_by_email
|
58
|
-
post "/do/unassign/email/#{email}", params
|
56
|
+
|
57
|
+
def unassign_by_email(email, params = {})
|
58
|
+
post "/do/unassign/email/#{CGI.escape(email)}", params
|
59
59
|
end
|
60
|
-
|
61
|
-
def unassign_by_id
|
62
|
-
post "/do/unassign/id/#{id}", params
|
60
|
+
|
61
|
+
def unassign_by_id(id, params = {})
|
62
|
+
post "/do/unassign/id/#{CGI.escape(id)}", params
|
63
63
|
end
|
64
|
-
|
65
|
-
def unassign_by_fid
|
66
|
-
post "/do/unassign/fid/#{fid}", params
|
64
|
+
|
65
|
+
def unassign_by_fid(fid, params = {})
|
66
|
+
post "/do/unassign/fid/#{CGI.escape(fid)}", params
|
67
67
|
end
|
68
|
-
|
69
|
-
def update_by_email
|
70
|
-
post "/do/update/email/#{email}", params
|
68
|
+
|
69
|
+
def update_by_email(email, params = {})
|
70
|
+
post "/do/update/email/#{CGI.escape(email)}", params
|
71
71
|
end
|
72
|
-
|
73
|
-
def update_by_id
|
74
|
-
post "/do/update/id/#{id}", params
|
72
|
+
|
73
|
+
def update_by_id(id, params = {})
|
74
|
+
post "/do/update/id/#{CGI.escape(id)}", params
|
75
75
|
end
|
76
|
-
|
77
|
-
def update_by_fid
|
78
|
-
post "/do/update/fid/#{fid}", params
|
76
|
+
|
77
|
+
def update_by_fid(fid, params = {})
|
78
|
+
post "/do/update/fid/#{CGI.escape(fid)}", params
|
79
79
|
end
|
80
|
-
|
81
|
-
def upsert_by_email
|
82
|
-
post "/do/upsert/email/#{email}", params
|
80
|
+
|
81
|
+
def upsert_by_email(email, params = {})
|
82
|
+
post "/do/upsert/email/#{CGI.escape(email)}", params
|
83
83
|
end
|
84
|
-
|
85
|
-
def upsert_by_id
|
86
|
-
post "/do/upsert/id/#{id}", params
|
84
|
+
|
85
|
+
def upsert_by_id(id, params = {})
|
86
|
+
post "/do/upsert/id/#{CGI.escape(id)}", params
|
87
87
|
end
|
88
|
-
|
89
|
-
def upsert_by_fid
|
90
|
-
post "/do/upsert/fid/#{fid}", params
|
88
|
+
|
89
|
+
def upsert_by_fid(fid, params = {})
|
90
|
+
post "/do/upsert/fid/#{CGI.escape(fid)}", params
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
protected
|
94
|
-
|
95
|
-
def get
|
96
|
-
response = @client.get
|
94
|
+
|
95
|
+
def get(path, params = {}, result = 'prospect')
|
96
|
+
response = @client.get 'prospect', path, params
|
97
97
|
result ? response[result] : response
|
98
98
|
end
|
99
|
-
|
100
|
-
def post
|
101
|
-
response = @client.post
|
99
|
+
|
100
|
+
def post(path, params = {}, result = 'prospect')
|
101
|
+
response = @client.post 'prospect', path, params
|
102
102
|
result ? response[result] : response
|
103
103
|
end
|
104
|
-
|
105
104
|
end
|
106
|
-
|
107
105
|
end
|
108
106
|
end
|
109
107
|
end
|