hubspot-ruby 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +17 -5
- data/Rakefile +3 -13
- data/hubspot-ruby.gemspec +1 -1
- data/lib/hubspot-ruby.rb +3 -0
- data/lib/hubspot/company.rb +27 -0
- data/lib/hubspot/railtie.rb +0 -1
- data/lib/tasks/{properties.rake → hubspot.rake} +0 -0
- data/spec/lib/hubspot/blog_spec.rb +98 -64
- data/spec/lib/hubspot/company_properties_spec.rb +2 -2
- data/spec/lib/hubspot/company_spec.rb +27 -3
- data/spec/lib/hubspot/contact_list_spec.rb +2 -2
- data/spec/lib/hubspot/contact_properties_spec.rb +2 -2
- data/spec/lib/hubspot/contact_spec.rb +44 -26
- data/spec/lib/hubspot/deal_pipeline_spec.rb +85 -0
- data/spec/lib/hubspot/deal_properties_spec.rb +2 -2
- data/spec/lib/hubspot/form_spec.rb +1 -1
- data/spec/lib/hubspot/utils_spec.rb +4 -4
- data/spec/lib/tasks/hubspot_spec.rb +100 -0
- data/spec/spec_helper.rb +0 -14
- data/spec/support/cassette_helper.rb +1 -1
- data/spec/support/hubspot_api_helpers.rb +9 -0
- data/spec/support/rake.rb +46 -0
- data/spec/support/vcr.rb +15 -0
- metadata +9 -12
- data/spec/lib/tasks/properties_spec.rb +0 -90
- data/spec/live/companies_integration_spec.rb +0 -31
- data/spec/live/companies_properties_integration_spec.rb +0 -120
- data/spec/live/contacts_integration_spec.rb +0 -24
- data/spec/live/contacts_properties_integration_spec.rb +0 -120
- data/spec/live/deal_pipeline_spec.rb +0 -35
- data/spec/live/deal_properties_integration_spec.rb +0 -123
- data/spec/live/deals_integration_spec.rb +0 -35
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew DiMichele
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-11-
|
12
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -229,7 +229,7 @@ files:
|
|
229
229
|
- lib/hubspot/subscription.rb
|
230
230
|
- lib/hubspot/topic.rb
|
231
231
|
- lib/hubspot/utils.rb
|
232
|
-
- lib/tasks/
|
232
|
+
- lib/tasks/hubspot.rake
|
233
233
|
- spec/lib/hubspot-ruby_spec.rb
|
234
234
|
- spec/lib/hubspot/blog_spec.rb
|
235
235
|
- spec/lib/hubspot/company_properties_spec.rb
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- spec/lib/hubspot/contact_list_spec.rb
|
240
240
|
- spec/lib/hubspot/contact_properties_spec.rb
|
241
241
|
- spec/lib/hubspot/contact_spec.rb
|
242
|
+
- spec/lib/hubspot/deal_pipeline_spec.rb
|
242
243
|
- spec/lib/hubspot/deal_properties_spec.rb
|
243
244
|
- spec/lib/hubspot/deal_spec.rb
|
244
245
|
- spec/lib/hubspot/engagement_spec.rb
|
@@ -247,17 +248,13 @@ files:
|
|
247
248
|
- spec/lib/hubspot/properties_spec.rb
|
248
249
|
- spec/lib/hubspot/topic_spec.rb
|
249
250
|
- spec/lib/hubspot/utils_spec.rb
|
250
|
-
- spec/lib/tasks/
|
251
|
-
- spec/live/companies_integration_spec.rb
|
252
|
-
- spec/live/companies_properties_integration_spec.rb
|
253
|
-
- spec/live/contacts_integration_spec.rb
|
254
|
-
- spec/live/contacts_properties_integration_spec.rb
|
255
|
-
- spec/live/deal_pipeline_spec.rb
|
256
|
-
- spec/live/deal_properties_integration_spec.rb
|
257
|
-
- spec/live/deals_integration_spec.rb
|
251
|
+
- spec/lib/tasks/hubspot_spec.rb
|
258
252
|
- spec/spec_helper.rb
|
259
253
|
- spec/support/cassette_helper.rb
|
254
|
+
- spec/support/hubspot_api_helpers.rb
|
255
|
+
- spec/support/rake.rb
|
260
256
|
- spec/support/tests_helper.rb
|
257
|
+
- spec/support/vcr.rb
|
261
258
|
homepage: http://github.com/adimichele/hubspot-ruby
|
262
259
|
licenses: []
|
263
260
|
metadata: {}
|
@@ -277,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
274
|
version: '0'
|
278
275
|
requirements: []
|
279
276
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.
|
277
|
+
rubygems_version: 2.7.6
|
281
278
|
signing_key:
|
282
279
|
specification_version: 4
|
283
280
|
summary: hubspot-ruby is a wrapper for the HubSpot REST API
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
describe 'properties rake tasks', live: true do
|
5
|
-
before :all do
|
6
|
-
Rake.application.rake_require 'tasks/properties'
|
7
|
-
end
|
8
|
-
|
9
|
-
context 'Contact Properties' do
|
10
|
-
let(:file) { '/tmp/contact-demo-props.json' }
|
11
|
-
let(:hapikey) { 'demo' }
|
12
|
-
|
13
|
-
describe 'hubspot:dump_properties' do
|
14
|
-
let :run_rake_task do
|
15
|
-
Rake::Task['hubspot:dump_properties'].reenable
|
16
|
-
Rake.application.invoke_task "hubspot:dump_properties[contact,#{file},#{hapikey}]"
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'saves the properties to a file' do
|
20
|
-
run_rake_task
|
21
|
-
|
22
|
-
props = JSON.parse(File.read(file))
|
23
|
-
expect(props.count).to be > 0
|
24
|
-
expect(props['groups'].count).to be > 0
|
25
|
-
expect(props['properties'].count).to be > 0
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'hubspot:restore_properties' do
|
30
|
-
let :run_rake_task do
|
31
|
-
Rake::Task['hubspot:restore_properties'].reenable
|
32
|
-
Rake.application.invoke_task "hubspot:restore_properties[contact,#{file},#{hapikey}]"
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should not need to make any changes' do
|
36
|
-
results = capture_stdout { run_rake_task }
|
37
|
-
expect(results.include?('Created: ')).to be_false
|
38
|
-
expect(results.include?('Updated: ')).to be_false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'Deal Properties' do
|
45
|
-
let(:file) { '/tmp/deal-demo-props.json' }
|
46
|
-
let(:hapikey) { 'demo' }
|
47
|
-
|
48
|
-
describe 'hubspot:dump_properties' do
|
49
|
-
let :run_rake_task do
|
50
|
-
Rake::Task['hubspot:dump_properties'].reenable
|
51
|
-
Rake.application.invoke_task "hubspot:dump_properties[deal,#{file},#{hapikey}]"
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'saves the properties to a file' do
|
55
|
-
pending 'Hubspot disabled this call using the demo hapikey'
|
56
|
-
|
57
|
-
run_rake_task
|
58
|
-
|
59
|
-
props = JSON.parse(File.read(file))
|
60
|
-
expect(props.count).to be > 0
|
61
|
-
expect(props['groups'].count).to be > 0
|
62
|
-
expect(props['properties'].count).to be > 0
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe 'hubspot:restore_properties' do
|
67
|
-
let :run_rake_task do
|
68
|
-
Rake::Task['hubspot:restore_properties'].reenable
|
69
|
-
Rake.application.invoke_task "hubspot:restore_properties[deal,#{file},#{hapikey}]"
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should not need to make any changes' do
|
73
|
-
pending 'Hubspot disabled this call using the demo hapikey'
|
74
|
-
|
75
|
-
results = capture_stdout { run_rake_task }
|
76
|
-
expect(results.include?('Created: ')).to be_false
|
77
|
-
expect(results.include?('Updated: ')).to be_false
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
def capture_stdout
|
84
|
-
previous, $stdout = $stdout, StringIO.new
|
85
|
-
yield
|
86
|
-
$stdout.string
|
87
|
-
ensure
|
88
|
-
$stdout = previous
|
89
|
-
end
|
90
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
describe "Companies API Live test", live: true do
|
2
|
-
# Let's try to hit all the API endpoints at least once
|
3
|
-
|
4
|
-
before do
|
5
|
-
Hubspot.configure hapikey: "demo"
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'find, update, batch_update and destroy a company' do
|
9
|
-
companies = Hubspot::Company.find_by_domain("create-delete-test.com")
|
10
|
-
companies.first.destroy! if companies.any?
|
11
|
-
|
12
|
-
company = Hubspot::Company.create!("Create Delete Test", domain: "create-delete-test.com")
|
13
|
-
expect(company).to be_present
|
14
|
-
|
15
|
-
company.update! name: "Create Delete Test 2"
|
16
|
-
company = Hubspot::Company.find_by_id(company.vid)
|
17
|
-
|
18
|
-
|
19
|
-
expect(company["name"]).to eql "Create Delete Test 2"
|
20
|
-
|
21
|
-
Hubspot::Company.batch_update!([{objectId: company.vid, name: 'Batch Update'}])
|
22
|
-
sleep 0.5 # prevent bulk update hasn't finished propagation
|
23
|
-
company = Hubspot::Company.find_by_id(company.vid)
|
24
|
-
|
25
|
-
expect(company["name"]).to eql "Batch Update"
|
26
|
-
|
27
|
-
expect(company.destroy!).to be_true
|
28
|
-
expect(Hubspot::Company.find_by_domain("create-delete-test.com")).to eq []
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
describe 'Company Properties API Live test', live: true do
|
2
|
-
# Let's try to hit all the API endpoints at least once
|
3
|
-
|
4
|
-
before do
|
5
|
-
Hubspot.configure hapikey: "demo"
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should return a list of properties' do
|
9
|
-
result = Hubspot::CompanyProperties.all
|
10
|
-
|
11
|
-
expect(result.count).to be > 0
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should return a list of properties for the specified groups' do
|
15
|
-
group_names = %w(companyinformation)
|
16
|
-
|
17
|
-
result = Hubspot::CompanyProperties.all({}, { include: group_names })
|
18
|
-
expect(result.count).to be > 0
|
19
|
-
result.each do |entry|
|
20
|
-
expect(group_names.include?(entry['groupName']))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should return a list of properties except for the specified groups' do
|
25
|
-
group_names = %w(companyinformation)
|
26
|
-
|
27
|
-
result = Hubspot::CompanyProperties.all({}, { exclude: group_names })
|
28
|
-
expect(result.count).to be > 0
|
29
|
-
result.each do |entry|
|
30
|
-
expect(group_names.include?(entry['groupName'])).to be_false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should return a list of groups' do
|
35
|
-
result = Hubspot::CompanyProperties.groups
|
36
|
-
|
37
|
-
expect(result.count).to be > 0
|
38
|
-
expect(result[0].slice(*%w(name displayName displayOrder)).count).to eq(3)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should return list of groups and their properties' do
|
42
|
-
result = Hubspot::CompanyProperties.groups({ includeProperties: true })
|
43
|
-
|
44
|
-
expect(result.count).to be > 0
|
45
|
-
expect(result[0].slice(*%w(name displayName displayOrder properties)).count).to eq(4)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should return only the requested groups' do
|
49
|
-
group_names = %w(companyinformation )
|
50
|
-
result = Hubspot::CompanyProperties.groups({}, { include: group_names })
|
51
|
-
|
52
|
-
expect(result.count).to eq(group_names.count)
|
53
|
-
result.each do |entry|
|
54
|
-
expect(group_names.include?(entry['name']))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should filter out the excluded groups' do
|
59
|
-
group_names = %w(companyinformation )
|
60
|
-
result = Hubspot::CompanyProperties.groups({}, { exclude: group_names })
|
61
|
-
|
62
|
-
result.each do |entry|
|
63
|
-
expect(group_names.include?(entry['name'])).to be_false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'should create, update, and delete properties' do
|
68
|
-
let(:data) {
|
69
|
-
{ 'name' => 'testfield909',
|
70
|
-
'label' => 'A test property',
|
71
|
-
'description' => 'This is a test property',
|
72
|
-
'groupName' => 'companyinformation',
|
73
|
-
'type' => 'string',
|
74
|
-
'fieldType' => 'text',
|
75
|
-
'formField' => false }
|
76
|
-
}
|
77
|
-
|
78
|
-
it 'should create a new property' do
|
79
|
-
response = Hubspot::CompanyProperties.create!(data)
|
80
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should update an existing property' do
|
84
|
-
data['label'] = 'An updated test property'
|
85
|
-
|
86
|
-
response = Hubspot::CompanyProperties.update!(data['name'], data)
|
87
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should delete an existing property' do
|
91
|
-
response = Hubspot::CompanyProperties.delete!(data['name'])
|
92
|
-
expect(response).to be nil
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'should create, update, and delete property groups' do
|
97
|
-
let(:data) {
|
98
|
-
{ 'name' => 'testgroup99',
|
99
|
-
'displayName' => 'Test Group 99'
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
it 'should create a new property group' do
|
104
|
-
response = Hubspot::CompanyProperties.create_group!(data)
|
105
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'should update an existing property group' do
|
109
|
-
data['displayName'] = 'Test Group 99 Modified'
|
110
|
-
|
111
|
-
response = Hubspot::CompanyProperties.update_group!(data['name'], data)
|
112
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'should delete an existing property group' do
|
116
|
-
response = Hubspot::CompanyProperties.delete_group!(data['name'])
|
117
|
-
expect(response).to be nil
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
describe "Contacts API Live test", live: true do
|
2
|
-
# Let's try to hit all the API endpoints at least once
|
3
|
-
|
4
|
-
before do
|
5
|
-
Hubspot.configure hapikey: "demo"
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'find, update and destroy a contact' do
|
9
|
-
contact = Hubspot::Contact.find_by_email("create_delete_test@hsgemtest.com")
|
10
|
-
contact.destroy! if contact
|
11
|
-
|
12
|
-
contact = Hubspot::Contact.create!("create_delete_test@hsgemtest.com")
|
13
|
-
expect(contact).to be_present
|
14
|
-
|
15
|
-
contact.update! firstname: "Clint", lastname: "Eastwood"
|
16
|
-
contact = Hubspot::Contact.find_by_id(contact.vid)
|
17
|
-
|
18
|
-
expect(contact["firstname"]).to eql "Clint"
|
19
|
-
expect(contact["lastname"]).to eql "Eastwood"
|
20
|
-
|
21
|
-
expect(contact.destroy!).to be_true
|
22
|
-
expect(Hubspot::Contact.find_by_email("create_delete_test@hsgemtest.com")).to be_nil
|
23
|
-
end
|
24
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
describe 'Contact Properties API Live test', live: true do
|
2
|
-
# Let's try to hit all the API endpoints at least once
|
3
|
-
|
4
|
-
before do
|
5
|
-
Hubspot.configure hapikey: "demo"
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should return a list of properties' do
|
9
|
-
result = Hubspot::ContactProperties.all
|
10
|
-
|
11
|
-
expect(result.count).to be > 0
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should return a list of properties for the specified groups' do
|
15
|
-
group_names = %w(contactinformation salesforceinformation)
|
16
|
-
|
17
|
-
result = Hubspot::ContactProperties.all({}, { include: group_names })
|
18
|
-
expect(result.count).to be > 0
|
19
|
-
result.each do |entry|
|
20
|
-
expect(group_names.include?(entry['groupName']))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should return a list of properties except for the specified groups' do
|
25
|
-
group_names = %w(contactinformation salesforceinformation)
|
26
|
-
|
27
|
-
result = Hubspot::ContactProperties.all({}, { exclude: group_names })
|
28
|
-
expect(result.count).to be > 0
|
29
|
-
result.each do |entry|
|
30
|
-
expect(group_names.include?(entry['groupName'])).to be_false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should return a list of groups' do
|
35
|
-
result = Hubspot::ContactProperties.groups
|
36
|
-
|
37
|
-
expect(result.count).to be > 0
|
38
|
-
expect(result[0].slice(*%w(name displayName displayOrder)).count).to eq(3)
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should return list of groups and their properties' do
|
42
|
-
result = Hubspot::ContactProperties.groups({ includeProperties: true })
|
43
|
-
|
44
|
-
expect(result.count).to be > 0
|
45
|
-
expect(result[0].slice(*%w(name displayName displayOrder properties)).count).to eq(4)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should return only the requested groups' do
|
49
|
-
group_names = %w(contactinformation salesforceinformation)
|
50
|
-
result = Hubspot::ContactProperties.groups({}, { include: group_names })
|
51
|
-
|
52
|
-
expect(result.count).to eq(group_names.count)
|
53
|
-
result.each do |entry|
|
54
|
-
expect(group_names.include?(entry['name']))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should filter out the excluded groups' do
|
59
|
-
group_names = %w(contactinformation salesforceinformation)
|
60
|
-
result = Hubspot::ContactProperties.groups({}, { exclude: group_names })
|
61
|
-
|
62
|
-
result.each do |entry|
|
63
|
-
expect(group_names.include?(entry['name'])).to be_false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'should create, update, and delete properties' do
|
68
|
-
let(:data) {
|
69
|
-
{ 'name' => 'testfield909',
|
70
|
-
'label' => 'A test property',
|
71
|
-
'description' => 'This is a test property',
|
72
|
-
'groupName' => 'contactinformation',
|
73
|
-
'type' => 'string',
|
74
|
-
'fieldType' => 'text',
|
75
|
-
'formField' => false }
|
76
|
-
}
|
77
|
-
|
78
|
-
it 'should create a new property' do
|
79
|
-
response = Hubspot::ContactProperties.create!(data)
|
80
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should update an existing property' do
|
84
|
-
data['label'] = 'An updated test property'
|
85
|
-
|
86
|
-
response = Hubspot::ContactProperties.update!(data['name'], data)
|
87
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'should delete an existing property' do
|
91
|
-
response = Hubspot::ContactProperties.delete!(data['name'])
|
92
|
-
expect(response).to be nil
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'should create, update, and delete property groups' do
|
97
|
-
let(:data) {
|
98
|
-
{ 'name' => 'testgroup99',
|
99
|
-
'displayName' => 'Test Group 99'
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
it 'should create a new property group' do
|
104
|
-
response = Hubspot::ContactProperties.create_group!(data)
|
105
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'should update an existing property group' do
|
109
|
-
data['displayName'] = 'Test Group 99 Modified'
|
110
|
-
|
111
|
-
response = Hubspot::ContactProperties.update_group!(data['name'], data)
|
112
|
-
data.map { |key, val| expect(response[key]).to eql(val) }
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'should delete an existing property group' do
|
116
|
-
response = Hubspot::ContactProperties.delete_group!(data['name'])
|
117
|
-
expect(response).to be nil
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|