intercom 3.5.10 → 3.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +35 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +5 -0
  4. data/Gemfile +1 -4
  5. data/README.md +152 -83
  6. data/RELEASING.md +9 -0
  7. data/changes.txt +116 -0
  8. data/intercom.gemspec +1 -2
  9. data/lib/intercom.rb +4 -0
  10. data/lib/intercom/api_operations/{delete.rb → archive.rb} +4 -2
  11. data/lib/intercom/api_operations/find_all.rb +1 -1
  12. data/lib/intercom/api_operations/request_hard_delete.rb +12 -0
  13. data/lib/intercom/api_operations/search.rb +17 -0
  14. data/lib/intercom/client.rb +42 -5
  15. data/lib/intercom/customer.rb +10 -0
  16. data/lib/intercom/errors.rb +41 -4
  17. data/lib/intercom/request.rb +144 -81
  18. data/lib/intercom/search_collection_proxy.rb +82 -0
  19. data/lib/intercom/service/base_service.rb +6 -0
  20. data/lib/intercom/service/company.rb +14 -2
  21. data/lib/intercom/service/contact.rb +4 -2
  22. data/lib/intercom/service/conversation.rb +12 -0
  23. data/lib/intercom/service/customer.rb +14 -0
  24. data/lib/intercom/service/event.rb +12 -0
  25. data/lib/intercom/service/subscription.rb +2 -2
  26. data/lib/intercom/service/tag.rb +1 -1
  27. data/lib/intercom/service/team.rb +17 -0
  28. data/lib/intercom/service/user.rb +4 -2
  29. data/lib/intercom/service/visitor.rb +2 -2
  30. data/lib/intercom/team.rb +7 -0
  31. data/lib/intercom/traits/api_resource.rb +4 -9
  32. data/lib/intercom/version.rb +1 -1
  33. data/spec/spec_helper.rb +124 -2
  34. data/spec/unit/intercom/client_collection_proxy_spec.rb +5 -5
  35. data/spec/unit/intercom/client_spec.rb +69 -1
  36. data/spec/unit/intercom/company_spec.rb +20 -16
  37. data/spec/unit/intercom/contact_spec.rb +6 -0
  38. data/spec/unit/intercom/conversation_spec.rb +15 -0
  39. data/spec/unit/intercom/event_spec.rb +19 -0
  40. data/spec/unit/intercom/request_spec.rb +150 -9
  41. data/spec/unit/intercom/search_collection_proxy_spec.rb +56 -0
  42. data/spec/unit/intercom/team_spec.rb +21 -0
  43. data/spec/unit/intercom/traits/api_resource_spec.rb +34 -7
  44. data/spec/unit/intercom/user_spec.rb +15 -3
  45. metadata +33 -22
  46. data/.travis.yml +0 -6
  47. data/lib/intercom/extended_api_operations/users.rb +0 -16
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe "Intercom::Team" do
4
+ let (:client) { Intercom::Client.new(token: 'token') }
5
+
6
+ it "returns a CollectionProxy for all without making any requests" do
7
+ client.expects(:execute_request).never
8
+ all = client.teams.all
9
+ all.must_be_instance_of(Intercom::ClientCollectionProxy)
10
+ end
11
+
12
+ it 'gets an team list' do
13
+ client.expects(:get).with("/teams", {}).returns(test_team_list)
14
+ client.teams.all.each { |t| }
15
+ end
16
+
17
+ it "gets an team" do
18
+ client.expects(:get).with("/teams/1234", {}).returns(test_team)
19
+ client.teams.find(:id => "1234")
20
+ end
21
+ end
@@ -17,14 +17,30 @@ describe Intercom::Traits::ApiResource do
17
17
  "color"=>"cyan"
18
18
  }}
19
19
  end
20
+
21
+ let(:object_hash) do
22
+ {
23
+ type: "company",
24
+ id: "aaaaaaaaaaaaaaaaaaaaaaaa",
25
+ app_id: "some-app-id",
26
+ name: "SuperSuite",
27
+ plan_id: 1,
28
+ remote_company_id: "8",
29
+ remote_created_at: 103201,
30
+ created_at: 1374056196,
31
+ user_count: 1,
32
+ custom_attributes: { type: "ping" },
33
+ metadata: {
34
+ type: "user",
35
+ color: "cyan"
36
+ }
37
+ }
38
+ end
39
+
20
40
  let(:api_resource) { DummyClass.new.extend(Intercom::Traits::ApiResource)}
21
41
 
22
42
  before(:each) { api_resource.from_response(object_json) }
23
43
 
24
- it "does not set type on parsing json" do
25
- api_resource.wont_respond_to :type
26
- end
27
-
28
44
  it "coerces time on parsing json" do
29
45
  assert_equal Time.at(1374056196), api_resource.created_at
30
46
  end
@@ -76,18 +92,29 @@ describe Intercom::Traits::ApiResource do
76
92
  proc { api_resource.send(:flubber=, 'a', 'b') }.must_raise NoMethodError
77
93
  end
78
94
 
79
- it "an initialized ApiResource is equal to on generated from a response" do
95
+ it "an initialized ApiResource is equal to one generated from a response" do
80
96
  class ConcreteApiResource; include Intercom::Traits::ApiResource; end
81
97
  initialized_api_resource = ConcreteApiResource.new(object_json)
82
98
  except(object_json, 'type').keys.each do |attribute|
83
99
  assert_equal initialized_api_resource.send(attribute), api_resource.send(attribute)
84
100
  end
85
101
  end
86
-
102
+
103
+ it "initialized ApiResource using hash is equal to one generated from response" do
104
+ class ConcreteApiResource; include Intercom::Traits::ApiResource; end
105
+
106
+ api_resource.from_hash(object_hash)
107
+ initialized_api_resource = ConcreteApiResource.new(object_hash)
108
+
109
+ except(object_json, 'type').keys.each do |attribute|
110
+ assert_equal initialized_api_resource.send(attribute), api_resource.send(attribute)
111
+ end
112
+ end
113
+
87
114
  def except(h, *keys)
88
115
  keys.each { |key| h.delete(key) }
89
116
  h
90
117
  end
91
-
118
+
92
119
  class DummyClass; end
93
120
  end
@@ -218,10 +218,22 @@ describe "Intercom::User" do
218
218
  client.users.save(user)
219
219
  end
220
220
 
221
- it "deletes a user" do
221
+ it "archives a user" do
222
222
  user = Intercom::User.new("id" => "1")
223
223
  client.expects(:delete).with("/users/1", {}).returns(user)
224
- client.users.delete(user)
224
+ client.users.archive(user)
225
+ end
226
+ it "has an alias to archive a user" do
227
+ user = Intercom::User.new("id" => "1")
228
+ client.expects(:delete).with("/users/1", {}).returns(user)
229
+ client.users.delete(user)
230
+ end
231
+
232
+
233
+ it "sends a request for a hard deletion" do
234
+ user = Intercom::User.new("id" => "1")
235
+ client.expects(:post).with("/user_delete_requests", {intercom_user_id: "1"}).returns({id: user.id})
236
+ client.users.request_hard_delete(user)
225
237
  end
226
238
 
227
239
  it "can use client.users.create for convenience" do
@@ -239,7 +251,7 @@ describe "Intercom::User" do
239
251
  it "allows setting dates to nil without converting them to 0" do
240
252
  client.expects(:post).with("/users", {"email" => "jo@example.com", 'custom_attributes' => {}, "remote_created_at" => nil}).returns({"email" => "jo@example.com"})
241
253
  user = client.users.create("email" => "jo@example.com", "remote_created_at" => nil)
242
- user.remote_created_at.must_equal nil
254
+ assert_nil user.remote_created_at
243
255
  end
244
256
 
245
257
  it "sets/gets rw keys" do
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.5.10
4
+ version: 3.9.5
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: 2017-01-10 00:00:00.000000000 Z
18
+ date: 2019-11-14 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest
@@ -31,6 +31,20 @@ dependencies:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5.4'
34
+ - !ruby/object:Gem::Dependency
35
+ name: m
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.0
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.5.0
34
48
  - !ruby/object:Gem::Dependency
35
49
  name: rake
36
50
  requirement: !ruby/object:Gem::Requirement
@@ -87,20 +101,6 @@ dependencies:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
- - !ruby/object:Gem::Dependency
91
- name: json
92
- requirement: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '1.8'
97
- type: :runtime
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '1.8'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: gem-release
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -131,12 +131,14 @@ executables: []
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
+ - ".circleci/config.yml"
134
135
  - ".github/ISSUE_TEMPLATE.md"
136
+ - ".github/PULL_REQUEST_TEMPLATE.md"
135
137
  - ".gitignore"
136
- - ".travis.yml"
137
138
  - Gemfile
138
139
  - MIT-LICENSE
139
140
  - README.md
141
+ - RELEASING.md
140
142
  - Rakefile
141
143
  - changes.txt
142
144
  - intercom.gemspec
@@ -144,27 +146,29 @@ files:
144
146
  - lib/ext/sliceable_hash.rb
145
147
  - lib/intercom.rb
146
148
  - lib/intercom/admin.rb
149
+ - lib/intercom/api_operations/archive.rb
147
150
  - lib/intercom/api_operations/bulk/load_error_feed.rb
148
151
  - lib/intercom/api_operations/bulk/submit.rb
149
152
  - lib/intercom/api_operations/convert.rb
150
- - lib/intercom/api_operations/delete.rb
151
153
  - lib/intercom/api_operations/find.rb
152
154
  - lib/intercom/api_operations/find_all.rb
153
155
  - lib/intercom/api_operations/list.rb
154
156
  - lib/intercom/api_operations/load.rb
157
+ - lib/intercom/api_operations/request_hard_delete.rb
155
158
  - lib/intercom/api_operations/save.rb
156
159
  - lib/intercom/api_operations/scroll.rb
160
+ - lib/intercom/api_operations/search.rb
157
161
  - lib/intercom/client.rb
158
162
  - lib/intercom/client_collection_proxy.rb
159
163
  - lib/intercom/company.rb
160
164
  - lib/intercom/contact.rb
161
165
  - lib/intercom/conversation.rb
162
166
  - lib/intercom/count.rb
167
+ - lib/intercom/customer.rb
163
168
  - lib/intercom/errors.rb
164
169
  - lib/intercom/event.rb
165
170
  - lib/intercom/extended_api_operations/segments.rb
166
171
  - lib/intercom/extended_api_operations/tags.rb
167
- - lib/intercom/extended_api_operations/users.rb
168
172
  - lib/intercom/job.rb
169
173
  - lib/intercom/lib/dynamic_accessors.rb
170
174
  - lib/intercom/lib/dynamic_accessors_on_method_missing.rb
@@ -175,6 +179,7 @@ files:
175
179
  - lib/intercom/options.rb
176
180
  - lib/intercom/request.rb
177
181
  - lib/intercom/scroll_collection_proxy.rb
182
+ - lib/intercom/search_collection_proxy.rb
178
183
  - lib/intercom/segment.rb
179
184
  - lib/intercom/service/admin.rb
180
185
  - lib/intercom/service/base_service.rb
@@ -182,6 +187,7 @@ files:
182
187
  - lib/intercom/service/contact.rb
183
188
  - lib/intercom/service/conversation.rb
184
189
  - lib/intercom/service/count.rb
190
+ - lib/intercom/service/customer.rb
185
191
  - lib/intercom/service/event.rb
186
192
  - lib/intercom/service/job.rb
187
193
  - lib/intercom/service/message.rb
@@ -189,10 +195,12 @@ files:
189
195
  - lib/intercom/service/segment.rb
190
196
  - lib/intercom/service/subscription.rb
191
197
  - lib/intercom/service/tag.rb
198
+ - lib/intercom/service/team.rb
192
199
  - lib/intercom/service/user.rb
193
200
  - lib/intercom/service/visitor.rb
194
201
  - lib/intercom/subscription.rb
195
202
  - lib/intercom/tag.rb
203
+ - lib/intercom/team.rb
196
204
  - lib/intercom/traits/api_resource.rb
197
205
  - lib/intercom/traits/dirty_tracking.rb
198
206
  - lib/intercom/traits/incrementable_attributes.rb
@@ -215,9 +223,11 @@ files:
215
223
  - spec/unit/intercom/note_spec.rb
216
224
  - spec/unit/intercom/request_spec.rb
217
225
  - spec/unit/intercom/scroll_collection_proxy_spec.rb
226
+ - spec/unit/intercom/search_collection_proxy_spec.rb
218
227
  - spec/unit/intercom/segment_spec.rb
219
228
  - spec/unit/intercom/subscription_spec.rb
220
229
  - spec/unit/intercom/tag_spec.rb
230
+ - spec/unit/intercom/team_spec.rb
221
231
  - spec/unit/intercom/traits/api_resource_spec.rb
222
232
  - spec/unit/intercom/user_spec.rb
223
233
  - spec/unit/intercom/visitors_spec.rb
@@ -241,8 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
251
  - !ruby/object:Gem::Version
242
252
  version: '0'
243
253
  requirements: []
244
- rubyforge_project: intercom
245
- rubygems_version: 2.4.8
254
+ rubyforge_project:
255
+ rubygems_version: 2.7.6.2
246
256
  signing_key:
247
257
  specification_version: 4
248
258
  summary: Ruby bindings for the Intercom API
@@ -262,11 +272,12 @@ test_files:
262
272
  - spec/unit/intercom/note_spec.rb
263
273
  - spec/unit/intercom/request_spec.rb
264
274
  - spec/unit/intercom/scroll_collection_proxy_spec.rb
275
+ - spec/unit/intercom/search_collection_proxy_spec.rb
265
276
  - spec/unit/intercom/segment_spec.rb
266
277
  - spec/unit/intercom/subscription_spec.rb
267
278
  - spec/unit/intercom/tag_spec.rb
279
+ - spec/unit/intercom/team_spec.rb
268
280
  - spec/unit/intercom/traits/api_resource_spec.rb
269
281
  - spec/unit/intercom/user_spec.rb
270
282
  - spec/unit/intercom/visitors_spec.rb
271
283
  - spec/unit/intercom_spec.rb
272
- has_rdoc:
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.1.0
5
- - 2.2.0
6
- - 2.3.3
@@ -1,16 +0,0 @@
1
- require 'intercom/client_collection_proxy'
2
- require 'intercom/utils'
3
-
4
- module Intercom
5
- module ExtendedApiOperations
6
- module Users
7
- def users(id)
8
- collection_name = Utils.resource_class_to_collection_name(collection_class)
9
- finder_details = {}
10
- finder_details[:url] = "/#{collection_name}/#{id}/users"
11
- finder_details[:params] = {}
12
- ClientCollectionProxy.new("users", finder_details: finder_details, client: @client)
13
- end
14
- end
15
- end
16
- end