intercom 3.9.5 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +406 -236
- data/Rakefile +1 -1
- data/changes.txt +32 -0
- data/lib/intercom/api_operations/archive.rb +2 -1
- data/lib/intercom/api_operations/delete.rb +16 -0
- data/lib/intercom/api_operations/find.rb +5 -2
- data/lib/intercom/api_operations/find_all.rb +4 -3
- data/lib/intercom/api_operations/list.rb +4 -1
- data/lib/intercom/api_operations/load.rb +4 -2
- data/lib/intercom/api_operations/nested_resource.rb +70 -0
- data/lib/intercom/api_operations/save.rb +6 -4
- data/lib/intercom/api_operations/scroll.rb +4 -5
- data/lib/intercom/api_operations/search.rb +3 -2
- data/lib/intercom/article.rb +7 -0
- data/lib/intercom/base_collection_proxy.rb +73 -0
- data/lib/intercom/client.rb +36 -25
- data/lib/intercom/client_collection_proxy.rb +17 -39
- data/lib/intercom/collection.rb +7 -0
- data/lib/intercom/company.rb +8 -0
- data/lib/intercom/contact.rb +22 -3
- data/lib/intercom/conversation.rb +5 -0
- data/lib/intercom/data_attribute.rb +7 -0
- data/lib/intercom/deprecated_leads_collection_proxy.rb +22 -0
- data/lib/intercom/deprecated_resources.rb +13 -0
- data/lib/intercom/errors.rb +3 -0
- data/lib/intercom/extended_api_operations/segments.rb +3 -1
- data/lib/intercom/extended_api_operations/tags.rb +3 -1
- data/lib/intercom/lead.rb +21 -0
- data/lib/intercom/lib/dynamic_accessors.rb +9 -10
- data/lib/intercom/lib/typed_json_deserializer.rb +42 -37
- data/lib/intercom/note.rb +4 -0
- data/lib/intercom/request.rb +37 -33
- data/lib/intercom/scroll_collection_proxy.rb +38 -42
- data/lib/intercom/search_collection_proxy.rb +30 -65
- data/lib/intercom/section.rb +23 -0
- data/lib/intercom/segment.rb +4 -0
- data/lib/intercom/service/article.rb +20 -0
- data/lib/intercom/service/base_service.rb +7 -0
- data/lib/intercom/service/collection.rb +24 -0
- data/lib/intercom/service/company.rb +2 -12
- data/lib/intercom/service/contact.rb +31 -10
- data/lib/intercom/service/conversation.rb +12 -3
- data/lib/intercom/service/data_attribute.rb +20 -0
- data/lib/intercom/service/lead.rb +41 -0
- data/lib/intercom/service/note.rb +4 -8
- data/lib/intercom/service/section.rb +7 -0
- data/lib/intercom/service/subscription.rb +2 -2
- data/lib/intercom/service/tag.rb +9 -9
- data/lib/intercom/service/visitor.rb +17 -8
- data/lib/intercom/tag.rb +4 -0
- data/lib/intercom/traits/api_resource.rb +44 -18
- data/lib/intercom/traits/dirty_tracking.rb +8 -1
- data/lib/intercom/user.rb +12 -3
- data/lib/intercom/utils.rb +13 -2
- data/lib/intercom/version.rb +1 -1
- data/lib/intercom/visitor.rb +0 -2
- data/lib/intercom.rb +33 -22
- data/spec/spec_helper.rb +843 -520
- data/spec/unit/intercom/admin_spec.rb +2 -2
- data/spec/unit/intercom/article_spec.rb +40 -0
- data/spec/unit/intercom/base_collection_proxy_spec.rb +47 -0
- data/spec/unit/intercom/client_collection_proxy_spec.rb +41 -41
- data/spec/unit/intercom/client_spec.rb +25 -26
- data/spec/unit/intercom/collection_spec.rb +32 -0
- data/spec/unit/intercom/company_spec.rb +18 -14
- data/spec/unit/intercom/contact_spec.rb +385 -33
- data/spec/unit/intercom/conversation_spec.rb +55 -7
- data/spec/unit/intercom/count_spec.rb +4 -4
- data/spec/unit/intercom/data_attribute_spec.rb +40 -0
- data/spec/unit/intercom/deprecated_leads_collection_proxy_spec.rb +17 -0
- data/spec/unit/intercom/event_spec.rb +9 -11
- data/spec/unit/intercom/job_spec.rb +24 -24
- data/spec/unit/intercom/lead_spec.rb +57 -0
- data/spec/unit/intercom/lib/flat_store_spec.rb +22 -20
- data/spec/unit/intercom/message_spec.rb +1 -1
- data/spec/unit/intercom/note_spec.rb +4 -10
- data/spec/unit/intercom/request_spec.rb +1 -1
- data/spec/unit/intercom/scroll_collection_proxy_spec.rb +40 -39
- data/spec/unit/intercom/search_collection_proxy_spec.rb +32 -28
- data/spec/unit/intercom/section_spec.rb +32 -0
- data/spec/unit/intercom/segment_spec.rb +2 -2
- data/spec/unit/intercom/subscription_spec.rb +5 -6
- data/spec/unit/intercom/tag_spec.rb +22 -14
- data/spec/unit/intercom/team_spec.rb +2 -2
- data/spec/unit/intercom/traits/api_resource_spec.rb +107 -52
- data/spec/unit/intercom/user_spec.rb +224 -226
- data/spec/unit/intercom/visitor_spec.rb +49 -0
- data/spec/unit/intercom_spec.rb +5 -3
- metadata +34 -8
- data/lib/intercom/customer.rb +0 -10
- data/lib/intercom/service/customer.rb +0 -14
- data/spec/unit/intercom/visitors_spec.rb +0 -61
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Intercom::Visitor' do
|
4
|
+
let (:client) { Intercom::Client.new(token: 'token') }
|
5
|
+
|
6
|
+
it 'can update a visitor with an id' do
|
7
|
+
visitor = Intercom::Visitor.new(:id => 'de45ae78gae1289cb')
|
8
|
+
client.expects(:put).with('/visitors/de45ae78gae1289cb', 'custom_attributes' => {})
|
9
|
+
client.visitors.save(visitor)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'can get a visitor' do
|
13
|
+
visitor = Intercom::Visitor.new(:id => 'de45ae78gae1289cb')
|
14
|
+
client.expects(:get).with('/visitors/de45ae78gae1289cb', {}).returns(test_visitor)
|
15
|
+
client.visitors.find(id: visitor.id)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'converting' do
|
19
|
+
let(:visitor) { Intercom::Visitor.from_api(user_id: 'visitor_id') }
|
20
|
+
let(:user) { Intercom::Contact.from_api(id: 'user_id', role: 'user') }
|
21
|
+
|
22
|
+
it 'visitor to user' do
|
23
|
+
client.expects(:post).with(
|
24
|
+
'/visitors/convert',
|
25
|
+
visitor: { user_id: visitor.user_id },
|
26
|
+
user: { 'id' => user.id },
|
27
|
+
type: 'user'
|
28
|
+
).returns(test_contact)
|
29
|
+
|
30
|
+
client.visitors.convert(visitor, user)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'visitor to lead' do
|
34
|
+
client.expects(:post).with(
|
35
|
+
'/visitors/convert',
|
36
|
+
visitor: { user_id: visitor.user_id },
|
37
|
+
type: 'lead'
|
38
|
+
).returns(test_contact(role: 'lead'))
|
39
|
+
|
40
|
+
client.visitors.convert(visitor)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'deletes a visitor' do
|
45
|
+
visitor = Intercom::Visitor.new('id' => '1')
|
46
|
+
client.expects(:delete).with('/visitors/1', {}).returns(visitor)
|
47
|
+
client.visitors.delete(visitor)
|
48
|
+
end
|
49
|
+
end
|
data/spec/unit/intercom_spec.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Intercom do
|
4
|
-
it
|
5
|
-
Intercom::VERSION.must_match(/\d+\.\d+\.\d+/)
|
6
|
+
it 'has a version number' do
|
7
|
+
_(Intercom::VERSION).must_match(/\d+\.\d+\.\d+/)
|
6
8
|
end
|
7
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben McRedmond
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date:
|
18
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
@@ -150,26 +150,34 @@ files:
|
|
150
150
|
- lib/intercom/api_operations/bulk/load_error_feed.rb
|
151
151
|
- lib/intercom/api_operations/bulk/submit.rb
|
152
152
|
- lib/intercom/api_operations/convert.rb
|
153
|
+
- lib/intercom/api_operations/delete.rb
|
153
154
|
- lib/intercom/api_operations/find.rb
|
154
155
|
- lib/intercom/api_operations/find_all.rb
|
155
156
|
- lib/intercom/api_operations/list.rb
|
156
157
|
- lib/intercom/api_operations/load.rb
|
158
|
+
- lib/intercom/api_operations/nested_resource.rb
|
157
159
|
- lib/intercom/api_operations/request_hard_delete.rb
|
158
160
|
- lib/intercom/api_operations/save.rb
|
159
161
|
- lib/intercom/api_operations/scroll.rb
|
160
162
|
- lib/intercom/api_operations/search.rb
|
163
|
+
- lib/intercom/article.rb
|
164
|
+
- lib/intercom/base_collection_proxy.rb
|
161
165
|
- lib/intercom/client.rb
|
162
166
|
- lib/intercom/client_collection_proxy.rb
|
167
|
+
- lib/intercom/collection.rb
|
163
168
|
- lib/intercom/company.rb
|
164
169
|
- lib/intercom/contact.rb
|
165
170
|
- lib/intercom/conversation.rb
|
166
171
|
- lib/intercom/count.rb
|
167
|
-
- lib/intercom/
|
172
|
+
- lib/intercom/data_attribute.rb
|
173
|
+
- lib/intercom/deprecated_leads_collection_proxy.rb
|
174
|
+
- lib/intercom/deprecated_resources.rb
|
168
175
|
- lib/intercom/errors.rb
|
169
176
|
- lib/intercom/event.rb
|
170
177
|
- lib/intercom/extended_api_operations/segments.rb
|
171
178
|
- lib/intercom/extended_api_operations/tags.rb
|
172
179
|
- lib/intercom/job.rb
|
180
|
+
- lib/intercom/lead.rb
|
173
181
|
- lib/intercom/lib/dynamic_accessors.rb
|
174
182
|
- lib/intercom/lib/dynamic_accessors_on_method_missing.rb
|
175
183
|
- lib/intercom/lib/flat_store.rb
|
@@ -180,18 +188,23 @@ files:
|
|
180
188
|
- lib/intercom/request.rb
|
181
189
|
- lib/intercom/scroll_collection_proxy.rb
|
182
190
|
- lib/intercom/search_collection_proxy.rb
|
191
|
+
- lib/intercom/section.rb
|
183
192
|
- lib/intercom/segment.rb
|
184
193
|
- lib/intercom/service/admin.rb
|
194
|
+
- lib/intercom/service/article.rb
|
185
195
|
- lib/intercom/service/base_service.rb
|
196
|
+
- lib/intercom/service/collection.rb
|
186
197
|
- lib/intercom/service/company.rb
|
187
198
|
- lib/intercom/service/contact.rb
|
188
199
|
- lib/intercom/service/conversation.rb
|
189
200
|
- lib/intercom/service/count.rb
|
190
|
-
- lib/intercom/service/
|
201
|
+
- lib/intercom/service/data_attribute.rb
|
191
202
|
- lib/intercom/service/event.rb
|
192
203
|
- lib/intercom/service/job.rb
|
204
|
+
- lib/intercom/service/lead.rb
|
193
205
|
- lib/intercom/service/message.rb
|
194
206
|
- lib/intercom/service/note.rb
|
207
|
+
- lib/intercom/service/section.rb
|
195
208
|
- lib/intercom/service/segment.rb
|
196
209
|
- lib/intercom/service/subscription.rb
|
197
210
|
- lib/intercom/service/tag.rb
|
@@ -210,27 +223,34 @@ files:
|
|
210
223
|
- lib/intercom/visitor.rb
|
211
224
|
- spec/spec_helper.rb
|
212
225
|
- spec/unit/intercom/admin_spec.rb
|
226
|
+
- spec/unit/intercom/article_spec.rb
|
227
|
+
- spec/unit/intercom/base_collection_proxy_spec.rb
|
213
228
|
- spec/unit/intercom/client_collection_proxy_spec.rb
|
214
229
|
- spec/unit/intercom/client_spec.rb
|
230
|
+
- spec/unit/intercom/collection_spec.rb
|
215
231
|
- spec/unit/intercom/company_spec.rb
|
216
232
|
- spec/unit/intercom/contact_spec.rb
|
217
233
|
- spec/unit/intercom/conversation_spec.rb
|
218
234
|
- spec/unit/intercom/count_spec.rb
|
235
|
+
- spec/unit/intercom/data_attribute_spec.rb
|
236
|
+
- spec/unit/intercom/deprecated_leads_collection_proxy_spec.rb
|
219
237
|
- spec/unit/intercom/event_spec.rb
|
220
238
|
- spec/unit/intercom/job_spec.rb
|
239
|
+
- spec/unit/intercom/lead_spec.rb
|
221
240
|
- spec/unit/intercom/lib/flat_store_spec.rb
|
222
241
|
- spec/unit/intercom/message_spec.rb
|
223
242
|
- spec/unit/intercom/note_spec.rb
|
224
243
|
- spec/unit/intercom/request_spec.rb
|
225
244
|
- spec/unit/intercom/scroll_collection_proxy_spec.rb
|
226
245
|
- spec/unit/intercom/search_collection_proxy_spec.rb
|
246
|
+
- spec/unit/intercom/section_spec.rb
|
227
247
|
- spec/unit/intercom/segment_spec.rb
|
228
248
|
- spec/unit/intercom/subscription_spec.rb
|
229
249
|
- spec/unit/intercom/tag_spec.rb
|
230
250
|
- spec/unit/intercom/team_spec.rb
|
231
251
|
- spec/unit/intercom/traits/api_resource_spec.rb
|
232
252
|
- spec/unit/intercom/user_spec.rb
|
233
|
-
- spec/unit/intercom/
|
253
|
+
- spec/unit/intercom/visitor_spec.rb
|
234
254
|
- spec/unit/intercom_spec.rb
|
235
255
|
homepage: https://www.intercom.io
|
236
256
|
licenses:
|
@@ -251,33 +271,39 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
271
|
- !ruby/object:Gem::Version
|
252
272
|
version: '0'
|
253
273
|
requirements: []
|
254
|
-
|
255
|
-
rubygems_version: 2.7.6.2
|
274
|
+
rubygems_version: 3.2.16
|
256
275
|
signing_key:
|
257
276
|
specification_version: 4
|
258
277
|
summary: Ruby bindings for the Intercom API
|
259
278
|
test_files:
|
260
279
|
- spec/spec_helper.rb
|
261
280
|
- spec/unit/intercom/admin_spec.rb
|
281
|
+
- spec/unit/intercom/article_spec.rb
|
282
|
+
- spec/unit/intercom/base_collection_proxy_spec.rb
|
262
283
|
- spec/unit/intercom/client_collection_proxy_spec.rb
|
263
284
|
- spec/unit/intercom/client_spec.rb
|
285
|
+
- spec/unit/intercom/collection_spec.rb
|
264
286
|
- spec/unit/intercom/company_spec.rb
|
265
287
|
- spec/unit/intercom/contact_spec.rb
|
266
288
|
- spec/unit/intercom/conversation_spec.rb
|
267
289
|
- spec/unit/intercom/count_spec.rb
|
290
|
+
- spec/unit/intercom/data_attribute_spec.rb
|
291
|
+
- spec/unit/intercom/deprecated_leads_collection_proxy_spec.rb
|
268
292
|
- spec/unit/intercom/event_spec.rb
|
269
293
|
- spec/unit/intercom/job_spec.rb
|
294
|
+
- spec/unit/intercom/lead_spec.rb
|
270
295
|
- spec/unit/intercom/lib/flat_store_spec.rb
|
271
296
|
- spec/unit/intercom/message_spec.rb
|
272
297
|
- spec/unit/intercom/note_spec.rb
|
273
298
|
- spec/unit/intercom/request_spec.rb
|
274
299
|
- spec/unit/intercom/scroll_collection_proxy_spec.rb
|
275
300
|
- spec/unit/intercom/search_collection_proxy_spec.rb
|
301
|
+
- spec/unit/intercom/section_spec.rb
|
276
302
|
- spec/unit/intercom/segment_spec.rb
|
277
303
|
- spec/unit/intercom/subscription_spec.rb
|
278
304
|
- spec/unit/intercom/tag_spec.rb
|
279
305
|
- spec/unit/intercom/team_spec.rb
|
280
306
|
- spec/unit/intercom/traits/api_resource_spec.rb
|
281
307
|
- spec/unit/intercom/user_spec.rb
|
282
|
-
- spec/unit/intercom/
|
308
|
+
- spec/unit/intercom/visitor_spec.rb
|
283
309
|
- spec/unit/intercom_spec.rb
|
data/lib/intercom/customer.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'intercom/service/base_service'
|
2
|
-
require 'intercom/api_operations/search'
|
3
|
-
|
4
|
-
module Intercom
|
5
|
-
module Service
|
6
|
-
class Customer < BaseService
|
7
|
-
include ApiOperations::Search
|
8
|
-
|
9
|
-
def collection_class
|
10
|
-
Intercom::Customer
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Intercom::Visitors" do
|
4
|
-
let (:client) { Intercom::Client.new(app_id: 'app_id', api_key: 'api_key') }
|
5
|
-
|
6
|
-
it 'should be listable' do
|
7
|
-
proxy = client.visitors.all
|
8
|
-
proxy.resource_name.must_equal 'visitors'
|
9
|
-
proxy.finder_url.must_equal '/visitors'
|
10
|
-
proxy.resource_class.must_equal Intercom::Visitor
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'can update a visitor with an id' do
|
14
|
-
visitor = Intercom::Visitor.new(:id => "de45ae78gae1289cb")
|
15
|
-
client.expects(:put).with("/visitors/de45ae78gae1289cb", {'custom_attributes' => {}})
|
16
|
-
client.visitors.save(visitor)
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'converting' do
|
20
|
-
let(:visitor) { Intercom::Visitor.from_api(user_id: 'visitor_id') }
|
21
|
-
let(:user) { Intercom::User.from_api(id: 'user_id') }
|
22
|
-
|
23
|
-
it 'visitor to user' do
|
24
|
-
client.expects(:post).with(
|
25
|
-
"/visitors/convert",
|
26
|
-
{
|
27
|
-
visitor: { user_id: visitor.user_id },
|
28
|
-
user: { 'id' => user.id },
|
29
|
-
type:'user'
|
30
|
-
}
|
31
|
-
).returns(test_user)
|
32
|
-
|
33
|
-
client.visitors.convert(visitor, user)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'visitor to lead' do
|
37
|
-
client.expects(:post).with(
|
38
|
-
"/visitors/convert",
|
39
|
-
{
|
40
|
-
visitor: { user_id: visitor.user_id },
|
41
|
-
type:'lead'
|
42
|
-
}
|
43
|
-
).returns(test_user)
|
44
|
-
|
45
|
-
client.visitors.convert(visitor)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns a ClientCollectionProxy for all without making any requests" do
|
50
|
-
client.expects(:execute_request).never
|
51
|
-
all = client.visitors.all
|
52
|
-
all.must_be_instance_of(Intercom::ClientCollectionProxy)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "deletes a visitor" do
|
56
|
-
visitor = Intercom::Visitor.new("id" => "1")
|
57
|
-
client.expects(:delete).with("/visitors/1", {}).returns(visitor)
|
58
|
-
client.visitors.delete(visitor)
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|