ruby-pardot 1.2.0 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33f862629251e35bc4abea0f50af5fbd34e83d2b561529107dda17f5c5fe5bf8
4
- data.tar.gz: 773061f478695e10e26c2f17ea36ba1a81ee2a241797426e1581a02ac59f24d1
3
+ metadata.gz: 1e4f6eb36b94bd50088dc0d06fe3b229481a7e8299f7a16c265fef8ffb418d72
4
+ data.tar.gz: 64c099f9b5477692b9a53f8b727f7775c8a29128963a816d8537dbc790f95b7c
5
5
  SHA512:
6
- metadata.gz: 439fc348827c87938b93035b7b1d6bcdb6a043e49897041b9b45029b9f95dd3b562db3a3cad345b58dde4b9bb0c21823d311f18c90d4f593562b8d7e695f7f29
7
- data.tar.gz: b63c4c6083d3c86d2204ea43638a3133bf619a746d5c355d29a47c4c2dd326a68e1a5a77322183655829be0d0959b335a67f816a5bd7ad30609ef23b7b4325e3
6
+ metadata.gz: ac9660fa6856fabb229fc9e4f2c29ce8261c0f0b2cdf7026662f5f1d1ebfae42ea149c515f168aa7b9b85f6cea4cdfb5851afc61c37ebb1c436b147e1181c9e5
7
+ data.tar.gz: 4bacace091e84ee091fcabaf744184720a4d8488b8f5caa365c325bc3e5eec88287c2b460945c13183eed88ccaf835bec86a2bf0054694ec236e6c68383f26e4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-pardot (1.2.0)
4
+ ruby-pardot (1.3.0)
5
5
  crack (= 0.4.3)
6
6
  httparty (= 0.13.1)
7
7
 
@@ -25,7 +25,7 @@ GEM
25
25
  rspec-expectations (2.5.0)
26
26
  diff-lcs (~> 1.1.2)
27
27
  rspec-mocks (2.5.0)
28
- safe_yaml (1.0.4)
28
+ safe_yaml (1.0.5)
29
29
 
30
30
  PLATFORMS
31
31
  ruby
@@ -4,7 +4,8 @@ module Pardot
4
4
  def get object, path, params = {}, num_retries = 0
5
5
  smooth_params object, params
6
6
  full_path = fullpath object, path
7
- check_response self.class.get(full_path, :query => params)
7
+ headers = create_auth_header object
8
+ check_response self.class.get(full_path, :query => params, :headers => headers)
8
9
 
9
10
  rescue Pardot::ExpiredApiKeyError => e
10
11
  handle_expired_api_key :get, object, path, params, num_retries, e
@@ -16,7 +17,8 @@ module Pardot
16
17
  def post object, path, params = {}, num_retries = 0, bodyParams = {}
17
18
  smooth_params object, params
18
19
  full_path = fullpath object, path
19
- check_response self.class.post(full_path, :query => params, :body => bodyParams)
20
+ headers = create_auth_header object
21
+ check_response self.class.post(full_path, :query => params, :body => bodyParams, :headers => headers)
20
22
 
21
23
  rescue Pardot::ExpiredApiKeyError => e
22
24
  handle_expired_api_key :post, object, path, params, num_retries, e
@@ -39,7 +41,12 @@ module Pardot
39
41
  return if object == "login"
40
42
 
41
43
  authenticate unless authenticated?
42
- params.merge! :user_key => @user_key, :api_key => @api_key, :format => @format
44
+ params.merge! :format => @format
45
+ end
46
+
47
+ def create_auth_header object
48
+ return if object == "login"
49
+ { :Authorization => "Pardot api_key=#{@api_key}, user_key=#{@user_key}" }
43
50
  end
44
51
 
45
52
  def check_response http_response
@@ -1,3 +1,3 @@
1
1
  module Pardot
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.name = "ruby-pardot"
6
6
  s.version = Pardot::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Dan Cunning", "Chris Little", "Justin Roberts"]
9
- s.email = ["support@pardot.com", "chris.little@salesforce.com", "justin.roberts@salesforce.com"]
8
+ s.authors = ["Dan Cunning"]
9
+ s.email = ["support@pardot.com"]
10
10
  s.homepage = "http://github.com/pardot/ruby-pardot"
11
11
  s.summary = "Library for interacting with the Pardot API"
12
12
  s.description = "Library for interacting with the Pardot API"
@@ -18,7 +18,7 @@ describe Pardot::Http do
18
18
  end
19
19
 
20
20
  it "should notice errors and raise them as Pardot::ResponseError" do
21
- fake_get "/api/foo/version/3/bar?api_key=my_api_key&format=simple&user_key=bar",
21
+ fake_get "/api/foo/version/3/bar?format=simple",
22
22
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)
23
23
 
24
24
  lambda { get }.should raise_error(Pardot::ResponseError)
@@ -31,7 +31,7 @@ describe Pardot::Http do
31
31
  end
32
32
 
33
33
  it "should call handle_expired_api_key when the api key expires" do
34
- fake_get "/api/foo/version/3/bar?api_key=my_api_key&format=simple&user_key=bar",
34
+ fake_get "/api/foo/version/3/bar?format=simple",
35
35
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)
36
36
 
37
37
  @client.should_receive(:handle_expired_api_key)
@@ -47,7 +47,7 @@ describe Pardot::Http do
47
47
  end
48
48
 
49
49
  it "should notice errors and raise them as Pardot::ResponseError" do
50
- fake_post "/api/foo/version/3/bar?api_key=my_api_key&format=simple&user_key=bar",
50
+ fake_post "/api/foo/version/3/bar?format=simple",
51
51
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)
52
52
 
53
53
  lambda { post }.should raise_error(Pardot::ResponseError)
@@ -60,7 +60,7 @@ describe Pardot::Http do
60
60
  end
61
61
 
62
62
  it "should call handle_expired_api_key when the api key expires" do
63
- fake_post "/api/foo/version/3/bar?api_key=my_api_key&format=simple&user_key=bar",
63
+ fake_post "/api/foo/version/3/bar?format=simple",
64
64
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)
65
65
 
66
66
  @client.should_receive(:handle_expired_api_key)
@@ -77,7 +77,7 @@ describe Pardot::Http do
77
77
  end
78
78
 
79
79
  it "should notice errors and raise them as Pardot::ResponseError" do
80
- fake_get "/api/foo/version/4/bar?api_key=my_api_key&format=simple&user_key=bar",
80
+ fake_get "/api/foo/version/4/bar?format=simple",
81
81
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)
82
82
 
83
83
  lambda { get }.should raise_error(Pardot::ResponseError)
@@ -90,7 +90,7 @@ describe Pardot::Http do
90
90
  end
91
91
 
92
92
  it "should call handle_expired_api_key when the api key expires" do
93
- fake_get "/api/foo/version/4/bar?api_key=my_api_key&format=simple&user_key=bar",
93
+ fake_get "/api/foo/version/4/bar?format=simple",
94
94
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)
95
95
 
96
96
  @client.should_receive(:handle_expired_api_key)
@@ -107,7 +107,7 @@ describe Pardot::Http do
107
107
  end
108
108
 
109
109
  it "should notice errors and raise them as Pardot::ResponseError" do
110
- fake_post "/api/foo/version/4/bar?api_key=my_api_key&format=simple&user_key=bar",
110
+ fake_post "/api/foo/version/4/bar?format=simple",
111
111
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Login failed</err>\n</rsp>\n)
112
112
 
113
113
  lambda { post }.should raise_error(Pardot::ResponseError)
@@ -120,7 +120,7 @@ describe Pardot::Http do
120
120
  end
121
121
 
122
122
  it "should call handle_expired_api_key when the api key expires" do
123
- fake_post "/api/foo/version/4/bar?api_key=my_api_key&format=simple&user_key=bar",
123
+ fake_post "/api/foo/version/4/bar?format=simple",
124
124
  %(?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="fail" version="1.0">\n <err code="15">Invalid API key or user key</err>\n</rsp>\n)
125
125
 
126
126
  @client.should_receive(:handle_expired_api_key)
@@ -19,18 +19,21 @@ describe Pardot::Objects::Emails do
19
19
  end
20
20
 
21
21
  it "should take in the email ID" do
22
- fake_get "/api/email/version/3/do/read/id/12?user_key=bar&api_key=my_api_key&format=simple", sample_response
22
+ fake_get "/api/email/version/3/do/read/id/12?format=simple", sample_response
23
23
  @client.emails.read_by_id(12).should == {"name" => "My Email"}
24
+ assert_authorization_header
24
25
  end
25
26
 
26
27
  it 'should send to a prospect' do
27
- fake_post '/api/email/version/3/do/send/prospect_id/42?campaign_id=765&email_template_id=86&user_key=bar&api_key=my_api_key&format=simple', sample_response
28
+ fake_post '/api/email/version/3/do/send/prospect_id/42?campaign_id=765&email_template_id=86&format=simple', sample_response
28
29
  @client.emails.send_to_prospect(42, :campaign_id => 765, :email_template_id => 86).should == {"name" => "My Email"}
30
+ assert_authorization_header
29
31
  end
30
32
 
31
33
  it 'should send to a list' do
32
- fake_post '/api/email/version/3/do/send?email_template_id=200&list_ids[]=235&campaign_id=654&user_key=bar&api_key=my_api_key&format=simple', sample_response
34
+ fake_post '/api/email/version/3/do/send?email_template_id=200&list_ids[]=235&campaign_id=654&format=simple', sample_response
33
35
  @client.emails.send_to_list(:email_template_id => 200, 'list_ids[]' => 235, :campaign_id => 654).should == {"name" => "My Email"}
36
+ assert_authorization_header
34
37
  end
35
38
 
36
39
  end
@@ -27,13 +27,14 @@ describe Pardot::Objects::Lists do
27
27
  end
28
28
 
29
29
  it "should take in some arguments" do
30
- fake_get "/api/list/version/3/do/query?api_key=my_api_key&id_greater_than=200&format=simple&user_key=bar", sample_results
30
+ fake_get "/api/list/version/3/do/query?id_greater_than=200&format=simple", sample_results
31
31
 
32
32
  @client.lists.query(:id_greater_than => 200).should == {"total_results" => 2,
33
33
  "list"=>[
34
34
  {"name"=>"Asdf List"},
35
35
  {"name"=>"Qwerty List"}
36
36
  ]}
37
+ assert_authorization_header
37
38
  end
38
39
 
39
40
  end
@@ -29,13 +29,14 @@ describe Pardot::Objects::Opportunities do
29
29
  end
30
30
 
31
31
  it "should take in some arguments" do
32
- fake_get "/api/opportunity/version/3/do/query?api_key=my_api_key&id_greater_than=200&format=simple&user_key=bar", sample_results
32
+ fake_get "/api/opportunity/version/3/do/query?id_greater_than=200&format=simple", sample_results
33
33
 
34
34
  @client.opportunities.query(:id_greater_than => 200).should == {"total_results" => 2,
35
35
  "opportunity"=>[
36
36
  {"type"=>"Great", "name"=>"Jim"},
37
37
  {"type"=>"Good", "name"=>"Sue"}
38
38
  ]}
39
+ assert_authorization_header
39
40
  end
40
41
 
41
42
  end
@@ -53,10 +54,11 @@ describe Pardot::Objects::Opportunities do
53
54
  end
54
55
 
55
56
  it "should return the prospect" do
56
- fake_post "/api/opportunity/version/3/do/create/prospect_email/user@test.com?type=Good&api_key=my_api_key&user_key=bar&format=simple&name=Jim", sample_results
57
+ fake_post "/api/opportunity/version/3/do/create/prospect_email/user@test.com?type=Good&format=simple&name=Jim", sample_results
57
58
 
58
59
  @client.opportunities.create_by_email("user@test.com", :name => "Jim", :type => "Good").should == {"name"=>"Jim", "type"=>"Good"}
59
-
60
+
61
+ assert_authorization_header
60
62
  end
61
63
 
62
64
  end
@@ -24,13 +24,14 @@ describe Pardot::Objects::ProspectAccounts do
24
24
  end
25
25
 
26
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
27
+ fake_get "/api/prospectAccount/version/3/do/query?assigned=true&format=simple", sample_results
28
28
 
29
29
  @client.prospect_accounts.query(:assigned => true).should == {'total_results' => 2,
30
30
  'prospectAccount'=>[
31
31
  {'name'=>'Spaceships R Us'},
32
32
  {'name'=>'Monsters Inc'}
33
33
  ]}
34
+ assert_authorization_header
34
35
  end
35
36
 
36
37
  end
@@ -47,9 +48,10 @@ describe Pardot::Objects::ProspectAccounts do
47
48
  end
48
49
 
49
50
  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
+ fake_post '/api/prospectAccount/version/3/do/read/id/1234?assigned=true&format=simple', sample_results
51
52
 
52
53
  @client.prospect_accounts.read('1234', :assigned => true).should == {'id' => '1234', 'name' => 'SupaDupaPanda' }
54
+ assert_authorization_header
53
55
  end
54
56
 
55
57
  end
@@ -67,10 +69,10 @@ describe Pardot::Objects::ProspectAccounts do
67
69
  end
68
70
 
69
71
  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
72
+ fake_post '/api/prospectAccount/version/3/do/create?format=simple&name=SuperPanda', sample_results
71
73
 
72
74
  @client.prospect_accounts.create(:name => 'SuperPanda').should == {"name"=>"SuperPanda"}
73
-
75
+ assert_authorization_header
74
76
  end
75
77
 
76
78
  end
@@ -26,13 +26,14 @@ describe Pardot::Objects::Prospects do
26
26
  end
27
27
 
28
28
  it "should take in some arguments" do
29
- fake_get "/api/prospect/version/3/do/query?assigned=true&format=simple&user_key=bar&api_key=my_api_key", sample_results
29
+ fake_get "/api/prospect/version/3/do/query?assigned=true&format=simple", sample_results
30
30
 
31
31
  @client.prospects.query(:assigned => true).should == {"total_results" => 2,
32
32
  "prospect"=>[
33
33
  {"last_name"=>"Smith", "first_name"=>"Jim"},
34
34
  {"last_name"=>"Green", "first_name"=>"Sue"}
35
35
  ]}
36
+ assert_authorization_header
36
37
  end
37
38
 
38
39
  end
@@ -50,10 +51,10 @@ describe Pardot::Objects::Prospects do
50
51
  end
51
52
 
52
53
  it "should return the prospect" do
53
- fake_post "/api/prospect/version/3/do/create/email/user@test.com?api_key=my_api_key&user_key=bar&format=simple&first_name=Jim", sample_results
54
+ fake_post "/api/prospect/version/3/do/create/email/user@test.com?format=simple&first_name=Jim", sample_results
54
55
 
55
56
  @client.prospects.create("user@test.com", :first_name => "Jim").should == {"last_name"=>"Smith", "first_name"=>"Jim"}
56
-
57
+ assert_authorization_header
57
58
  end
58
59
 
59
60
  end
@@ -29,13 +29,14 @@ describe Pardot::Objects::Users do
29
29
  end
30
30
 
31
31
  it "should take in some arguments" do
32
- fake_get "/api/user/version/3/do/query?api_key=my_api_key&user_key=bar&id_greater_than=200&format=simple", sample_results
32
+ fake_get "/api/user/version/3/do/query?id_greater_than=200&format=simple", sample_results
33
33
 
34
34
  @client.users.query(:id_greater_than => 200).should == {"total_results" => 2,
35
35
  "user"=>[
36
36
  {"email"=>"user@test.com", "first_name"=>"Jim"},
37
37
  {"email"=>"user@example.com", "first_name"=>"Sue"}
38
38
  ]}
39
+ assert_authorization_header
39
40
  end
40
41
 
41
42
  end
@@ -53,10 +54,10 @@ describe Pardot::Objects::Users do
53
54
  end
54
55
 
55
56
  it "should return the prospect" do
56
- fake_post "/api/user/version/3/do/read/email/user@test.com?api_key=my_api_key&user_key=bar&format=simple", sample_results
57
+ fake_post "/api/user/version/3/do/read/email/user@test.com?format=simple", sample_results
57
58
 
58
59
  @client.users.read_by_email("user@test.com").should == {"email"=>"user@example.com", "first_name"=>"Sue"}
59
-
60
+ assert_authorization_header
60
61
  end
61
62
 
62
63
  end
@@ -29,13 +29,14 @@ describe Pardot::Objects::VisitorActivities do
29
29
  end
30
30
 
31
31
  it "should take in some arguments" do
32
- fake_get "/api/visitorActivity/version/3/do/query?user_key=bar&api_key=my_api_key&id_greater_than=200&format=simple", sample_results
32
+ fake_get "/api/visitorActivity/version/3/do/query?id_greater_than=200&format=simple", sample_results
33
33
 
34
34
  @client.visitor_activities.query(:id_greater_than => 200).should == {"total_results" => 2,
35
35
  "visitorActivity"=>[
36
36
  {"type_name"=>"Read", "details"=>"Some details"},
37
37
  {"type_name"=>"Write", "details"=>"More details"}
38
38
  ]}
39
+ assert_authorization_header
39
40
  end
40
41
 
41
42
  end
@@ -53,10 +54,10 @@ describe Pardot::Objects::VisitorActivities do
53
54
  end
54
55
 
55
56
  it "should return the prospect" do
56
- fake_post "/api/visitorActivity/version/3/do/read/id/10?user_key=bar&api_key=my_api_key&format=simple", sample_results
57
+ fake_post "/api/visitorActivity/version/3/do/read/id/10?format=simple", sample_results
57
58
 
58
59
  @client.visitor_activities.read(10).should == {"details"=>"More details", "type_name"=>"Write"}
59
-
60
+ assert_authorization_header
60
61
  end
61
62
 
62
63
  end
@@ -29,13 +29,14 @@ describe Pardot::Objects::Visitors do
29
29
  end
30
30
 
31
31
  it "should take in some arguments" do
32
- fake_get "/api/visitor/version/3/do/query?api_key=my_api_key&user_key=bar&id_greater_than=200&format=simple", sample_results
32
+ fake_get "/api/visitor/version/3/do/query?id_greater_than=200&format=simple", sample_results
33
33
 
34
34
  @client.visitors.query(:id_greater_than => 200).should == {"total_results" => 2,
35
35
  "visitor"=>[
36
36
  {"browser"=>"Firefox", "language"=>"en"},
37
37
  {"browser"=>"Chrome", "language"=>"es"}
38
38
  ]}
39
+ assert_authorization_header
39
40
  end
40
41
 
41
42
  end
@@ -53,10 +54,10 @@ describe Pardot::Objects::Visitors do
53
54
  end
54
55
 
55
56
  it "should return the prospect" do
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
+ fake_post "/api/visitor/version/3/do/assign/id/10?type=Good&format=simple&name=Jim", sample_results
57
58
 
58
59
  @client.visitors.assign(10, :name => "Jim", :type => "Good").should == {"browser"=>"Chrome", "language"=>"es"}
59
-
60
+ assert_authorization_header
60
61
  end
61
62
 
62
63
  end
@@ -29,13 +29,14 @@ describe Pardot::Objects::Visits do
29
29
  end
30
30
 
31
31
  it "should take in some arguments" do
32
- fake_get "/api/visit/version/3/do/query?api_key=my_api_key&user_key=bar&id_greater_than=200&format=simple", sample_results
32
+ fake_get "/api/visit/version/3/do/query?id_greater_than=200&format=simple", sample_results
33
33
 
34
34
  @client.visits.query(:id_greater_than => 200).should == {"total_results" => 2,
35
35
  "visit"=>[
36
36
  {"duration_in_seconds"=>"50", "visitor_page_view_count"=>"3"},
37
37
  {"duration_in_seconds"=>"10", "visitor_page_view_count"=>"1"}
38
38
  ]}
39
+ assert_authorization_header
39
40
  end
40
41
 
41
42
  end
@@ -53,10 +54,10 @@ describe Pardot::Objects::Visits do
53
54
  end
54
55
 
55
56
  it "should return the prospect" do
56
- fake_post "/api/visit/version/3/do/read/id/10?user_key=bar&api_key=my_api_key&format=simple", sample_results
57
+ fake_post "/api/visit/version/3/do/read/id/10?format=simple", sample_results
57
58
 
58
59
  @client.visits.read(10).should == {"visitor_page_view_count"=>"1", "duration_in_seconds"=>"10"}
59
-
60
+ assert_authorization_header
60
61
  end
61
62
 
62
63
  end
@@ -12,3 +12,7 @@ end
12
12
  def fake_authenticate client, api_key
13
13
  client.api_key = api_key
14
14
  end
15
+
16
+ def assert_authorization_header
17
+ expect(FakeWeb.last_request[:authorization]).to eq('Pardot api_key=my_api_key, user_key=bar')
18
+ end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pardot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Cunning
8
- - Chris Little
9
- - Justin Roberts
10
8
  autorequire:
11
9
  bindir: bin
12
10
  cert_chain: []
13
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: crack
@@ -85,8 +83,6 @@ dependencies:
85
83
  description: Library for interacting with the Pardot API
86
84
  email:
87
85
  - support@pardot.com
88
- - chris.little@salesforce.com
89
- - justin.roberts@salesforce.com
90
86
  executables: []
91
87
  extensions: []
92
88
  extra_rdoc_files: []