intercom 3.9.5 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +406 -236
  3. data/Rakefile +1 -1
  4. data/changes.txt +32 -0
  5. data/lib/intercom/api_operations/archive.rb +2 -1
  6. data/lib/intercom/api_operations/delete.rb +16 -0
  7. data/lib/intercom/api_operations/find.rb +5 -2
  8. data/lib/intercom/api_operations/find_all.rb +4 -3
  9. data/lib/intercom/api_operations/list.rb +4 -1
  10. data/lib/intercom/api_operations/load.rb +4 -2
  11. data/lib/intercom/api_operations/nested_resource.rb +70 -0
  12. data/lib/intercom/api_operations/save.rb +6 -4
  13. data/lib/intercom/api_operations/scroll.rb +4 -5
  14. data/lib/intercom/api_operations/search.rb +3 -2
  15. data/lib/intercom/article.rb +7 -0
  16. data/lib/intercom/base_collection_proxy.rb +73 -0
  17. data/lib/intercom/client.rb +36 -25
  18. data/lib/intercom/client_collection_proxy.rb +17 -39
  19. data/lib/intercom/collection.rb +7 -0
  20. data/lib/intercom/company.rb +8 -0
  21. data/lib/intercom/contact.rb +22 -3
  22. data/lib/intercom/conversation.rb +5 -0
  23. data/lib/intercom/data_attribute.rb +7 -0
  24. data/lib/intercom/deprecated_leads_collection_proxy.rb +22 -0
  25. data/lib/intercom/deprecated_resources.rb +13 -0
  26. data/lib/intercom/errors.rb +3 -0
  27. data/lib/intercom/extended_api_operations/segments.rb +3 -1
  28. data/lib/intercom/extended_api_operations/tags.rb +3 -1
  29. data/lib/intercom/lead.rb +21 -0
  30. data/lib/intercom/lib/dynamic_accessors.rb +9 -10
  31. data/lib/intercom/lib/typed_json_deserializer.rb +42 -37
  32. data/lib/intercom/note.rb +4 -0
  33. data/lib/intercom/request.rb +37 -33
  34. data/lib/intercom/scroll_collection_proxy.rb +38 -42
  35. data/lib/intercom/search_collection_proxy.rb +30 -65
  36. data/lib/intercom/section.rb +23 -0
  37. data/lib/intercom/segment.rb +4 -0
  38. data/lib/intercom/service/article.rb +20 -0
  39. data/lib/intercom/service/base_service.rb +7 -0
  40. data/lib/intercom/service/collection.rb +24 -0
  41. data/lib/intercom/service/company.rb +2 -12
  42. data/lib/intercom/service/contact.rb +31 -10
  43. data/lib/intercom/service/conversation.rb +12 -3
  44. data/lib/intercom/service/data_attribute.rb +20 -0
  45. data/lib/intercom/service/lead.rb +41 -0
  46. data/lib/intercom/service/note.rb +4 -8
  47. data/lib/intercom/service/section.rb +7 -0
  48. data/lib/intercom/service/subscription.rb +2 -2
  49. data/lib/intercom/service/tag.rb +9 -9
  50. data/lib/intercom/service/visitor.rb +17 -8
  51. data/lib/intercom/tag.rb +4 -0
  52. data/lib/intercom/traits/api_resource.rb +44 -18
  53. data/lib/intercom/traits/dirty_tracking.rb +8 -1
  54. data/lib/intercom/user.rb +12 -3
  55. data/lib/intercom/utils.rb +13 -2
  56. data/lib/intercom/version.rb +1 -1
  57. data/lib/intercom/visitor.rb +0 -2
  58. data/lib/intercom.rb +33 -22
  59. data/spec/spec_helper.rb +843 -520
  60. data/spec/unit/intercom/admin_spec.rb +2 -2
  61. data/spec/unit/intercom/article_spec.rb +40 -0
  62. data/spec/unit/intercom/base_collection_proxy_spec.rb +47 -0
  63. data/spec/unit/intercom/client_collection_proxy_spec.rb +41 -41
  64. data/spec/unit/intercom/client_spec.rb +25 -26
  65. data/spec/unit/intercom/collection_spec.rb +32 -0
  66. data/spec/unit/intercom/company_spec.rb +18 -14
  67. data/spec/unit/intercom/contact_spec.rb +385 -33
  68. data/spec/unit/intercom/conversation_spec.rb +55 -7
  69. data/spec/unit/intercom/count_spec.rb +4 -4
  70. data/spec/unit/intercom/data_attribute_spec.rb +40 -0
  71. data/spec/unit/intercom/deprecated_leads_collection_proxy_spec.rb +17 -0
  72. data/spec/unit/intercom/event_spec.rb +9 -11
  73. data/spec/unit/intercom/job_spec.rb +24 -24
  74. data/spec/unit/intercom/lead_spec.rb +57 -0
  75. data/spec/unit/intercom/lib/flat_store_spec.rb +22 -20
  76. data/spec/unit/intercom/message_spec.rb +1 -1
  77. data/spec/unit/intercom/note_spec.rb +4 -10
  78. data/spec/unit/intercom/request_spec.rb +1 -1
  79. data/spec/unit/intercom/scroll_collection_proxy_spec.rb +40 -39
  80. data/spec/unit/intercom/search_collection_proxy_spec.rb +32 -28
  81. data/spec/unit/intercom/section_spec.rb +32 -0
  82. data/spec/unit/intercom/segment_spec.rb +2 -2
  83. data/spec/unit/intercom/subscription_spec.rb +5 -6
  84. data/spec/unit/intercom/tag_spec.rb +22 -14
  85. data/spec/unit/intercom/team_spec.rb +2 -2
  86. data/spec/unit/intercom/traits/api_resource_spec.rb +107 -52
  87. data/spec/unit/intercom/user_spec.rb +224 -226
  88. data/spec/unit/intercom/visitor_spec.rb +49 -0
  89. data/spec/unit/intercom_spec.rb +5 -3
  90. metadata +34 -8
  91. data/lib/intercom/customer.rb +0 -10
  92. data/lib/intercom/service/customer.rb +0 -14
  93. 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
@@ -1,7 +1,9 @@
1
- require "spec_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
2
4
 
3
5
  describe Intercom do
4
- it "has a version number" do
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: 3.9.5
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: 2019-11-14 00:00:00.000000000 Z
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/customer.rb
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/customer.rb
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/visitors_spec.rb
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
- rubyforge_project:
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/visitors_spec.rb
308
+ - spec/unit/intercom/visitor_spec.rb
283
309
  - spec/unit/intercom_spec.rb
@@ -1,10 +0,0 @@
1
- require 'intercom/traits/api_resource'
2
-
3
- module Intercom
4
- class Customer
5
- include Traits::ApiResource
6
-
7
- def identity_vars ; [:id, :email, :user_id] ; end
8
- def flat_store_attributes ; [:custom_attributes] ; end
9
- end
10
- end
@@ -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