hubspot-api-ruby 0.9.0 → 0.10.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/README.md +27 -9
- data/Rakefile +0 -2
- data/hubspot-api-ruby.gemspec +1 -2
- data/lib/hubspot/config.rb +4 -0
- data/lib/hubspot/engagement.rb +0 -1
- data/lib/hubspot/file.rb +2 -2
- data/lib/hubspot/railtie.rb +0 -4
- data/lib/hubspot/utils.rb +0 -30
- data/spec/lib/hubspot/blog_spec.rb +2 -7
- data/spec/lib/hubspot/config_spec.rb +24 -14
- data/spec/lib/hubspot/connection_spec.rb +44 -55
- data/spec/lib/hubspot/contact_list_spec.rb +21 -33
- data/spec/lib/hubspot/contact_spec.rb +1 -1
- data/spec/lib/hubspot/custom_event_spec.rb +5 -4
- data/spec/lib/hubspot/engagement_spec.rb +3 -11
- data/spec/lib/hubspot/event_spec.rb +3 -2
- data/spec/lib/hubspot/file_spec.rb +20 -9
- data/spec/lib/hubspot/form_spec.rb +8 -11
- data/spec/lib/hubspot/meeting_spec.rb +7 -1
- data/spec/lib/hubspot/owner_spec.rb +2 -3
- data/spec/lib/hubspot/utils_spec.rb +6 -39
- data/spec/lib/hubspot-ruby_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/vcr.rb +1 -0
- metadata +5 -9
- data/lib/tasks/hubspot.rake +0 -53
- data/spec/lib/tasks/hubspot_spec.rb +0 -119
- data/spec/support/capture_output.rb +0 -21
- data/spec/support/rake.rb +0 -46
@@ -1,7 +1,18 @@
|
|
1
1
|
describe Hubspot::ContactList do
|
2
|
+
# uncomment if you need to create test data in your panel.
|
3
|
+
# note that sandboxes have a limit of 5 dynamic lists
|
4
|
+
# before(:all) do
|
5
|
+
# VCR.use_cassette("create_all_lists") do
|
6
|
+
# 25.times { Hubspot::ContactList.create!(name: SecureRandom.hex) }
|
7
|
+
# 3.times { Hubspot::ContactList.create!(name: SecureRandom.hex, dynamic: true, filters: [[{ operator: "EQ", value: "@hubspot", property: "twitterhandle", type: "string"}]]) }
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
|
2
11
|
let(:example_contact_list_hash) do
|
3
12
|
VCR.use_cassette("contact_list_example") do
|
4
|
-
|
13
|
+
headers = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }
|
14
|
+
response = HTTParty.get("https://api.hubapi.com/contacts/v1/lists/static?count=1", headers: headers).parsed_response
|
15
|
+
response['lists'].first
|
5
16
|
end
|
6
17
|
end
|
7
18
|
|
@@ -9,12 +20,6 @@ describe Hubspot::ContactList do
|
|
9
20
|
Hubspot::ContactList.create!(name: "static list #{SecureRandom.hex}")
|
10
21
|
end
|
11
22
|
|
12
|
-
let(:example_contact_hash) do
|
13
|
-
VCR.use_cassette("contact_example") do
|
14
|
-
HTTParty.get("https://api.hubapi.com/contacts/v1/contact/email/testingapis@hubspot.com/profile?hapikey=demo").parsed_response
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
23
|
shared_examples "count and offset" do |params|
|
19
24
|
it 'returns only the number of objects specified by count' do
|
20
25
|
result = instance_exec(count: 2, ¶ms[:block])
|
@@ -38,7 +43,7 @@ describe Hubspot::ContactList do
|
|
38
43
|
its(:id) { should be_an(Integer) }
|
39
44
|
its(:portal_id) { should be_a(Integer) }
|
40
45
|
its(:name) { should_not be_empty }
|
41
|
-
its(:dynamic) { should be
|
46
|
+
its(:dynamic) { should be false }
|
42
47
|
its(:properties) { should be_a(Hash) }
|
43
48
|
end
|
44
49
|
|
@@ -57,12 +62,6 @@ describe Hubspot::ContactList do
|
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
60
|
-
it 'returns by default 20 contact lists' do
|
61
|
-
expect(list.contacts.count).to eql 20
|
62
|
-
contact = list.contacts.first
|
63
|
-
expect(contact).to be_a(Hubspot::Contact)
|
64
|
-
end
|
65
|
-
|
66
65
|
it 'returns by default 20 contact lists with paging data' do
|
67
66
|
contact_data = list.contacts({bypass_cache: true, paged: true})
|
68
67
|
contacts = contact_data['contacts']
|
@@ -73,15 +72,10 @@ describe Hubspot::ContactList do
|
|
73
72
|
expect(contacts.count).to eql 20
|
74
73
|
contact = contacts.first
|
75
74
|
expect(contact).to be_a(Hubspot::Contact)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'add default properties to the contacts returned' do
|
79
|
-
contact = list.contacts.first
|
80
75
|
expect(contact.email).to_not be_empty
|
81
76
|
end
|
82
77
|
|
83
78
|
it_behaves_like 'count and offset', {block: ->(r) { Hubspot::ContactList.find(list.id).contacts(r) }}
|
84
|
-
|
85
79
|
end
|
86
80
|
|
87
81
|
describe '.create' do
|
@@ -119,13 +113,6 @@ describe Hubspot::ContactList do
|
|
119
113
|
end
|
120
114
|
|
121
115
|
describe '.all' do
|
122
|
-
before(:all) do
|
123
|
-
VCR.use_cassette("create_all_lists") do
|
124
|
-
25.times { Hubspot::ContactList.create!(name: SecureRandom.hex) }
|
125
|
-
25.times { Hubspot::ContactList.create!(name: SecureRandom.hex, dynamic: true, filters: [[{ operator: "EQ", value: "@hubspot", property: "twitterhandle", type: "string"}]]) }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
116
|
context 'all list types' do
|
130
117
|
cassette 'find_all_lists'
|
131
118
|
|
@@ -146,7 +133,7 @@ describe Hubspot::ContactList do
|
|
146
133
|
|
147
134
|
it 'returns by defaut all the static contact lists' do
|
148
135
|
lists = Hubspot::ContactList.all(static: true)
|
149
|
-
expect(lists.count).to be >
|
136
|
+
expect(lists.count).to be > 2
|
150
137
|
|
151
138
|
list = lists.first
|
152
139
|
expect(list).to be_a(Hubspot::ContactList)
|
@@ -159,7 +146,7 @@ describe Hubspot::ContactList do
|
|
159
146
|
|
160
147
|
it 'returns by defaut all the dynamic contact lists' do
|
161
148
|
lists = Hubspot::ContactList.all(dynamic: true)
|
162
|
-
expect(lists.count).to be >
|
149
|
+
expect(lists.count).to be > 2
|
163
150
|
|
164
151
|
list = lists.first
|
165
152
|
expect(list).to be_a(Hubspot::ContactList)
|
@@ -173,7 +160,7 @@ describe Hubspot::ContactList do
|
|
173
160
|
cassette "contact_list_find"
|
174
161
|
subject { Hubspot::ContactList.find(id) }
|
175
162
|
|
176
|
-
let(:list) { Hubspot::ContactList.
|
163
|
+
let(:list) { Hubspot::ContactList.new(example_contact_list_hash) }
|
177
164
|
|
178
165
|
context 'when the contact list is found' do
|
179
166
|
let(:id) { list.id.to_i }
|
@@ -188,7 +175,7 @@ describe Hubspot::ContactList do
|
|
188
175
|
|
189
176
|
context 'Wrong parameter type given' do
|
190
177
|
it 'raises an error' do
|
191
|
-
expect { Hubspot::ContactList.find(
|
178
|
+
expect { Hubspot::ContactList.find({ foo: :bar }) }.to raise_error(Hubspot::InvalidParams)
|
192
179
|
end
|
193
180
|
end
|
194
181
|
|
@@ -287,12 +274,13 @@ describe Hubspot::ContactList do
|
|
287
274
|
|
288
275
|
context 'static list' do
|
289
276
|
it 'returns true if removes all contacts in batch mode' do
|
290
|
-
|
291
|
-
|
277
|
+
list = Hubspot::ContactList.new(example_contact_list_hash)
|
278
|
+
contacts = list.contacts(count: 2)
|
279
|
+
expect(list.remove([contacts.first, contacts.last])).to be true
|
292
280
|
end
|
293
281
|
|
294
282
|
it 'returns false if the contact cannot be removed' do
|
295
|
-
contact_not_present_in_list = Hubspot::Contact.new(
|
283
|
+
contact_not_present_in_list = Hubspot::Contact.new(1234)
|
296
284
|
expect(static_list.remove(contact_not_present_in_list)).to be false
|
297
285
|
end
|
298
286
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
RSpec.describe Hubspot::CustomEvent do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
before do
|
3
|
+
Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), portal_id: ENV.fetch("HUBSPOT_PORTAL_ID"),
|
4
|
+
custom_event_prefix: 'foobar')
|
5
|
+
end
|
5
6
|
|
6
7
|
describe '.trigger' do
|
7
8
|
let(:event_name) { 'my_awesome_event' }
|
@@ -9,7 +10,7 @@ RSpec.describe Hubspot::CustomEvent do
|
|
9
10
|
let(:properties) { { prop_foo: 'bar' } }
|
10
11
|
let(:options) { {} }
|
11
12
|
let(:base_url) { 'https://api.hubapi.com' }
|
12
|
-
let(:url) { "#{base_url}/events/v3/send
|
13
|
+
let(:url) { "#{base_url}/events/v3/send" }
|
13
14
|
|
14
15
|
subject { described_class.trigger(event_name, email, properties, options) }
|
15
16
|
|
@@ -1,22 +1,14 @@
|
|
1
1
|
describe Hubspot::Engagement do
|
2
|
-
|
3
2
|
let(:contact) { Hubspot::Contact.create("#{SecureRandom.hex}@hubspot.com") }
|
4
3
|
let(:engagement) { Hubspot::EngagementNote.create!(contact.id, "foo") }
|
5
|
-
let(:example_engagement_hash) do
|
6
|
-
VCR.use_cassette("engagement_example") do
|
7
|
-
HTTParty.get("https://api.hubapi.com/engagements/v1/engagements/3981023?hapikey=demo").parsed_response
|
8
|
-
end
|
9
|
-
end
|
10
|
-
let(:example_associated_engagement_hash) do
|
11
|
-
VCR.use_cassette("engagement_associated_example") do
|
12
|
-
HTTParty.get("https://api.hubapi.com/engagements/v1/engagements/58699206?hapikey=demo").parsed_response
|
13
|
-
end
|
14
|
-
end
|
15
4
|
|
16
5
|
# http://developers.hubspot.com/docs/methods/contacts/get_contact
|
17
6
|
|
18
7
|
describe "#initialize" do
|
19
8
|
subject{ Hubspot::Engagement.new(example_engagement_hash) }
|
9
|
+
|
10
|
+
let(:example_engagement_hash) { { 'engagement' => { 'id' => 3981023, 'portalId' => 62515, 'associations' => {} } } }
|
11
|
+
|
20
12
|
it { should be_an_instance_of Hubspot::Engagement }
|
21
13
|
its (:id) { should == 3981023 }
|
22
14
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
describe Hubspot::Event do
|
2
|
-
let(:portal_id) {
|
2
|
+
let(:portal_id) { ENV.fetch("HUBSPOT_PORTAL_ID") }
|
3
3
|
let(:sent_portal_id) { portal_id }
|
4
|
-
|
4
|
+
|
5
|
+
before { Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), portal_id: portal_id) }
|
5
6
|
|
6
7
|
describe '.trigger' do
|
7
8
|
let(:event_id) { '000000001625' }
|
@@ -1,12 +1,23 @@
|
|
1
|
-
describe Hubspot do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
describe Hubspot::File do
|
2
|
+
let(:example_file_hash) do
|
3
|
+
VCR.use_cassette('file_example') do
|
4
|
+
headers = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }
|
5
|
+
body = {
|
6
|
+
file: File.open(File::NULL, 'r'),
|
7
|
+
options: { access: 'PRIVATE', ttl: 'P1M', overwrite: false }.to_json,
|
8
|
+
folderPath: '/'
|
9
|
+
}
|
10
|
+
url = 'https://api.hubapi.com/filemanager/api/v3/files/upload'
|
11
|
+
HTTParty.post(url, body: body, headers: headers).parsed_response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".find_by_id" do
|
16
|
+
it "should fetch specific file" do
|
17
|
+
VCR.use_cassette("file_find") do
|
18
|
+
id = example_file_hash['objects'].first['id']
|
19
|
+
file = Hubspot::File.find_by_id(id)
|
20
|
+
file.id.should eq(id)
|
10
21
|
end
|
11
22
|
end
|
12
23
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
describe Hubspot::Form do
|
2
2
|
let(:example_form_hash) do
|
3
3
|
VCR.use_cassette('form_example') do
|
4
|
-
|
4
|
+
guid = Hubspot::Form.all.first.guid
|
5
|
+
headers = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }
|
6
|
+
HTTParty.get("https://api.hubapi.com#{Hubspot::Form::FORMS_PATH}/#{guid}", headers: headers).parsed_response
|
5
7
|
end
|
6
8
|
end
|
7
9
|
|
@@ -29,8 +31,6 @@ describe Hubspot::Form do
|
|
29
31
|
end
|
30
32
|
|
31
33
|
describe '.all' do
|
32
|
-
before { Hubspot.configure(hapikey: 'demo') }
|
33
|
-
|
34
34
|
cassette 'find_all_forms'
|
35
35
|
|
36
36
|
it 'returns all forms' do
|
@@ -42,8 +42,6 @@ describe Hubspot::Form do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '.find' do
|
45
|
-
before { Hubspot.configure(hapikey: 'demo') }
|
46
|
-
|
47
45
|
cassette 'form_find'
|
48
46
|
subject { Hubspot::Form.find(Hubspot::Form.all.first.guid) }
|
49
47
|
|
@@ -79,7 +77,6 @@ describe Hubspot::Form do
|
|
79
77
|
end
|
80
78
|
|
81
79
|
describe '#fields' do
|
82
|
-
before { Hubspot.configure(hapikey: 'demo') }
|
83
80
|
context 'returning all the fields' do
|
84
81
|
cassette 'fields_among_form'
|
85
82
|
|
@@ -119,11 +116,11 @@ describe Hubspot::Form do
|
|
119
116
|
describe '#submit' do
|
120
117
|
cassette 'form_submit_data'
|
121
118
|
|
122
|
-
let(:form) { Hubspot::Form.
|
119
|
+
let(:form) { Hubspot::Form.all.first }
|
123
120
|
|
124
121
|
context 'with a valid portal id' do
|
125
122
|
before do
|
126
|
-
Hubspot.configure(
|
123
|
+
Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), portal_id: ENV.fetch("HUBSPOT_PORTAL_ID"))
|
127
124
|
end
|
128
125
|
|
129
126
|
it 'returns true if the form submission is successful' do
|
@@ -135,7 +132,7 @@ describe Hubspot::Form do
|
|
135
132
|
|
136
133
|
context 'with an invalid portal id' do
|
137
134
|
before do
|
138
|
-
Hubspot.configure(
|
135
|
+
Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), portal_id: "xxx")
|
139
136
|
end
|
140
137
|
|
141
138
|
it 'returns false in case of errors' do
|
@@ -149,7 +146,7 @@ describe Hubspot::Form do
|
|
149
146
|
let(:f) { Hubspot::Form.new('guid' => form.guid) }
|
150
147
|
|
151
148
|
before do
|
152
|
-
Hubspot.configure(
|
149
|
+
Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"), portal_id: ENV.fetch("HUBSPOT_PORTAL_ID"))
|
153
150
|
end
|
154
151
|
|
155
152
|
it 'returns true if the form submission is successful' do
|
@@ -170,8 +167,8 @@ describe Hubspot::Form do
|
|
170
167
|
let(:params) { { name: new_name, redirect: redirect } }
|
171
168
|
subject { form.update!(params) }
|
172
169
|
|
173
|
-
it { should be_an_instance_of Hubspot::Form }
|
174
170
|
it 'updates properties' do
|
171
|
+
should be_an_instance_of Hubspot::Form
|
175
172
|
subject.properties['name'].should start_with('updated form name ')
|
176
173
|
subject.properties['redirect'].should be == redirect
|
177
174
|
end
|
@@ -1,6 +1,12 @@
|
|
1
1
|
RSpec.describe Hubspot::Meeting do
|
2
2
|
|
3
|
-
let(:hubspot_owner_id)
|
3
|
+
let(:hubspot_owner_id) do
|
4
|
+
VCR.use_cassette('meeting_owner') do
|
5
|
+
headers = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }
|
6
|
+
owners = HTTParty.get('https://api.hubapi.com/owners/v2/owners', headers: headers).parsed_response
|
7
|
+
owners.first['ownerId']
|
8
|
+
end
|
9
|
+
end
|
4
10
|
let(:hs_meeting_title) { 'hs_meeting_title' }
|
5
11
|
let(:hs_meeting_body) { 'hs_meeting_body' }
|
6
12
|
let(:hs_meeting_start_time) { DateTime.strptime('2022-05-03T10:00:00+01:00', '%Y-%m-%dT%H:%M:%S%z') }
|
@@ -1,12 +1,11 @@
|
|
1
1
|
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/owners/v2/owners', headers: headers).parsed_response
|
5
6
|
end
|
6
7
|
end
|
7
8
|
|
8
|
-
before { Hubspot.configure(hapikey: 'demo') }
|
9
|
-
|
10
9
|
describe '.all' do
|
11
10
|
cassette 'owner_all'
|
12
11
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
describe Hubspot::Utils do
|
2
|
+
API_HEADERS = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }.freeze
|
3
|
+
|
2
4
|
describe ".properties_to_hash" do
|
3
5
|
let(:properties) do
|
4
6
|
{
|
@@ -32,13 +34,13 @@ describe Hubspot::Utils do
|
|
32
34
|
describe '.compare_property_lists for ContactProperties' do
|
33
35
|
let(:example_groups) do
|
34
36
|
VCR.use_cassette('contact_properties/groups_example') do
|
35
|
-
HTTParty.get('https://api.hubapi.com/contacts/v2/groups
|
37
|
+
HTTParty.get('https://api.hubapi.com/contacts/v2/groups', headers: API_HEADERS).parsed_response
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
41
|
let(:example_properties) do
|
40
42
|
VCR.use_cassette('contact_properties/properties_example') do
|
41
|
-
HTTParty.get('https://api.hubapi.com/contacts/v2/properties
|
43
|
+
HTTParty.get('https://api.hubapi.com/contacts/v2/properties', headers: API_HEADERS).parsed_response
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -81,13 +83,13 @@ describe Hubspot::Utils do
|
|
81
83
|
describe '.compare_property_lists for DealProperties' do
|
82
84
|
let(:example_groups) do
|
83
85
|
VCR.use_cassette('deal_groups_example') do
|
84
|
-
HTTParty.get('https://api.hubapi.com/deals/v1/groups
|
86
|
+
HTTParty.get('https://api.hubapi.com/deals/v1/groups', headers: API_HEADERS).parsed_response
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
90
|
let(:example_properties) do
|
89
91
|
VCR.use_cassette('deal_properties_example') do
|
90
|
-
HTTParty.get('https://api.hubapi.com/deals/v1/properties
|
92
|
+
HTTParty.get('https://api.hubapi.com/deals/v1/properties', headers: API_HEADERS).parsed_response
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
@@ -126,39 +128,4 @@ describe Hubspot::Utils do
|
|
126
128
|
end
|
127
129
|
end
|
128
130
|
end
|
129
|
-
|
130
|
-
describe ".dump_properties" do
|
131
|
-
it "prints a deprecation warning" do
|
132
|
-
VCR.use_cassette("dump_deal_properties_and_groups") do
|
133
|
-
api_key = "demo"
|
134
|
-
|
135
|
-
output = capture_stderr do
|
136
|
-
Hubspot::Utils.dump_properties(Hubspot::DealProperties, api_key)
|
137
|
-
end
|
138
|
-
|
139
|
-
expected_warning = "Hubspot::Utils.dump_properties is deprecated"
|
140
|
-
expect(output).to include(expected_warning)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe ".restore_properties" do
|
146
|
-
it "prints a deprecation warning" do
|
147
|
-
VCR.use_cassette("restore_deal_properties_and_groups") do
|
148
|
-
api_key = "demo"
|
149
|
-
properties = {"groups" => {}, "properties" => {}}
|
150
|
-
|
151
|
-
output = capture_stderr do
|
152
|
-
Hubspot::Utils.restore_properties(
|
153
|
-
Hubspot::DealProperties,
|
154
|
-
api_key,
|
155
|
-
properties
|
156
|
-
)
|
157
|
-
end
|
158
|
-
|
159
|
-
expected_warning = "Hubspot::Utils.restore_properties is deprecated"
|
160
|
-
expect(output).to include(expected_warning)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
131
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.describe Hubspot do
|
2
2
|
describe ".configure" do
|
3
3
|
it "delegates .configure to Hubspot::Config.configure" do
|
4
|
-
options = {
|
4
|
+
options = { access_token: "demo" }
|
5
5
|
allow(Hubspot::Config).to receive(:configure).with(options)
|
6
6
|
|
7
7
|
Hubspot.configure(options)
|
data/spec/spec_helper.rb
CHANGED
@@ -30,11 +30,11 @@ Dir["#{RSPEC_ROOT}/shared_examples/**/*.rb"].each {|f| require f}
|
|
30
30
|
|
31
31
|
RSpec.configure do |config|
|
32
32
|
config.before(:all) do
|
33
|
-
Hubspot.configure(
|
33
|
+
Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"))
|
34
34
|
end
|
35
35
|
|
36
36
|
config.before(:each) do
|
37
|
-
Hubspot.configure(
|
37
|
+
Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"))
|
38
38
|
end
|
39
39
|
|
40
40
|
# config.after(:each) do
|
data/spec/support/vcr.rb
CHANGED
@@ -10,4 +10,5 @@ VCR.configure do |c|
|
|
10
10
|
c.default_cassette_options = { record: vcr_record_mode }
|
11
11
|
c.filter_sensitive_data("<HAPI_KEY>") { ENV.fetch("HUBSPOT_HAPI_KEY") }
|
12
12
|
c.filter_sensitive_data("<PORTAL_ID>") { ENV.fetch("HUBSPOT_PORTAL_ID") }
|
13
|
+
c.filter_sensitive_data("<ACCESS_TOKEN>") { ENV.fetch("HUBSPOT_ACCESS_TOKEN") }
|
13
14
|
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.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -294,7 +294,6 @@ files:
|
|
294
294
|
- lib/hubspot/subscription.rb
|
295
295
|
- lib/hubspot/topic.rb
|
296
296
|
- lib/hubspot/utils.rb
|
297
|
-
- lib/tasks/hubspot.rake
|
298
297
|
- spec/factories/companies.rb
|
299
298
|
- spec/factories/contacts.rb
|
300
299
|
- spec/lib/hubspot-ruby_spec.rb
|
@@ -321,21 +320,18 @@ files:
|
|
321
320
|
- spec/lib/hubspot/properties_spec.rb
|
322
321
|
- spec/lib/hubspot/resource_spec.rb
|
323
322
|
- spec/lib/hubspot/utils_spec.rb
|
324
|
-
- spec/lib/tasks/hubspot_spec.rb
|
325
323
|
- spec/shared_examples/saveable_resource.rb
|
326
324
|
- spec/shared_examples/updateable_resource.rb
|
327
325
|
- spec/spec_helper.rb
|
328
|
-
- spec/support/capture_output.rb
|
329
326
|
- spec/support/cassette_helper.rb
|
330
327
|
- spec/support/hubspot_api_helpers.rb
|
331
|
-
- spec/support/rake.rb
|
332
328
|
- spec/support/vcr.rb
|
333
329
|
homepage: https://github.com/captaincontrat/hubspot-api-ruby
|
334
330
|
licenses:
|
335
331
|
- MIT
|
336
332
|
metadata:
|
337
333
|
changelog_uri: https://github.com/captaincontrat/hubspot-api-ruby/blob/master/History.md
|
338
|
-
post_install_message:
|
334
|
+
post_install_message:
|
339
335
|
rdoc_options: []
|
340
336
|
require_paths:
|
341
337
|
- lib
|
@@ -351,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
351
347
|
version: '0'
|
352
348
|
requirements: []
|
353
349
|
rubygems_version: 3.2.32
|
354
|
-
signing_key:
|
350
|
+
signing_key:
|
355
351
|
specification_version: 4
|
356
352
|
summary: hubspot-api-ruby is a wrapper for the HubSpot REST API
|
357
353
|
test_files: []
|
data/lib/tasks/hubspot.rake
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'hubspot-api-ruby'
|
2
|
-
|
3
|
-
namespace :hubspot do
|
4
|
-
desc 'Dump properties to file'
|
5
|
-
task :dump_properties, [:kind, :file, :hapikey, :include, :exclude] do |_, args|
|
6
|
-
Hubspot::Deprecator.build.deprecation_warning("hubspot:dump_properties")
|
7
|
-
|
8
|
-
hapikey = args[:hapikey] || ENV['HUBSPOT_API_KEY']
|
9
|
-
kind = args[:kind]
|
10
|
-
unless %w(contact deal).include?(kind)
|
11
|
-
raise ArgumentError, ':kind must be either "contact" or "deal"'
|
12
|
-
end
|
13
|
-
klass = kind == 'contact' ? Hubspot::ContactProperties : Hubspot::DealProperties
|
14
|
-
props = Hubspot::Utils::dump_properties(klass, hapikey, build_filter(args))
|
15
|
-
if args[:file].blank?
|
16
|
-
puts JSON.pretty_generate(props)
|
17
|
-
else
|
18
|
-
File.open(args[:file], 'w') do |f|
|
19
|
-
f.write(JSON.pretty_generate(props))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Restore properties from file'
|
25
|
-
task :restore_properties, [:kind, :file, :hapikey, :dry_run] do |_, args|
|
26
|
-
Hubspot::Deprecator.build.deprecation_warning("hubspot:restore_properties")
|
27
|
-
|
28
|
-
hapikey = args[:hapikey] || ENV['HUBSPOT_API_KEY']
|
29
|
-
if args[:file].blank?
|
30
|
-
raise ArgumentError, ':file is a required parameter'
|
31
|
-
end
|
32
|
-
kind = args[:kind]
|
33
|
-
unless %w(contact deal).include?(kind)
|
34
|
-
raise ArgumentError, ':kind must be either "contact" or "deal"'
|
35
|
-
end
|
36
|
-
klass = kind == 'contact' ? Hubspot::ContactProperties : Hubspot::DealProperties
|
37
|
-
file = File.read(args[:file])
|
38
|
-
props = JSON.parse(file)
|
39
|
-
Hubspot::Utils.restore_properties(klass, hapikey, props, args[:dry_run] != 'false')
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def build_filter(args)
|
45
|
-
{ include: val_to_array(args[:include]),
|
46
|
-
exclude: val_to_array(args[:exclude])
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
def val_to_array(val)
|
51
|
-
val.blank? ? val : val.split(/\W+/)
|
52
|
-
end
|
53
|
-
end
|