hubspot-api-ruby 0.10.0 → 0.12.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: 4aa748bc77ade29ff96016950aa3f3d8d9bbb309167b200319798d9edf8664bc
4
- data.tar.gz: f09d8a29a3dbbcaa18071670e46d4c10c6727731409bbf4a7eee5099d6fd15e2
3
+ metadata.gz: b3bfd2a58aeeda26ef22bb1cc16d7794397357e0b4584255c419e8f9e269cb94
4
+ data.tar.gz: 0f56e584031be6a59378c64d2922a09567c5632dbe3a67970fecf60f6c53a367
5
5
  SHA512:
6
- metadata.gz: ac1c6faae15a4569c92d8061a270f7b55aad7c64eaf2f16bc057b31312204164771600a5ebb511a0d7e0977123baf65b22125f69832dc6b2af63637bb4689814
7
- data.tar.gz: 37b874280272f531177bf348d038b5b6e935f2a4edefeef1c1c7d4e5e68c2613047a75ea782daa412053fb8f50c312d6a27d5f264509f758cd6eb82abf1afe8d
6
+ metadata.gz: 9cd0a53353924b64a5e1f6a2aca63991e9e5aff111c4e91570090ef0061058aed825d9fb9bdf29d2d9239375872d44d229b540c63a8c71e6f1893b74e3e01fba
7
+ data.tar.gz: 36b861191b970ee112f72e21624b0827d33f1ff1912924f153267c7cafd5867cf949dd3b3c44c92d077d555c419830db1e30664be6f5faabb7b0c0aaca15c973
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, # or :timeout to set read_timeout and open_timeout
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/RELEASING.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Releasing to Rubygems
2
2
 
3
- 1. Update gemspec.
4
- 2. Push updates to github.
5
- 3. Build gem with `gem build hubspot-api-ruby.gemspec`.
6
- 4. Push the resulting .gem file to Rubygems with `gem push`
3
+ 1. Update History.md
4
+ 2. Update gemspec.
5
+ 3. Push updates to github.
6
+ 4. Build gem with `gem build hubspot-api-ruby.gemspec`.
7
+ 5. Push the resulting .gem file to Rubygems with `gem push`
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hubspot-api-ruby"
3
- s.version = "0.10.0"
3
+ s.version = "0.12.0"
4
4
  s.require_paths = ["lib"]
5
5
  s.authors = ["Jonathan"]
6
6
  s.email = ["jonathan@hoggo.com"]
@@ -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
@@ -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?
@@ -1,6 +1,5 @@
1
1
  module Hubspot
2
2
  class Resource
3
-
4
3
  class_attribute :id_field, instance_writer: false
5
4
  class_attribute :property_name_field, instance_writer: false
6
5
  class_attribute :update_method, instance_writer: false
@@ -73,25 +72,15 @@ module Hubspot
73
72
  @deleted = false
74
73
  end
75
74
 
76
- def id
77
- @id
78
- end
79
-
80
- def id=(id)
81
- @id = id
82
- end
75
+ attr_accessor :id
83
76
 
84
77
  def to_i
85
78
  @id
86
79
  end
87
80
 
88
- def metadata
89
- @metadata
90
- end
91
-
92
- def changes
93
- @changes
94
- end
81
+ attr_reader :changes
82
+ attr_reader :metadata
83
+ attr_reader :properties
95
84
 
96
85
  def changed?
97
86
  !@changes.empty?
@@ -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
@@ -91,4 +91,24 @@ RSpec.describe Hubspot::Resource do
91
91
  end
92
92
  end
93
93
  end
94
+
95
+ describe '#properties' do
96
+ context 'using new' do
97
+ subject(:resource) { described_class.new(properties) }
98
+ let(:properties) { { id: 1, firstname: 'John', lastname: 'Wayne' } }
99
+
100
+ it 'has no properties' do
101
+ expect(subject.properties).to be_empty
102
+ end
103
+ end
104
+
105
+ context 'using from_result' do
106
+ subject(:resource) { described_class.from_result({ properties: properties }) }
107
+ let(:properties) { { id: { 'value' => 1 }, firstname: { 'value' => 'John' }, lastname: { 'value' => 'Wayne' } } }
108
+
109
+ it 'has properties' do
110
+ expect(subject.properties).to eq HashWithIndifferentAccess.new(properties)
111
+ end
112
+ end
113
+ end
94
114
  end
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.10.0
4
+ version: 0.12.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-08-09 00:00:00.000000000 Z
11
+ date: 2022-10-12 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.32
349
+ rubygems_version: 3.2.33
350
350
  signing_key:
351
351
  specification_version: 4
352
352
  summary: hubspot-api-ruby is a wrapper for the HubSpot REST API