hubspot-api-ruby 0.19.0 → 0.20.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/hubspot-api-ruby.gemspec +1 -1
- data/lib/hubspot/owner.rb +39 -25
- data/spec/lib/hubspot/owner_spec.rb +17 -2
- 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: 98ed008fd84b2f589251de5d0419a1e22823df7767b59d1e19df1a8f30ac11c3
|
4
|
+
data.tar.gz: 5586bece57acb191f44e73eed781b6e122c3e072b84d6eadee6ee5cb0d4c8344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff09103b5a37c8a50a10ec24e1feba246af33b4d8f39512817ad6f1e505c1a37a5ca3b40fe5db7ca9d9da02f1ca6fd17ba1359d095a5952794e313b2398a5fa
|
7
|
+
data.tar.gz: dda419b3e0d59f80d1126b8bcb4e5d057c3e8ea869c0595be1ea8a21c6702d418630ec18431204817cf58943d25fecfaccc23727e99008f790e1c083f3fd105b
|
data/hubspot-api-ruby.gemspec
CHANGED
data/lib/hubspot/owner.rb
CHANGED
@@ -2,24 +2,21 @@ module Hubspot
|
|
2
2
|
#
|
3
3
|
# HubSpot Owners API
|
4
4
|
#
|
5
|
-
# {
|
5
|
+
# {https://developers.hubspot.com/docs/reference/api/crm/owners/v3}
|
6
|
+
#
|
6
7
|
#
|
7
|
-
# TODO: Create an Owner
|
8
|
-
# TODO: Update an Owner
|
9
|
-
# TODO: Delete an Owner
|
10
8
|
class Owner
|
11
|
-
GET_OWNER_PATH = '/
|
12
|
-
GET_OWNERS_PATH = '/
|
13
|
-
CREATE_OWNER_PATH =
|
14
|
-
UPDATE_OWNER_PATH = '/
|
15
|
-
DELETE_OWNER_PATH = '/
|
16
|
-
|
9
|
+
GET_OWNER_PATH = '/crm/v3/owners/:owner_id' # GET
|
10
|
+
GET_OWNERS_PATH = '/crm/v3/owners' # GET
|
11
|
+
CREATE_OWNER_PATH = "/crm/v3/owners" # POST
|
12
|
+
UPDATE_OWNER_PATH = '/crm/v3/owners/:owner_id' # PUT
|
13
|
+
DELETE_OWNER_PATH = '/crm/v3/owners/:owner_id' # DELETE
|
17
14
|
|
18
15
|
attr_reader :properties, :owner_id, :email
|
19
16
|
|
20
17
|
def initialize(property_hash)
|
21
18
|
@properties = property_hash
|
22
|
-
@owner_id = @properties['
|
19
|
+
@owner_id = @properties['id']
|
23
20
|
@email = @properties['email']
|
24
21
|
end
|
25
22
|
|
@@ -28,29 +25,46 @@ module Hubspot
|
|
28
25
|
end
|
29
26
|
|
30
27
|
class << self
|
31
|
-
def all(
|
32
|
-
path
|
33
|
-
params
|
28
|
+
def all(include_archived: false, limit: 100, after: nil)
|
29
|
+
path = GET_OWNERS_PATH
|
30
|
+
params = {
|
31
|
+
archived: include_archived,
|
32
|
+
limit: limit,
|
33
|
+
after: after
|
34
|
+
}.compact
|
35
|
+
|
34
36
|
response = Hubspot::Connection.get_json(path, params)
|
35
|
-
|
37
|
+
{
|
38
|
+
results: response['results'].map { |r| new(r) },
|
39
|
+
pagination: {
|
40
|
+
next: response['paging']&.dig('next', 'after'),
|
41
|
+
total: response['total']
|
42
|
+
}
|
43
|
+
}
|
36
44
|
end
|
37
45
|
|
38
|
-
def find(id,
|
39
|
-
path
|
40
|
-
|
41
|
-
|
46
|
+
def find(id, id_property: nil)
|
47
|
+
path = GET_OWNER_PATH
|
48
|
+
params = { owner_id: id }
|
49
|
+
params[:idProperty] = id_property if id_property
|
50
|
+
response = Hubspot::Connection.get_json(path, params)
|
42
51
|
new(response)
|
43
52
|
end
|
44
53
|
|
45
|
-
def find_by_email(email,
|
46
|
-
path
|
47
|
-
params
|
54
|
+
def find_by_email(email, include_archived: false, limit: 100, after: nil)
|
55
|
+
path = GET_OWNERS_PATH
|
56
|
+
params = {
|
57
|
+
email: email,
|
58
|
+
archived: include_archived,
|
59
|
+
limit: limit,
|
60
|
+
after: after
|
61
|
+
}.compact
|
48
62
|
response = Hubspot::Connection.get_json(path, params)
|
49
|
-
response.blank? ? nil : new(response.first)
|
63
|
+
response['results'].blank? ? nil : new(response['results'].first)
|
50
64
|
end
|
51
65
|
|
52
|
-
def find_by_emails(emails,
|
53
|
-
emails.map { |email| find_by_email(email,
|
66
|
+
def find_by_emails(emails = [], include_archived: false)
|
67
|
+
emails.map { |email| find_by_email(email, include_archived: include_archived) }.reject(&:nil?)
|
54
68
|
end
|
55
69
|
end
|
56
70
|
end
|
@@ -2,7 +2,7 @@ describe Hubspot::Owner do
|
|
2
2
|
let(:example_owners) do
|
3
3
|
VCR.use_cassette('owner_example') do
|
4
4
|
headers = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }
|
5
|
-
HTTParty.get('https://api.hubapi.com/
|
5
|
+
HTTParty.get('https://api.hubapi.com/crm/v3/owners', headers: headers).parsed_response['results']
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -13,7 +13,22 @@ describe Hubspot::Owner do
|
|
13
13
|
owners = Hubspot::Owner.all
|
14
14
|
|
15
15
|
expect(owners.blank?).to be false
|
16
|
-
|
16
|
+
expect(owners[:results].blank?).to be false
|
17
|
+
compare_owners(owners[:results], example_owners)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.find' do
|
22
|
+
cassette 'owner_find_by_id'
|
23
|
+
|
24
|
+
let(:sample) { example_owners.first }
|
25
|
+
let(:id) { sample['id'] }
|
26
|
+
|
27
|
+
it 'should find a user via their id' do
|
28
|
+
owner = Hubspot::Owner.find(id)
|
29
|
+
sample.map do |key, val|
|
30
|
+
expect(owner[key]).to eq(val)
|
31
|
+
end
|
17
32
|
end
|
18
33
|
end
|
19
34
|
|
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.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -352,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
352
352
|
- !ruby/object:Gem::Version
|
353
353
|
version: '0'
|
354
354
|
requirements: []
|
355
|
-
rubygems_version: 3.5.
|
355
|
+
rubygems_version: 3.5.3
|
356
356
|
signing_key:
|
357
357
|
specification_version: 4
|
358
358
|
summary: hubspot-api-ruby is a wrapper for the HubSpot REST API
|