hubspot-api-ruby 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adea84341de555a5a7b9d83e03f8aa1013484015ad17d151f4876e9f2bd02293
4
- data.tar.gz: 16380d38efaea5c290d2d3b969e76b7501f81beab80a2bec1b8dee6209c5bc57
3
+ metadata.gz: 4aa748bc77ade29ff96016950aa3f3d8d9bbb309167b200319798d9edf8664bc
4
+ data.tar.gz: f09d8a29a3dbbcaa18071670e46d4c10c6727731409bbf4a7eee5099d6fd15e2
5
5
  SHA512:
6
- metadata.gz: 3ca148e0b2648da567d90d312cf979b1bcf8f840ed56393623d8c4cdb2aa0a7d1fe711721fd0828d5062837765280dc4f39719742cd124313bb9e15d31371e89
7
- data.tar.gz: b3f6ac7fd1468a9caf227bd37f7cbe8316328ee88008e0305d891fa7c11478e9161425ababe9eb93416684284e39f2839f468e5667d6e9ce05e96c6c807b617c
6
+ metadata.gz: ac1c6faae15a4569c92d8061a270f7b55aad7c64eaf2f16bc057b31312204164771600a5ebb511a0d7e0977123baf65b22125f69832dc6b2af63637bb4689814
7
+ data.tar.gz: 37b874280272f531177bf348d038b5b6e935f2a4edefeef1c1c7d4e5e68c2613047a75ea782daa412053fb8f50c312d6a27d5f264509f758cd6eb82abf1afe8d
data/README.md CHANGED
@@ -30,16 +30,16 @@ Authentication docs].
30
30
  Below is a complete list of configuration options with the default values:
31
31
  ```ruby
32
32
  Hubspot.configure({
33
- hapikey: <HAPIKEY>,
33
+ access_token: <ACCESS_TOKEN>,
34
34
  base_url: "https://api.hubapi.com",
35
35
  portal_id: <PORTAL_ID>,
36
36
  logger: Logger.new(nil),
37
- access_token: <ACCESS_TOKEN>,
38
37
  client_id: <CLIENT_ID>,
39
38
  client_secret: <CLIENT_SECRET>,
40
39
  redirect_uri: <REDIRECT_URI>,
41
40
  read_timeout: nil, # or :timeout to set read_timeout and open_timeout
42
41
  open_timeout: nil,
42
+ hapikey: <HAPIKEY>,
43
43
  })
44
44
  ```
45
45
 
@@ -50,15 +50,20 @@ environment.
50
50
  [HubSpot API Authentication Docs]: https://developers.hubspot.com/docs/methods/auth/oauth-overview
51
51
  [HubSpot Developer Tools]: https://developers.hubspot.com/docs/devtools
52
52
 
53
- ## Authentication with an API key
53
+ ## Authentication with a private app access token
54
54
 
55
- To set the HubSpot API key, aka `hapikey`, run the following:
55
+ To set the HubSpot access token, run the following:
56
56
  ```ruby
57
- Hubspot.configure(hapikey: "YOUR_API_KEY")
57
+ Hubspot.configure(access_token: 'YOUR_ACCESS_TOKEN')
58
58
  ```
59
59
 
60
- If you have a HubSpot account, you can find your API key by logging in and
61
- visiting: https://app.hubspot.com/keys/get
60
+ Note: some APIs require the portal ID to be set.
61
+
62
+ ```ruby
63
+ Hubspot.configure(access_token: 'YOUR_ACCESS_TOKEN', portal_id: 'YOUR_PORTAL_ID')
64
+ ```
65
+
66
+ [To learn how to create and manage private apps and access tokens, click here.](https://developers.hubspot.com/docs/api/private-apps)
62
67
 
63
68
  ## Authentication with OAuth 2.0
64
69
 
@@ -111,6 +116,18 @@ Hubspot::OAuth.refresh(refresh_token)
111
116
 
112
117
  At this time, OAuth tokens are configured globally rather than on a per-connection basis.
113
118
 
119
+ ## Authentication with an API key
120
+
121
+ NOTE: API keys are deprecated. [Read more here](https://developers.hubspot.com/changelog/upcoming-api-key-sunset) and [find out how to migrate to private apps there](https://developers.hubspot.com/docs/api/migrate-an-api-key-integration-to-a-private-app).
122
+
123
+ To set the HubSpot API key, aka `hapikey`, run the following:
124
+ ```ruby
125
+ Hubspot.configure(hapikey: "YOUR_API_KEY")
126
+ ```
127
+
128
+ If you have a HubSpot account, you can find your API key by logging in and
129
+ visiting: https://app.hubspot.com/keys/get
130
+
114
131
  ## Usage
115
132
 
116
133
  Classes have been created that map to Hubspot resource types and attempt to abstract away as much of the API specific details as possible. These classes generally follow the [ActiveRecord](https://en.wikipedia.org/wiki/Active_record_pattern) pattern and general Ruby conventions. Anyone familiar with [Ruby On Rails](https://rubyonrails.org/) should find this API closely maps with familiar concepts.
@@ -147,10 +164,11 @@ By default, the VCR recording mode is set to `:none`, which allows recorded
147
164
  requests to be re-played but raises for any new request. This prevents the test
148
165
  suite from issuing unexpected HTTP requests.
149
166
 
150
- Some requests require to be done on a live hubspot portal, you can set the `HUBSPOT_HAPI_KEY` environement variable, for example inside a `.env.test` file :
167
+ Some requests require to be done on a live hubspot portal, you can set the `HUBSPOT_ACCESS_TOKEN` and `HUBSPOT_PORTAL_ID` environement variables, for example inside a `.env.test` file :
151
168
 
152
169
  ```
153
- HUBSPOT_HAPI_KEY=xxxx
170
+ HUBSPOT_ACCESS_TOKEN=xxxx
171
+ HUBSPOT_PORTAL_ID=yyyy
154
172
  ```
155
173
 
156
174
  To add a new test or update a VCR recording, run the test with the `VCR_RECORD_MODE`
data/Rakefile CHANGED
@@ -28,5 +28,3 @@ Rake::RDocTask.new do |rdoc|
28
28
  rdoc.rdoc_files.include('README*')
29
29
  rdoc.rdoc_files.include('lib/**/*.rb')
30
30
  end
31
-
32
- Dir.glob('lib/tasks/*.rake').each { |r| load r }
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hubspot-api-ruby"
3
- s.version = "0.9.0"
3
+ s.version = "0.10.0"
4
4
  s.require_paths = ["lib"]
5
5
  s.authors = ["Jonathan"]
6
6
  s.email = ["jonathan@hoggo.com"]
@@ -8,7 +8,6 @@ Gem::Specification.new do |s|
8
8
  s.licenses = ["MIT"]
9
9
  s.files = [".rspec", "Gemfile", "Guardfile", "LICENSE.txt", "README.md", "RELEASING.md", "Rakefile", "hubspot-api-ruby.gemspec"]
10
10
  s.files += Dir["lib/**/*.rb"]
11
- s.files += Dir["lib/**/*.rake"]
12
11
  s.files += Dir["spec/**/*.rb"]
13
12
  s.homepage = "https://github.com/captaincontrat/hubspot-api-ruby"
14
13
  s.summary = "hubspot-api-ruby is a wrapper for the HubSpot REST API"
@@ -31,6 +31,10 @@ module Hubspot
31
31
  raise Hubspot::ConfigurationError.new("You must provide either an access_token or an hapikey")
32
32
  end
33
33
 
34
+ if hapikey.present?
35
+ Hubspot::Deprecator.build.deprecation_warning("hapikey", "please use access_token instead. See https://developers.hubspot.com/docs/api/migrate-an-api-key-integration-to-a-private-app")
36
+ end
37
+
34
38
  if access_token.present?
35
39
  Hubspot::Connection.headers("Authorization" => "Bearer #{access_token}")
36
40
  end
@@ -21,7 +21,6 @@ module Hubspot
21
21
  attr_reader :metadata
22
22
 
23
23
  def initialize(response_hash)
24
-
25
24
  @engagement = response_hash["engagement"]
26
25
  @associations = response_hash["associations"]
27
26
  @attachments = response_hash["attachments"]
data/lib/hubspot/file.rb CHANGED
@@ -10,7 +10,7 @@ module Hubspot
10
10
  #
11
11
  class File
12
12
  GET_FILE_PATH = "/filemanager/api/v2/files/:file_id"
13
- DELETE_FILE_PATH = "/filemanager/api/v2/files/:file_id/full-delete"
13
+ DELETE_FILE_PATH = "/filemanager/api/v2/files/:file_id/full-delete"
14
14
  LIST_FILE_PATH = "/filemanager/api/v2/files"
15
15
 
16
16
  attr_reader :id
@@ -24,7 +24,7 @@ module Hubspot
24
24
  class << self
25
25
  def find_by_id(file_id)
26
26
  response = Hubspot::Connection.get_json(GET_FILE_PATH, { file_id: file_id })
27
- new(response)
27
+ new(response)
28
28
  end
29
29
  end
30
30
 
@@ -2,9 +2,5 @@ require 'hubspot-api-ruby'
2
2
  require 'rails'
3
3
  module Hubspot
4
4
  class Railtie < Rails::Railtie
5
- rake_tasks do
6
- spec = Gem::Specification.find_by_name('hubspot-api-ruby')
7
- load "#{spec.gem_dir}/lib/tasks/hubspot.rake"
8
- end
9
5
  end
10
6
  end
data/lib/hubspot/utils.rb CHANGED
@@ -20,31 +20,6 @@ module Hubspot
20
20
  hash.map { |k, v| { key_name => k.to_s, "value" => v } }
21
21
  end
22
22
 
23
- def dump_properties(klass, hapikey=ENV['HUBSPOT_API_KEY'], filter={})
24
- Hubspot::Deprecator.build.deprecation_warning("Hubspot::Utils.dump_properties")
25
-
26
- with_hapikey(hapikey) do
27
- { 'groups' => klass.groups({}, filter),
28
- 'properties' => klass.all({}, filter).select { |p| !p['hubspotDefined'] }
29
- }
30
- end
31
- end
32
-
33
- def restore_properties(klass, hapikey=ENV['HUPSPOT_API_KEY'], properties={}, dry_run=false)
34
- Hubspot::Deprecator.build.deprecation_warning("Hubspot::Utils.restore_properties")
35
-
36
- existing_properties = dump_properties(klass, hapikey)
37
- skip, new_groups, new_props, update_props = compare_property_lists(klass, properties, existing_properties)
38
- puts '', 'Dry Run - Changes will not be applied' if dry_run
39
- puts '','Skipping'
40
- skip.each { |h| puts "#{h[:reason]} - #{h[:prop]['groupName']}:#{h[:prop]['name']}" }
41
- with_hapikey(hapikey) do
42
- create_groups(klass, new_groups, dry_run)
43
- create_properties(klass, new_props, dry_run)
44
- update_properties(klass, update_props, dry_run)
45
- end
46
- end
47
-
48
23
  def create_groups(klass, groups, dry_run=false)
49
24
  puts '','Creating new groups'
50
25
  groups.each do |g|
@@ -112,11 +87,6 @@ module Hubspot
112
87
  [skip, new_groups.to_a, new_props, update_props]
113
88
  end
114
89
 
115
- def with_hapikey(hapikey)
116
- Hubspot.configure(hapikey: hapikey)
117
- yield if block_given?
118
- end
119
-
120
90
  private
121
91
 
122
92
  def find_by_name(name, set)
@@ -1,14 +1,9 @@
1
1
  require 'timecop'
2
2
 
3
3
  describe Hubspot do
4
- before do
5
- Hubspot.configure(hapikey: "demo")
6
- Timecop.freeze(Time.utc(2012, 'Oct', 10))
7
- end
4
+ before { Timecop.freeze(Time.utc(2012, 'Oct', 10)) }
8
5
 
9
- after do
10
- Timecop.return
11
- end
6
+ after { Timecop.return }
12
7
 
13
8
  let(:last_blog_id) { Hubspot::Blog.list.last['id'] }
14
9
  let(:last_blog_post_id) { Hubspot::Blog.list.last.posts.first['id'] }
@@ -1,26 +1,23 @@
1
1
  describe Hubspot::Config do
2
2
  describe ".configure" do
3
- it "sets the hapikey config" do
4
- hapikey = "demo"
3
+ it "sets the access token config" do
4
+ access_token = "foobar"
5
5
 
6
- config = Hubspot::Config.configure(hapikey: hapikey)
6
+ config = Hubspot::Config.configure(access_token: access_token)
7
7
 
8
- expect(config.hapikey).to eq(hapikey)
8
+ expect(config.access_token).to eq(access_token)
9
9
  end
10
10
 
11
11
  it "changes the base_url" do
12
12
  base_url = "https://api.hubapi.com/v2"
13
13
 
14
- config = Hubspot::Config.configure(
15
- hapikey: "123abc",
16
- base_url: base_url
17
- )
14
+ config = Hubspot::Config.configure(base_url: base_url, access_token: 'foobar')
18
15
 
19
16
  expect(config.base_url).to eq(base_url)
20
17
  end
21
18
 
22
19
  it "sets a default value for base_url" do
23
- config = Hubspot::Config.configure(hapikey: "123abc")
20
+ config = Hubspot::Config.configure(access_token: 'foobar')
24
21
 
25
22
  expect(config.base_url).to eq("https://api.hubapi.com")
26
23
  end
@@ -29,7 +26,7 @@ describe Hubspot::Config do
29
26
  portal_id = "62515"
30
27
 
31
28
  config = Hubspot::Config.configure(
32
- hapikey: "123abc",
29
+ access_token: 'foobar',
33
30
  portal_id: portal_id
34
31
  )
35
32
 
@@ -50,15 +47,28 @@ describe Hubspot::Config do
50
47
  })
51
48
  }.to raise_error(Hubspot::ConfigurationError)
52
49
  end
50
+
51
+ context 'hapikey deprecation' do
52
+ it "sets the hapikey config and sends a deprecation warning" do
53
+ previous, $stderr = $stderr, StringIO.new
54
+
55
+ hapikey = 'demo'
56
+ config = Hubspot::Config.configure(hapikey: hapikey)
57
+ expect(config.hapikey).to eq(hapikey)
58
+ expect($stderr.string).to include 'please use access_token instead.'
59
+ ensure
60
+ $stderr = previous
61
+ end
62
+ end
53
63
  end
54
64
 
55
65
  describe ".reset!" do
56
66
  it "resets the config values" do
57
- Hubspot::Config.configure(hapikey: "123abc", portal_id: "456def")
67
+ Hubspot::Config.configure(access_token: "123abc", portal_id: "456def")
58
68
 
59
69
  Hubspot::Config.reset!
60
70
 
61
- expect(Hubspot::Config.hapikey).to be nil
71
+ expect(Hubspot::Config.access_token).to be nil
62
72
  expect(Hubspot::Config.portal_id).to be nil
63
73
  end
64
74
  end
@@ -66,7 +76,7 @@ describe Hubspot::Config do
66
76
  describe ".ensure!" do
67
77
  context "when a specified parameter is missing" do
68
78
  it "raises an error" do
69
- Hubspot::Config.configure(hapikey: "123abc")
79
+ Hubspot::Config.configure(access_token: "123abc")
70
80
 
71
81
  expect {
72
82
  Hubspot::Config.ensure!(:portal_id)
@@ -76,7 +86,7 @@ describe Hubspot::Config do
76
86
 
77
87
  context "when all specified parameters are present" do
78
88
  it "does not raise an error" do
79
- Hubspot::Config.configure(hapikey: "123abc", portal_id: "456def")
89
+ Hubspot::Config.configure(access_token: "123abc", portal_id: "456def")
80
90
 
81
91
  expect {
82
92
  Hubspot::Config.ensure!(:portal_id)
@@ -1,18 +1,12 @@
1
1
  describe Hubspot::Connection do
2
- before do
3
- Hubspot.configure hapikey: 'fake'
4
- end
5
-
6
2
  describe ".get_json" do
7
3
  it "returns the parsed response from the GET request" do
8
4
  path = "/some/path"
9
5
  body = { key: "value" }
10
6
 
11
- stub_request(:get, "https://api.hubapi.com/some/path?hapikey=fake").
12
- to_return(status: 200, body: JSON.generate(body))
7
+ stub_request(:get, "https://api.hubapi.com/some/path").to_return(status: 200, body: JSON.generate(body))
13
8
 
14
9
  result = Hubspot::Connection.get_json(path, {})
15
-
16
10
  expect(result).to eq({ "key" => "value" })
17
11
  end
18
12
  end
@@ -22,11 +16,9 @@ describe Hubspot::Connection do
22
16
  path = "/some/path"
23
17
  body = { id: 1, name: "ABC" }
24
18
 
25
- stub_request(:post, "https://api.hubapi.com/some/path?hapikey=fake&name=ABC").
26
- to_return(status: 200, body: JSON.generate(body))
19
+ stub_request(:post, "https://api.hubapi.com/some/path?name=ABC").to_return(status: 200, body: JSON.generate(body))
27
20
 
28
21
  result = Hubspot::Connection.post_json(path, params: { name: "ABC" })
29
-
30
22
  expect(result).to eq({ "id" => 1, "name" => "ABC" })
31
23
  end
32
24
  end
@@ -35,11 +27,9 @@ describe Hubspot::Connection do
35
27
  it "returns the response from the DELETE request" do
36
28
  path = "/some/path"
37
29
 
38
- stub_request(:delete, "https://api.hubapi.com/some/path?hapikey=fake").
39
- to_return(status: 204, body: JSON.generate({}))
30
+ stub_request(:delete, "https://api.hubapi.com/some/path").to_return(status: 204, body: JSON.generate({}))
40
31
 
41
32
  result = Hubspot::Connection.delete_json(path, {})
42
-
43
33
  expect(result.code).to eq(204)
44
34
  end
45
35
  end
@@ -49,20 +39,18 @@ describe Hubspot::Connection do
49
39
  path = "/some/path"
50
40
  update_options = { params: {}, body: {} }
51
41
 
52
- stub_request(:put, "https://api.hubapi.com/some/path?hapikey=fake").
53
- to_return(status: 200, body: JSON.generate(vid: 123))
42
+ stub_request(:put, "https://api.hubapi.com/some/path").to_return(status: 200, body: JSON.generate(vid: 123))
54
43
 
55
44
  response = Hubspot::Connection.put_json(path, update_options)
56
45
 
57
46
  assert_requested(
58
47
  :put,
59
- "https://api.hubapi.com/some/path?hapikey=fake",
48
+ "https://api.hubapi.com/some/path",
60
49
  {
61
50
  body: "{}",
62
51
  headers: { "Content-Type" => "application/json" },
63
52
  }
64
53
  )
65
-
66
54
  expect(response).to eq({ "vid" => 123 })
67
55
  end
68
56
 
@@ -72,13 +60,13 @@ describe Hubspot::Connection do
72
60
 
73
61
  logger = stub_logger
74
62
 
75
- stub_request(:put, "https://api.hubapi.com/some/path?hapikey=fake").
76
- to_return(status: 200, body: JSON.generate("response body"))
63
+ stub_request(:put, "https://api.hubapi.com/some/path").to_return(status: 200,
64
+ body: JSON.generate("response body"))
77
65
 
78
66
  Hubspot::Connection.put_json(path, update_options)
79
67
 
80
68
  expect(logger).to have_received(:info).with(<<~MSG)
81
- Hubspot: https://api.hubapi.com/some/path?hapikey=fake.
69
+ Hubspot: https://api.hubapi.com/some/path.
82
70
  Body: {}.
83
71
  Response: 200 "response body"
84
72
  MSG
@@ -88,8 +76,7 @@ describe Hubspot::Connection do
88
76
  path = "/some/path"
89
77
  update_options = { params: {}, body: {} }
90
78
 
91
- stub_request(:put, "https://api.hubapi.com/some/path?hapikey=fake").
92
- to_return(status: 401)
79
+ stub_request(:put, "https://api.hubapi.com/some/path").to_return(status: 401)
93
80
 
94
81
  expect {
95
82
  Hubspot::Connection.put_json(path, update_options)
@@ -99,80 +86,85 @@ describe Hubspot::Connection do
99
86
 
100
87
  context 'private methods' do
101
88
  describe ".generate_url" do
102
- let(:path){ "/test/:email/profile" }
103
- let(:params){{email: "test"}}
104
- let(:options){{}}
105
- subject{ Hubspot::Connection.send(:generate_url, path, params, options) }
106
- before{ Hubspot.configure(hapikey: "demo", portal_id: "62515") }
89
+ let(:path) { "/test/:email/profile" }
90
+ let(:params) { { email: "test" } }
91
+ let(:options) { {} }
92
+ subject { Hubspot::Connection.send(:generate_url, path, params, options) }
107
93
 
108
94
  it "doesn't modify params" do
109
- expect{ subject }.to_not change{params}
95
+ expect { subject }.to_not change{params}
110
96
  end
111
97
 
112
98
  context "with a portal_id param" do
113
- let(:path){ "/test/:portal_id/profile" }
114
- let(:params){{}}
115
- it{ should == "https://api.hubapi.com/test/62515/profile?hapikey=demo" }
99
+ let(:path) { "/test/:portal_id/profile" }
100
+ let(:params) { {} }
101
+
102
+ before do
103
+ Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), portal_id: ENV.fetch("HUBSPOT_PORTAL_ID"))
104
+ end
105
+
106
+ it { should == "https://api.hubapi.com/test/#{ENV.fetch('HUBSPOT_PORTAL_ID')}/profile" }
116
107
  end
117
108
 
118
109
  context "when configure hasn't been called" do
119
- before{ Hubspot::Config.reset! }
110
+ before { Hubspot::Config.reset! }
120
111
  it "raises a config exception" do
121
- expect{ subject }.to raise_error Hubspot::ConfigurationError
112
+ expect { subject }.to raise_error Hubspot::ConfigurationError
122
113
  end
123
114
  end
124
115
 
125
116
  context "with interpolations but no params" do
126
- let(:params){{}}
117
+ let(:params) { {} }
118
+
127
119
  it "raises an interpolation exception" do
128
120
  expect{ subject }.to raise_error Hubspot::MissingInterpolation
129
121
  end
130
122
  end
131
123
 
132
124
  context "with an interpolated param" do
133
- let(:params){ {email: "email@address.com"} }
134
- it{ should == "https://api.hubapi.com/test/email%40address.com/profile?hapikey=demo" }
125
+ let(:params) { { email: "email@address.com" } }
126
+ it { should == "https://api.hubapi.com/test/email%40address.com/profile" }
135
127
  end
136
128
 
137
129
  context "with multiple interpolated params" do
138
- let(:path){ "/test/:email/:id/profile" }
139
- let(:params){{email: "email@address.com", id: 1234}}
140
- it{ should == "https://api.hubapi.com/test/email%40address.com/1234/profile?hapikey=demo" }
130
+ let(:path) { "/test/:email/:id/profile" }
131
+ let(:params) { { email: "email@address.com", id: 1234 } }
132
+ it { should == "https://api.hubapi.com/test/email%40address.com/1234/profile" }
141
133
  end
142
134
 
143
135
  context "with query params" do
144
- let(:params){{email: "email@address.com", id: 1234}}
145
- it{ should == "https://api.hubapi.com/test/email%40address.com/profile?id=1234&hapikey=demo" }
136
+ let(:params) { { email: "email@address.com", id: 1234 } }
137
+ it { should == "https://api.hubapi.com/test/email%40address.com/profile?id=1234" }
146
138
 
147
139
  context "containing a time" do
148
140
  let(:start_time) { Time.now }
149
- let(:params){{email: "email@address.com", id: 1234, start: start_time}}
150
- it{ should == "https://api.hubapi.com/test/email%40address.com/profile?id=1234&start=#{start_time.to_i * 1000}&hapikey=demo" }
141
+ let(:params) { { email: "email@address.com", id: 1234, start: start_time } }
142
+ it { should == "https://api.hubapi.com/test/email%40address.com/profile?id=1234&start=#{start_time.to_i * 1000}" }
151
143
  end
152
144
 
153
145
  context "containing a range" do
154
146
  let(:start_time) { Time.now }
155
147
  let(:end_time) { Time.now + 1.year }
156
- let(:params){{email: "email@address.com", id: 1234, created__range: start_time..end_time }}
157
- it{ should == "https://api.hubapi.com/test/email%40address.com/profile?id=1234&created__range=#{start_time.to_i * 1000}&created__range=#{end_time.to_i * 1000}&hapikey=demo" }
148
+ let(:params) { { email: "email@address.com", id: 1234, created__range: start_time..end_time } }
149
+ it { should == "https://api.hubapi.com/test/email%40address.com/profile?id=1234&created__range=#{start_time.to_i * 1000}&created__range=#{end_time.to_i * 1000}" }
158
150
  end
159
151
 
160
152
  context "containing an array of strings" do
161
- let(:path){ "/test/emails" }
162
- let(:params){{batch_email: %w(email1@example.com email2@example.com)}}
163
- it{ should == "https://api.hubapi.com/test/emails?email=email1%40example.com&email=email2%40example.com&hapikey=demo" }
153
+ let(:path) { "/test/emails" }
154
+ let(:params) { { batch_email: %w(email1@example.com email2@example.com) } }
155
+ it { should == "https://api.hubapi.com/test/emails?email=email1%40example.com&email=email2%40example.com" }
164
156
  end
165
157
  end
166
158
 
167
159
  context "with options" do
168
- let(:options){ {base_url: "https://cool.com", hapikey: false} }
169
- it{ should == "https://cool.com/test/test/profile"}
160
+ let(:options) { { base_url: "https://cool.com", access_token: false } }
161
+ it { should == "https://cool.com/test/test/profile" }
170
162
  end
171
163
 
172
164
  context "passing Array as parameters for batch mode, key is prefixed with batch_" do
173
165
  let(:path) { Hubspot::ContactList::LIST_BATCH_PATH }
174
166
  let(:params) { { batch_list_id: [1,2,3] } }
175
- it{ should == "https://api.hubapi.com/contacts/v1/lists/batch?listId=1&listId=2&listId=3&hapikey=demo" }
167
+ it { should == "https://api.hubapi.com/contacts/v1/lists/batch?listId=1&listId=2&listId=3" }
176
168
  end
177
169
  end
178
170
  end
@@ -191,10 +183,7 @@ describe Hubspot::EventConnection do
191
183
  let(:headers) { nil }
192
184
 
193
185
  subject { described_class.trigger(path, options) }
194
- before do
195
- Hubspot.configure(hapikey: 'demo', portal_id: '62515')
196
- allow(described_class).to receive(:get).and_return(true)
197
- end
186
+ before { allow(described_class).to receive(:get).and_return(true) }
198
187
 
199
188
  it 'calls get with a custom url' do
200
189
  subject