hubspot-api-ruby 0.13.0 → 0.14.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/meeting.rb +47 -2
- data/spec/factories/contacts.rb +2 -2
- data/spec/lib/hubspot/contact_spec.rb +2 -2
- data/spec/lib/hubspot/meeting_spec.rb +81 -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: effa2b66c983b7633d912e80b23c1bc2c6faa6fee1905ad3ddcd571fcc2d619f
|
4
|
+
data.tar.gz: 7049786deace29ba3a0eaa8196ae3ab8baee711758517f4493570e9af5927554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 868839e40b04820791f786a3cb082a1fc6f081062b25f69af3f05792c1aa6f4a37dd4935a095065acb2aa23284f5d75826e0080e66ce11bc656620b90b90ecb5
|
7
|
+
data.tar.gz: fedec9a5eae9e6fd8df0465f9fd7bc9c383eaab0600671713e8c6b876c4e94be591f85e27f82da05daf023c9ccb7b773a954d920515ba41facc37d171d845efe
|
data/hubspot-api-ruby.gemspec
CHANGED
data/lib/hubspot/meeting.rb
CHANGED
@@ -7,11 +7,42 @@ module Hubspot
|
|
7
7
|
#
|
8
8
|
# {https://developers.hubspot.com/docs/api/crm/meetings}
|
9
9
|
#
|
10
|
-
|
10
|
+
MEETINGS_PATH = '/crm/v3/objects/meetings'
|
11
11
|
MEETING_PATH = '/crm/v3/objects/meetings/:meeting_id'
|
12
|
+
MEETING_SEARCH_PATH = '/crm/v3/objects/meetings/search'
|
12
13
|
ASSOCIATE_MEETING_PATH = '/crm/v3/objects/meetings/:meeting_id/associations/Contact/:contact_id/meeting_event_to_contact'
|
13
14
|
|
15
|
+
BASE_PROPERTIES = %w[hubspot_owner_id hs_meeting_title hs_meeting_body hs_meeting_start_time hs_meeting_end_time].freeze
|
16
|
+
|
14
17
|
class << self
|
18
|
+
def all(opts = {})
|
19
|
+
options = { properties: BASE_PROPERTIES.join(','), **opts.compact }
|
20
|
+
response = Hubspot::Connection.get_json(MEETINGS_PATH, options)
|
21
|
+
meetings = response['results'].map { |result| new(result) }
|
22
|
+
|
23
|
+
{
|
24
|
+
meetings: meetings,
|
25
|
+
after: response.dig('paging', 'next', 'after')
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def find(id)
|
30
|
+
response = Hubspot::Connection.get_json(MEETING_PATH, { meeting_id: id, properties: BASE_PROPERTIES.join(',') })
|
31
|
+
new(response)
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_by_contact(contact_id)
|
35
|
+
response = Hubspot::Connection.post_json(MEETING_SEARCH_PATH, {
|
36
|
+
params: {},
|
37
|
+
body: {
|
38
|
+
properties: BASE_PROPERTIES,
|
39
|
+
filters: [{ propertyName: 'associations.contact', 'operator': 'EQ', value: contact_id }]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
)
|
43
|
+
response['results'].map { |f| new(f) }
|
44
|
+
end
|
45
|
+
|
15
46
|
def create!(owner_id, meeting_title, meeting_body, start_date_time, end_date_time)
|
16
47
|
body = {
|
17
48
|
properties: {
|
@@ -24,7 +55,7 @@ module Hubspot
|
|
24
55
|
hs_meeting_outcome: 'SCHEDULED'
|
25
56
|
}
|
26
57
|
}
|
27
|
-
response = Hubspot::Connection.post_json(
|
58
|
+
response = Hubspot::Connection.post_json(MEETINGS_PATH, params: {}, body: body)
|
28
59
|
HashWithIndifferentAccess.new(response)
|
29
60
|
end
|
30
61
|
|
@@ -40,5 +71,19 @@ module Hubspot
|
|
40
71
|
})
|
41
72
|
end
|
42
73
|
end
|
74
|
+
|
75
|
+
attr_reader :id
|
76
|
+
attr_reader :properties
|
77
|
+
|
78
|
+
def initialize(hash)
|
79
|
+
self.send(:assign_properties, hash)
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def assign_properties(hash)
|
85
|
+
@id = hash['id']
|
86
|
+
@properties = hash['properties'].deep_symbolize_keys
|
87
|
+
end
|
43
88
|
end
|
44
89
|
end
|
data/spec/factories/contacts.rb
CHANGED
@@ -5,6 +5,6 @@ FactoryBot.define do
|
|
5
5
|
|
6
6
|
firstname { Faker::Name.first_name }
|
7
7
|
lastname { Faker::Name.last_name }
|
8
|
-
email { Faker::Internet.safe_email("#{Time.new.to_i.to_s[-5..-1]}#{(0..3).map { (65 + rand(26)).chr }.join}") }
|
8
|
+
email { Faker::Internet.safe_email(name: "#{Time.new.to_i.to_s[-5..-1]}#{(0..3).map { (65 + rand(26)).chr }.join}") }
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
@@ -42,7 +42,7 @@ RSpec.describe Hubspot::Contact do
|
|
42
42
|
context 'without properties' do
|
43
43
|
cassette
|
44
44
|
|
45
|
-
let(:email) { Faker::Internet.safe_email("#{(0..3).map { (65 + rand(26)).chr }.join}#{Time.new.to_i.to_s[-5..-1]}") }
|
45
|
+
let(:email) { Faker::Internet.safe_email(name: "#{(0..3).map { (65 + rand(26)).chr }.join}#{Time.new.to_i.to_s[-5..-1]}") }
|
46
46
|
subject { described_class.create email }
|
47
47
|
|
48
48
|
it 'creates a new contact' do
|
@@ -54,7 +54,7 @@ RSpec.describe Hubspot::Contact do
|
|
54
54
|
context 'with properties' do
|
55
55
|
cassette
|
56
56
|
|
57
|
-
let(:email) { Faker::Internet.safe_email("#{(0..3).map { (65 + rand(26)).chr }.join}#{Time.new.to_i.to_s[-5..-1]}") }
|
57
|
+
let(:email) { Faker::Internet.safe_email(name: "#{(0..3).map { (65 + rand(26)).chr }.join}#{Time.new.to_i.to_s[-5..-1]}") }
|
58
58
|
let(:firstname) { "Allison" }
|
59
59
|
let(:properties) { { firstname: firstname } }
|
60
60
|
|
@@ -12,6 +12,87 @@ RSpec.describe Hubspot::Meeting do
|
|
12
12
|
let(:hs_meeting_start_time) { DateTime.strptime('2022-05-03T10:00:00+01:00', '%Y-%m-%dT%H:%M:%S%z') }
|
13
13
|
let(:hs_meeting_end_time) { DateTime.strptime('2022-05-03T10:15:00+01:00', '%Y-%m-%dT%H:%M:%S%z') }
|
14
14
|
|
15
|
+
describe '.all' do
|
16
|
+
let(:options) { {} }
|
17
|
+
subject(:all) do
|
18
|
+
described_class.all(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'retrieves all the meetings with default limit' do
|
22
|
+
VCR.use_cassette 'meeting_all' do
|
23
|
+
meetings = all
|
24
|
+
expect(meetings).not_to be_nil
|
25
|
+
expect(meetings[:meetings].many?).to be true
|
26
|
+
expect(meetings[:meetings].first).to be_a(Hubspot::Meeting)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with a limit' do
|
31
|
+
let(:options) { { limit: 2 } }
|
32
|
+
it 'retrieves all the meetings within limit' do
|
33
|
+
VCR.use_cassette 'meeting_all_limit' do
|
34
|
+
meetings = all
|
35
|
+
expect(meetings).not_to be_nil
|
36
|
+
expect(meetings[:meetings].count).to eq 2
|
37
|
+
expect(meetings[:meetings].first).to be_a(Hubspot::Meeting)
|
38
|
+
expect(meetings[:after]).not_to be nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with a limit and an after param' do
|
44
|
+
let(:options) { { limit: 3, after: '12642400565' } }
|
45
|
+
|
46
|
+
it 'retrives the next meetings within limit after a given id' do
|
47
|
+
VCR.use_cassette 'meeting_all_limit_after' do
|
48
|
+
meetings = all
|
49
|
+
expect(meetings).not_to be_nil
|
50
|
+
expect(meetings[:meetings].count).to eq 3
|
51
|
+
expect(meetings[:meetings].first).to be_a(Hubspot::Meeting)
|
52
|
+
expect(meetings[:after]).not_to be nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.find' do
|
59
|
+
subject(:find) do
|
60
|
+
described_class.find(27195487241)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'retrieves the meeting' do
|
64
|
+
VCR.use_cassette 'meeting_find' do
|
65
|
+
meeting = find
|
66
|
+
expect(meeting).not_to be_nil
|
67
|
+
expect(meeting.properties[:hubspot_owner_id]).not_to be nil
|
68
|
+
expect(meeting.properties[:hs_meeting_title]).not_to be nil
|
69
|
+
expect(meeting.properties[:hs_meeting_body]).not_to be nil
|
70
|
+
expect(meeting.properties[:hs_meeting_start_time]).not_to be nil
|
71
|
+
expect(meeting.properties[:hs_meeting_end_time]).not_to be nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe ".find_by_contact" do
|
77
|
+
subject(:find_by_contact) do
|
78
|
+
described_class.find_by_contact(1451)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'retrieves meetings' do
|
82
|
+
VCR.use_cassette 'meeting_find_by_contact' do
|
83
|
+
meetings = find_by_contact
|
84
|
+
first_meeting = meetings.first
|
85
|
+
expect(meetings).not_to be_nil
|
86
|
+
expect(first_meeting).not_to be_nil
|
87
|
+
expect(first_meeting.properties[:hubspot_owner_id]).not_to be nil
|
88
|
+
expect(first_meeting.properties[:hs_meeting_title]).not_to be nil
|
89
|
+
expect(first_meeting.properties[:hs_meeting_body]).not_to be nil
|
90
|
+
expect(first_meeting.properties[:hs_meeting_start_time]).not_to be nil
|
91
|
+
expect(first_meeting.properties[:hs_meeting_end_time]).not_to be nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
15
96
|
describe '.create' do
|
16
97
|
context 'with properties' do
|
17
98
|
|
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.14.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-11-07 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
|