hubspot-api-ruby 0.19.0 → 0.21.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/association.rb +14 -13
- data/lib/hubspot/conversation_thread.rb +27 -0
- data/lib/hubspot/owner.rb +39 -25
- data/lib/hubspot-api-ruby.rb +1 -0
- data/spec/lib/hubspot/conversation_thread_spec.rb +25 -0
- data/spec/lib/hubspot/owner_spec.rb +17 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3d7600de11889f3e5dfe562ccec90bb6c1edd20b866c972e35ae11c1ce3bacf
|
4
|
+
data.tar.gz: 65698aa080bdb71c8c0e05436cd36af6981b3f1d8c79de9e7e95c32888b9e252
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49597d6095f36055416f3610e5e7b1059a6f08829b9e3a9c248b753f2ad133d31087edcb6c86f5100cd66bb939d33b8ea1c9fab321012a8a9c5394b3c7ec9368
|
7
|
+
data.tar.gz: 6ebf057a56f6d2d643c2582d96f7f8fd8002cfe7088a72d0bec190dc62e06961470f04b18121d87f2d0b42abe3f2bda6821a63294590e1d536be412b0cd6c472
|
data/hubspot-api-ruby.gemspec
CHANGED
data/lib/hubspot/association.rb
CHANGED
@@ -6,29 +6,30 @@ class Hubspot::Association
|
|
6
6
|
}.freeze
|
7
7
|
|
8
8
|
ASSOCIATION_DEFINITIONS = {
|
9
|
+
"Contact" => {
|
10
|
+
"Deal" => 4
|
11
|
+
},
|
9
12
|
"Company" => {
|
10
13
|
"Contact" => 2,
|
11
|
-
"
|
12
|
-
"
|
14
|
+
"Company" => 13,
|
15
|
+
"Deal" => 6
|
13
16
|
},
|
14
17
|
"Deal" => {
|
15
|
-
"
|
16
|
-
"
|
18
|
+
"Contact" => 3,
|
19
|
+
"Company" => 5
|
17
20
|
},
|
18
|
-
"
|
19
|
-
"
|
21
|
+
"Task" => {
|
22
|
+
"Contact" => 204,
|
23
|
+
"Company" => 192,
|
24
|
+
"Deal" => 216,
|
25
|
+
"Ticket" => 230
|
20
26
|
},
|
21
27
|
"Ticket" => {
|
22
28
|
"Contact" => 16,
|
23
|
-
"
|
29
|
+
"Conversation" => 32,
|
24
30
|
"Company" => 339,
|
31
|
+
"Deal" => 28,
|
25
32
|
"Task" => 229
|
26
|
-
},
|
27
|
-
"Task" => {
|
28
|
-
"Contact" => 204,
|
29
|
-
"Deal" => 216,
|
30
|
-
"Company" => 192,
|
31
|
-
"Ticket" => 230
|
32
33
|
}
|
33
34
|
}.freeze
|
34
35
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'hubspot/utils'
|
2
|
+
|
3
|
+
module Hubspot
|
4
|
+
#
|
5
|
+
# HubSpot Tasks API
|
6
|
+
#
|
7
|
+
# {https://developers.hubspot.com/docs/reference/api/conversations/inbox-and-messages}
|
8
|
+
#
|
9
|
+
class ConversationThread
|
10
|
+
THREAD_PATH = '/conversations/v3/conversations/threads/:thread_id'
|
11
|
+
|
12
|
+
attr_reader :properties, :id
|
13
|
+
|
14
|
+
def initialize(response_hash)
|
15
|
+
@id = response_hash['id']
|
16
|
+
@properties = response_hash.deep_symbolize_keys
|
17
|
+
end
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def find(thread_id, with_associations: false)
|
21
|
+
association = with_associations ? ['TICKET'] : []
|
22
|
+
response = Hubspot::Connection.get_json(THREAD_PATH, thread_id:, association:)
|
23
|
+
new(response)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
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
|
data/lib/hubspot-api-ruby.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec.describe Hubspot::ConversationThread do
|
2
|
+
describe 'find' do
|
3
|
+
let(:thread_id) { 3_176_297_853 }
|
4
|
+
|
5
|
+
subject(:existing_thread) { described_class.find(thread_id, with_associations: true) }
|
6
|
+
|
7
|
+
it 'gets existing conversation thread' do
|
8
|
+
VCR.use_cassette 'conversation_thread_find' do
|
9
|
+
expect(existing_thread.id).not_to be_nil
|
10
|
+
expect(existing_thread.properties[:status]).to eq('OPEN')
|
11
|
+
expect(existing_thread.properties[:threadAssociations]).to eq(associatedTicketId: '21514722825')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when task does not exist' do
|
16
|
+
let(:thread_id) { 996_174_569_112 }
|
17
|
+
|
18
|
+
it 'raises an error' do
|
19
|
+
VCR.use_cassette 'conversation_thread_find' do
|
20
|
+
expect { existing_thread }.to raise_error Hubspot::NotFoundError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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.21.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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- lib/hubspot/contact.rb
|
275
275
|
- lib/hubspot/contact_list.rb
|
276
276
|
- lib/hubspot/contact_properties.rb
|
277
|
+
- lib/hubspot/conversation_thread.rb
|
277
278
|
- lib/hubspot/custom_event.rb
|
278
279
|
- lib/hubspot/deal.rb
|
279
280
|
- lib/hubspot/deal_pipeline.rb
|
@@ -309,6 +310,7 @@ files:
|
|
309
310
|
- spec/lib/hubspot/contact_list_spec.rb
|
310
311
|
- spec/lib/hubspot/contact_properties_spec.rb
|
311
312
|
- spec/lib/hubspot/contact_spec.rb
|
313
|
+
- spec/lib/hubspot/conversation_thread_spec.rb
|
312
314
|
- spec/lib/hubspot/custom_event_spec.rb
|
313
315
|
- spec/lib/hubspot/deal_pipeline_spec.rb
|
314
316
|
- spec/lib/hubspot/deal_properties_spec.rb
|