hubspot-api-ruby 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/hubspot-api-ruby.gemspec +1 -1
- data/lib/hubspot/company_properties.rb +10 -0
- data/lib/hubspot/contact_properties.rb +10 -0
- data/lib/hubspot/deal_properties.rb +10 -0
- data/lib/hubspot/properties.rb +8 -0
- data/spec/lib/hubspot/company_properties_spec.rb +40 -0
- data/spec/lib/hubspot/contact_properties_spec.rb +40 -0
- data/spec/lib/hubspot/deal_properties_spec.rb +40 -0
- metadata +3 -3
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
@@ -37,8 +37,9 @@ Hubspot.configure({
|
|
37
37
|
client_id: <CLIENT_ID>,
|
38
38
|
client_secret: <CLIENT_SECRET>,
|
39
39
|
redirect_uri: <REDIRECT_URI>,
|
40
|
-
read_timeout: nil,
|
40
|
+
read_timeout: nil,
|
41
41
|
open_timeout: nil,
|
42
|
+
# read_timeout and open_timeout are expressed in seconds and passed to HTTParty
|
42
43
|
hapikey: <HAPIKEY>,
|
43
44
|
})
|
44
45
|
```
|
@@ -169,6 +170,7 @@ Some requests require to be done on a live hubspot portal, you can set the `HUBS
|
|
169
170
|
```
|
170
171
|
HUBSPOT_ACCESS_TOKEN=xxxx
|
171
172
|
HUBSPOT_PORTAL_ID=yyyy
|
173
|
+
HUBSPOT_HAPI_KEY=zzzz
|
172
174
|
```
|
173
175
|
|
174
176
|
To add a new test or update a VCR recording, run the test with the `VCR_RECORD_MODE`
|
data/hubspot-api-ruby.gemspec
CHANGED
@@ -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
|
@@ -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/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?
|
@@ -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
|
@@ -38,6 +38,26 @@ describe Hubspot::ContactProperties do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
describe '.find' do
|
42
|
+
context 'existing property' do
|
43
|
+
cassette 'contact_properties/existing_property'
|
44
|
+
|
45
|
+
it 'should return a contact property by name if it exists' do
|
46
|
+
response = Hubspot::ContactProperties.find('full_name')
|
47
|
+
expect(response['name']).to eq 'full_name'
|
48
|
+
expect(response['label']).to eq 'Full name'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'non-existent property' do
|
53
|
+
cassette 'contact_properties/non_existent_property'
|
54
|
+
|
55
|
+
it 'should return an error for a missing property' do
|
56
|
+
expect{ Hubspot::ContactProperties.find('this_does_not_exist') }.to raise_error(Hubspot::NotFoundError)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
41
61
|
let(:params) { {
|
42
62
|
'name' => 'my_new_property',
|
43
63
|
'label' => 'This is my new property',
|
@@ -141,6 +161,26 @@ describe Hubspot::ContactProperties do
|
|
141
161
|
end
|
142
162
|
end
|
143
163
|
|
164
|
+
describe '.find_group' do
|
165
|
+
context 'existing group' do
|
166
|
+
cassette 'contact_properties/existing_group'
|
167
|
+
|
168
|
+
it 'should return a contact property by name if it exists' do
|
169
|
+
response = Hubspot::ContactProperties.find_group('contactinformation')
|
170
|
+
expect(response['name']).to eq 'contactinformation'
|
171
|
+
expect(response['displayName']).to eq 'Contact information'
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'non-existent group' do
|
176
|
+
cassette 'contact_properties/non_existent_group'
|
177
|
+
|
178
|
+
it 'should return an error for a missing group' do
|
179
|
+
expect{ Hubspot::ContactProperties.find_group('this_does_not_exist') }.to raise_error(Hubspot::NotFoundError)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
144
184
|
let(:params) { { 'name' => 'ff_group1', 'displayName' => 'Test Group One', 'displayOrder' => 100, 'badParam' => 99 } }
|
145
185
|
|
146
186
|
describe '.create_group!' do
|
@@ -37,6 +37,26 @@ describe Hubspot::DealProperties do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
describe '.find' do
|
42
|
+
context 'existing property' do
|
43
|
+
cassette 'deal_properties/existing_property'
|
44
|
+
|
45
|
+
it 'should return a deal property by name if it exists' do
|
46
|
+
response = Hubspot::DealProperties.find('hs_acv')
|
47
|
+
expect(response['name']).to eq 'hs_acv'
|
48
|
+
expect(response['label']).to eq 'Annual contract value'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'non-existent property' do
|
53
|
+
cassette 'deal_properties/non_existent_property'
|
54
|
+
|
55
|
+
it 'should return an error for a missing property' do
|
56
|
+
expect{ Hubspot::DealProperties.find('this_does_not_exist') }.to raise_error(Hubspot::NotFoundError)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
40
60
|
|
41
61
|
let(:params) { {
|
42
62
|
'name' => "my_new_property_#{SecureRandom.hex}",
|
@@ -140,6 +160,26 @@ describe Hubspot::DealProperties do
|
|
140
160
|
end
|
141
161
|
end
|
142
162
|
|
163
|
+
describe '.find_group' do
|
164
|
+
context 'existing group' do
|
165
|
+
cassette 'deal_properties/existing_group'
|
166
|
+
|
167
|
+
it 'should return a deal property by name if it exists' do
|
168
|
+
response = Hubspot::DealProperties.find_group('deal_revenue')
|
169
|
+
expect(response['name']).to eq 'deal_revenue'
|
170
|
+
expect(response['displayName']).to eq 'Deal revenue'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context 'non-existent group' do
|
175
|
+
cassette 'deal_properties/non_existent_group'
|
176
|
+
|
177
|
+
it 'should return an error for a missing group' do
|
178
|
+
expect{ Hubspot::DealProperties.find_group('this_does_not_exist') }.to raise_error(Hubspot::NotFoundError)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
143
183
|
let(:params) { { 'name' => 'ff_group1', 'displayName' => 'Test Group One', 'displayOrder' => 100, 'badParam' => 99 } }
|
144
184
|
|
145
185
|
describe '.create_group!' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -346,7 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
346
346
|
- !ruby/object:Gem::Version
|
347
347
|
version: '0'
|
348
348
|
requirements: []
|
349
|
-
rubygems_version: 3.2
|
349
|
+
rubygems_version: 3.1.2
|
350
350
|
signing_key:
|
351
351
|
specification_version: 4
|
352
352
|
summary: hubspot-api-ruby is a wrapper for the HubSpot REST API
|