hubspot-api-ruby 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: effa2b66c983b7633d912e80b23c1bc2c6faa6fee1905ad3ddcd571fcc2d619f
4
- data.tar.gz: 7049786deace29ba3a0eaa8196ae3ab8baee711758517f4493570e9af5927554
3
+ metadata.gz: 5b5da1c5b3161e39ad26020948f72dc349ec275140714ed29b470e9081c0e22d
4
+ data.tar.gz: e0fbef872458028ef540fe2fac43816980f2a4ad6862ee3acdaf68f6c12fc907
5
5
  SHA512:
6
- metadata.gz: 868839e40b04820791f786a3cb082a1fc6f081062b25f69af3f05792c1aa6f4a37dd4935a095065acb2aa23284f5d75826e0080e66ce11bc656620b90b90ecb5
7
- data.tar.gz: fedec9a5eae9e6fd8df0465f9fd7bc9c383eaab0600671713e8c6b876c4e94be591f85e27f82da05daf023c9ccb7b773a954d920515ba41facc37d171d845efe
6
+ metadata.gz: 2ddeb851b64faacbed0a42a1019d28c7a04b0899454db482188a7c53f6f9c397ad929fdf445d1143b9cfd85742d595b085e7e58c37b2de988307bc74e15665da
7
+ data.tar.gz: f2bfebd54dfecd85121f49399d271a1bd3a917b58db832639f983ca98897610e064525a43e645dda305f16d57b4316bae633b65a57289c2211a724c9ac934e8f
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hubspot-api-ruby"
3
- s.version = "0.14.0"
3
+ s.version = "0.15.0"
4
4
  s.require_paths = ["lib"]
5
5
  s.authors = ["Jonathan"]
6
6
  s.email = ["jonathan@hoggo.com"]
@@ -31,16 +31,30 @@ module Hubspot
31
31
  new(response)
32
32
  end
33
33
 
34
- def find_by_contact(contact_id)
34
+ def find_by_contact(contact_id, opts={})
35
+ params = {
36
+ limit: opts[:limit].presence || 100,
37
+ after: opts[:after].presence
38
+ }.compact
39
+
40
+ default_filters = [{ propertyName: 'associations.contact', 'operator': 'EQ', value: contact_id }]
41
+ default_sorts = [{ propertyName: "hs_lastmodifieddate", direction: "DESCENDING" }]
42
+
35
43
  response = Hubspot::Connection.post_json(MEETING_SEARCH_PATH, {
36
44
  params: {},
37
45
  body: {
46
+ **params,
38
47
  properties: BASE_PROPERTIES,
39
- filters: [{ propertyName: 'associations.contact', 'operator': 'EQ', value: contact_id }]
48
+ filters: (opts[:filters].presence || []) + default_filters,
49
+ sorts: opts[:sorts].presence || default_sorts
40
50
  }
41
51
  }
42
52
  )
43
- response['results'].map { |f| new(f) }
53
+
54
+ {
55
+ after: response.dig('paging', 'next', 'after'),
56
+ meetings: response['results'].map { |f| new(f) }
57
+ }
44
58
  end
45
59
 
46
60
  def create!(owner_id, meeting_title, meeting_body, start_date_time, end_date_time)
@@ -75,12 +75,14 @@ RSpec.describe Hubspot::Meeting do
75
75
 
76
76
  describe ".find_by_contact" do
77
77
  subject(:find_by_contact) do
78
- described_class.find_by_contact(1451)
78
+ described_class.find_by_contact(1451, opts)
79
79
  end
80
+ let(:opts) { {} }
80
81
 
81
82
  it 'retrieves meetings' do
82
83
  VCR.use_cassette 'meeting_find_by_contact' do
83
- meetings = find_by_contact
84
+ results = find_by_contact
85
+ meetings = results[:meetings]
84
86
  first_meeting = meetings.first
85
87
  expect(meetings).not_to be_nil
86
88
  expect(first_meeting).not_to be_nil
@@ -91,6 +93,47 @@ RSpec.describe Hubspot::Meeting do
91
93
  expect(first_meeting.properties[:hs_meeting_end_time]).not_to be nil
92
94
  end
93
95
  end
96
+
97
+ context 'when custom filters' do
98
+ let(:opts) { { filters: [{ propertyName: 'hs_meeting_title', 'operator': 'EQ', value: 'Hello World' }] } }
99
+
100
+ it 'retrieves meetings' do
101
+ VCR.use_cassette 'meeting_find_by_contact_custom_filters' do
102
+ results = find_by_contact
103
+ meetings = results[:meetings]
104
+ first_meeting = meetings.first
105
+ expect(meetings).not_to be_nil
106
+ expect(meetings.count).to eq 1
107
+ expect(first_meeting).not_to be_nil
108
+ expect(first_meeting.properties[:hubspot_owner_id]).not_to be nil
109
+ expect(first_meeting.properties[:hs_meeting_title]).not_to be nil
110
+ expect(first_meeting.properties[:hs_meeting_body]).not_to be nil
111
+ expect(first_meeting.properties[:hs_meeting_start_time]).not_to be nil
112
+ expect(first_meeting.properties[:hs_meeting_end_time]).not_to be nil
113
+ end
114
+ end
115
+ end
116
+
117
+ context 'when limit' do
118
+ let(:opts) { { limit: 2, after: 1 } }
119
+
120
+ it 'retrieves meetings' do
121
+ VCR.use_cassette 'meeting_find_by_contact_limit' do
122
+ results = find_by_contact
123
+ meetings = results[:meetings]
124
+ first_meeting = meetings.first
125
+ expect(meetings).not_to be_nil
126
+ expect(results[:after]).not_to be_nil
127
+ expect(meetings.count).to eq 2
128
+ expect(first_meeting).not_to be_nil
129
+ expect(first_meeting.properties[:hubspot_owner_id]).not_to be nil
130
+ expect(first_meeting.properties[:hs_meeting_title]).not_to be nil
131
+ expect(first_meeting.properties[:hs_meeting_body]).not_to be nil
132
+ expect(first_meeting.properties[:hs_meeting_start_time]).not_to be nil
133
+ expect(first_meeting.properties[:hs_meeting_end_time]).not_to be nil
134
+ end
135
+ end
136
+ end
94
137
  end
95
138
 
96
139
  describe '.create' 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.14.0
4
+ version: 0.15.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-07 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport