hubspot-api-ruby 0.9.0 → 0.11.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 +4 -4
- data/README.md +30 -10
- data/Rakefile +0 -2
- data/hubspot-api-ruby.gemspec +1 -2
- data/lib/hubspot/company_properties.rb +10 -0
- data/lib/hubspot/config.rb +4 -0
- data/lib/hubspot/contact_properties.rb +10 -0
- data/lib/hubspot/deal_properties.rb +10 -0
- data/lib/hubspot/engagement.rb +0 -1
- data/lib/hubspot/file.rb +2 -2
- data/lib/hubspot/properties.rb +8 -0
- data/lib/hubspot/railtie.rb +0 -4
- data/lib/hubspot/utils.rb +0 -30
- data/spec/lib/hubspot/blog_spec.rb +2 -7
- data/spec/lib/hubspot/company_properties_spec.rb +40 -0
- data/spec/lib/hubspot/config_spec.rb +24 -14
- data/spec/lib/hubspot/connection_spec.rb +44 -55
- data/spec/lib/hubspot/contact_list_spec.rb +21 -33
- data/spec/lib/hubspot/contact_properties_spec.rb +40 -0
- data/spec/lib/hubspot/contact_spec.rb +1 -1
- data/spec/lib/hubspot/custom_event_spec.rb +5 -4
- data/spec/lib/hubspot/deal_properties_spec.rb +40 -0
- data/spec/lib/hubspot/engagement_spec.rb +3 -11
- data/spec/lib/hubspot/event_spec.rb +3 -2
- data/spec/lib/hubspot/file_spec.rb +20 -9
- data/spec/lib/hubspot/form_spec.rb +8 -11
- data/spec/lib/hubspot/meeting_spec.rb +7 -1
- data/spec/lib/hubspot/owner_spec.rb +2 -3
- data/spec/lib/hubspot/utils_spec.rb +6 -39
- data/spec/lib/hubspot-ruby_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/vcr.rb +1 -0
- metadata +6 -10
- data/lib/tasks/hubspot.rake +0 -53
- data/spec/lib/tasks/hubspot_spec.rb +0 -119
- data/spec/support/capture_output.rb +0 -21
- data/spec/support/rake.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa1ed69670a9a924f8d1b1b44d3489ccce1e29a949495bfb6bec3e489f43525
|
4
|
+
data.tar.gz: 6e8320b3f698d568c717661c3fb5b145505959d662f96ea02d63726cf3dff22a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e05b88efa2d452f512e6846d43eaf89408742412ff3c34161f6d21ca2b87d1431a74d5d4b20482580733e013d00f2455b17806ee02a559643115093a78e143
|
7
|
+
data.tar.gz: 430cbd8c797d9aaf6a264d9116acd86f4a115c2bcfef12421ac6bbc988bdbf4cff6d5124b9f2a4355211b80450b8e80687d602c1aab159049964a7c690b956c6
|
data/README.md
CHANGED
@@ -30,16 +30,17 @@ Authentication docs].
|
|
30
30
|
Below is a complete list of configuration options with the default values:
|
31
31
|
```ruby
|
32
32
|
Hubspot.configure({
|
33
|
-
|
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
|
-
read_timeout: nil,
|
40
|
+
read_timeout: nil,
|
42
41
|
open_timeout: nil,
|
42
|
+
# read_timeout and open_timeout are expressed in seconds and passed to HTTParty
|
43
|
+
hapikey: <HAPIKEY>,
|
43
44
|
})
|
44
45
|
```
|
45
46
|
|
@@ -50,15 +51,20 @@ environment.
|
|
50
51
|
[HubSpot API Authentication Docs]: https://developers.hubspot.com/docs/methods/auth/oauth-overview
|
51
52
|
[HubSpot Developer Tools]: https://developers.hubspot.com/docs/devtools
|
52
53
|
|
53
|
-
## Authentication with
|
54
|
+
## Authentication with a private app access token
|
54
55
|
|
55
|
-
To set the HubSpot
|
56
|
+
To set the HubSpot access token, run the following:
|
56
57
|
```ruby
|
57
|
-
Hubspot.configure(
|
58
|
+
Hubspot.configure(access_token: 'YOUR_ACCESS_TOKEN')
|
58
59
|
```
|
59
60
|
|
60
|
-
|
61
|
-
|
61
|
+
Note: some APIs require the portal ID to be set.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Hubspot.configure(access_token: 'YOUR_ACCESS_TOKEN', portal_id: 'YOUR_PORTAL_ID')
|
65
|
+
```
|
66
|
+
|
67
|
+
[To learn how to create and manage private apps and access tokens, click here.](https://developers.hubspot.com/docs/api/private-apps)
|
62
68
|
|
63
69
|
## Authentication with OAuth 2.0
|
64
70
|
|
@@ -111,6 +117,18 @@ Hubspot::OAuth.refresh(refresh_token)
|
|
111
117
|
|
112
118
|
At this time, OAuth tokens are configured globally rather than on a per-connection basis.
|
113
119
|
|
120
|
+
## Authentication with an API key
|
121
|
+
|
122
|
+
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).
|
123
|
+
|
124
|
+
To set the HubSpot API key, aka `hapikey`, run the following:
|
125
|
+
```ruby
|
126
|
+
Hubspot.configure(hapikey: "YOUR_API_KEY")
|
127
|
+
```
|
128
|
+
|
129
|
+
If you have a HubSpot account, you can find your API key by logging in and
|
130
|
+
visiting: https://app.hubspot.com/keys/get
|
131
|
+
|
114
132
|
## Usage
|
115
133
|
|
116
134
|
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 +165,12 @@ By default, the VCR recording mode is set to `:none`, which allows recorded
|
|
147
165
|
requests to be re-played but raises for any new request. This prevents the test
|
148
166
|
suite from issuing unexpected HTTP requests.
|
149
167
|
|
150
|
-
Some requests require to be done on a live hubspot portal, you can set the `
|
168
|
+
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
169
|
|
152
170
|
```
|
153
|
-
|
171
|
+
HUBSPOT_ACCESS_TOKEN=xxxx
|
172
|
+
HUBSPOT_PORTAL_ID=yyyy
|
173
|
+
HUBSPOT_HAPI_KEY=zzzz
|
154
174
|
```
|
155
175
|
|
156
176
|
To add a new test or update a VCR recording, run the test with the `VCR_RECORD_MODE`
|
data/Rakefile
CHANGED
data/hubspot-api-ruby.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "hubspot-api-ruby"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.11.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"
|
@@ -3,6 +3,8 @@ module Hubspot
|
|
3
3
|
|
4
4
|
ALL_PROPERTIES_PATH = "/properties/v1/companies/properties"
|
5
5
|
ALL_GROUPS_PATH = "/properties/v1/companies/groups"
|
6
|
+
PROPERTY_PATH = "/properties/v1/companies/properties/named/:property_name"
|
7
|
+
GROUP_PATH = "/properties/v1/companies/groups/named/:group_name"
|
6
8
|
CREATE_PROPERTY_PATH = "/properties/v1/companies/properties"
|
7
9
|
UPDATE_PROPERTY_PATH = "/properties/v1/companies/properties/named/:property_name"
|
8
10
|
DELETE_PROPERTY_PATH = "/properties/v1/companies/properties/named/:property_name"
|
@@ -19,10 +21,18 @@ module Hubspot
|
|
19
21
|
superclass.all(ALL_PROPERTIES_PATH, opts, filter)
|
20
22
|
end
|
21
23
|
|
24
|
+
def find(property_name, opts={})
|
25
|
+
superclass.find(PROPERTY_PATH, property_name, opts)
|
26
|
+
end
|
27
|
+
|
22
28
|
def groups(opts={}, filter={})
|
23
29
|
superclass.groups(ALL_GROUPS_PATH, opts, filter)
|
24
30
|
end
|
25
31
|
|
32
|
+
def find_group(group_name, opts={})
|
33
|
+
superclass.find_group(GROUP_PATH, group_name, opts={})
|
34
|
+
end
|
35
|
+
|
26
36
|
def create!(params={})
|
27
37
|
superclass.create!(CREATE_PROPERTY_PATH, params)
|
28
38
|
end
|
data/lib/hubspot/config.rb
CHANGED
@@ -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
|
@@ -3,6 +3,8 @@ module Hubspot
|
|
3
3
|
|
4
4
|
ALL_PROPERTIES_PATH = "/properties/v1/contacts/properties"
|
5
5
|
ALL_GROUPS_PATH = "/properties/v1/contacts/groups"
|
6
|
+
PROPERTY_PATH = "/properties/v1/contacts/properties/named/:property_name"
|
7
|
+
GROUP_PATH = "/properties/v1/contacts/groups/named/:group_name"
|
6
8
|
CREATE_PROPERTY_PATH = "/properties/v1/contacts/properties"
|
7
9
|
UPDATE_PROPERTY_PATH = "/properties/v1/contacts/properties/named/:property_name"
|
8
10
|
DELETE_PROPERTY_PATH = "/properties/v1/contacts/properties/named/:property_name"
|
@@ -19,10 +21,18 @@ module Hubspot
|
|
19
21
|
superclass.all(ALL_PROPERTIES_PATH, opts, filter)
|
20
22
|
end
|
21
23
|
|
24
|
+
def find(property_name, opts={})
|
25
|
+
superclass.find(PROPERTY_PATH, property_name, opts)
|
26
|
+
end
|
27
|
+
|
22
28
|
def groups(opts={}, filter={})
|
23
29
|
superclass.groups(ALL_GROUPS_PATH, opts, filter)
|
24
30
|
end
|
25
31
|
|
32
|
+
def find_group(group_name, opts={})
|
33
|
+
superclass.find_group(GROUP_PATH, group_name, opts)
|
34
|
+
end
|
35
|
+
|
26
36
|
def create!(params={})
|
27
37
|
superclass.create!(CREATE_PROPERTY_PATH, params)
|
28
38
|
end
|
@@ -3,6 +3,8 @@ module Hubspot
|
|
3
3
|
|
4
4
|
ALL_PROPERTIES_PATH = '/deals/v1/properties'
|
5
5
|
ALL_GROUPS_PATH = '/deals/v1/groups'
|
6
|
+
PROPERTY_PATH = '/properties/v1/deals/properties/named/:property_name'
|
7
|
+
GROUP_PATH = '/properties/v1/deals/groups/named/:group_name'
|
6
8
|
CREATE_PROPERTY_PATH = '/deals/v1/properties/'
|
7
9
|
UPDATE_PROPERTY_PATH = '/deals/v1/properties/named/:property_name'
|
8
10
|
DELETE_PROPERTY_PATH = '/deals/v1/properties/named/:property_name'
|
@@ -19,10 +21,18 @@ module Hubspot
|
|
19
21
|
superclass.all(ALL_PROPERTIES_PATH, opts, filter)
|
20
22
|
end
|
21
23
|
|
24
|
+
def find(property_name, opts={})
|
25
|
+
superclass.find(PROPERTY_PATH, property_name, opts)
|
26
|
+
end
|
27
|
+
|
22
28
|
def groups(opts={}, filter={})
|
23
29
|
superclass.groups(ALL_GROUPS_PATH, opts, filter)
|
24
30
|
end
|
25
31
|
|
32
|
+
def find_group(group_name, opts={})
|
33
|
+
superclass.find_group(GROUP_PATH, group_name, opts)
|
34
|
+
end
|
35
|
+
|
26
36
|
def create!(params={})
|
27
37
|
superclass.create!(CREATE_PROPERTY_PATH, params)
|
28
38
|
end
|
data/lib/hubspot/engagement.rb
CHANGED
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
|
-
|
27
|
+
new(response)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/lib/hubspot/properties.rb
CHANGED
@@ -26,11 +26,19 @@ module Hubspot
|
|
26
26
|
filter_results(response, :groupName, filter[:include], filter[:exclude])
|
27
27
|
end
|
28
28
|
|
29
|
+
def find(path, property_name, opts={})
|
30
|
+
response = Hubspot::Connection.get_json(path, opts.merge({ property_name: property_name }))
|
31
|
+
end
|
32
|
+
|
29
33
|
def groups(path, opts={}, filter={})
|
30
34
|
response = Hubspot::Connection.get_json(path, opts)
|
31
35
|
filter_results(response, :name, filter[:include], filter[:exclude])
|
32
36
|
end
|
33
37
|
|
38
|
+
def find_group(path, group_name, opts={})
|
39
|
+
response = Hubspot::Connection.get_json(path, opts.merge({ group_name: group_name }))
|
40
|
+
end
|
41
|
+
|
34
42
|
def create!(path, params={})
|
35
43
|
post_data = valid_property_params(params)
|
36
44
|
return nil if post_data.blank?
|
data/lib/hubspot/railtie.rb
CHANGED
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
|
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
|
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'] }
|
@@ -111,6 +111,26 @@ RSpec.describe Hubspot::CompanyProperties do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
describe '.find' do
|
115
|
+
context 'existing property' do
|
116
|
+
cassette 'company_properties/existing_property'
|
117
|
+
|
118
|
+
it 'should return a company property by name if it exists' do
|
119
|
+
response = Hubspot::CompanyProperties.find('domain')
|
120
|
+
expect(response['name']).to eq 'domain'
|
121
|
+
expect(response['label']).to eq 'Company Domain Name'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'non-existent property' do
|
126
|
+
cassette 'company_properties/non_existent_property'
|
127
|
+
|
128
|
+
it 'should return an error for a missing property' do
|
129
|
+
expect{ Hubspot::CompanyProperties.find('this_does_not_exist') }.to raise_error(Hubspot::NotFoundError)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
114
134
|
describe ".create!" do
|
115
135
|
it "creates a company property" do
|
116
136
|
VCR.use_cassette("company_properties/create_property") do
|
@@ -332,6 +352,26 @@ RSpec.describe Hubspot::CompanyProperties do
|
|
332
352
|
end
|
333
353
|
end
|
334
354
|
|
355
|
+
describe '.find_group' do
|
356
|
+
context 'existing group' do
|
357
|
+
cassette 'company_properties/existing_group'
|
358
|
+
|
359
|
+
it 'should return a company property group by name if it exists' do
|
360
|
+
response = Hubspot::CompanyProperties.find_group('companyinformation')
|
361
|
+
expect(response['name']).to eq 'companyinformation'
|
362
|
+
expect(response['displayName']).to eq 'Company information'
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
context 'non-existent group' do
|
367
|
+
cassette 'company_properties/non_existent_group'
|
368
|
+
|
369
|
+
it 'should return an error for a missing group' do
|
370
|
+
expect{ Hubspot::CompanyProperties.find_group('this_does_not_exist') }.to raise_error(Hubspot::NotFoundError)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
335
375
|
let(:params) { { 'name' => 'ff_group1', 'displayName' => 'Test Group One', 'displayOrder' => 100, 'badParam' => 99 } }
|
336
376
|
|
337
377
|
describe '.create_group!' do
|
@@ -1,26 +1,23 @@
|
|
1
1
|
describe Hubspot::Config do
|
2
2
|
describe ".configure" do
|
3
|
-
it "sets the
|
4
|
-
|
3
|
+
it "sets the access token config" do
|
4
|
+
access_token = "foobar"
|
5
5
|
|
6
|
-
config = Hubspot::Config.configure(
|
6
|
+
config = Hubspot::Config.configure(access_token: access_token)
|
7
7
|
|
8
|
-
expect(config.
|
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(
|
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
|
-
|
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(
|
67
|
+
Hubspot::Config.configure(access_token: "123abc", portal_id: "456def")
|
58
68
|
|
59
69
|
Hubspot::Config.reset!
|
60
70
|
|
61
|
-
expect(Hubspot::Config.
|
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(
|
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(
|
89
|
+
Hubspot::Config.configure(access_token: "123abc", portal_id: "456def")
|
80
90
|
|
81
91
|
expect {
|
82
92
|
Hubspot::Config.ensure!(:portal_id)
|