intercom 3.5.22 → 3.5.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/changes.txt +3 -0
- data/lib/intercom/errors.rb +6 -3
- data/lib/intercom/request.rb +2 -0
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/request_spec.rb +16 -4
- metadata +4 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e68aeb1127d2cf823cc5dd0ddd659dcd3c87b21
|
4
|
+
data.tar.gz: 47726ed9aaa657973655766fbde7562aa106f9bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22c0957deab7de22f497ace8c4b5e2c51a36719cd12abae4dc83c89525b795b665c04fb62b1a85e537c4e9e9a5ee6a84beef9aad4920e8a3f281bcdd1300f189
|
7
|
+
data.tar.gz: 579157330addc830b0c64bf48f0721d94f956e30a1248d59380c6284ca32bd2ff43e7b49f6f67db94ac3e75e5074c3020eeb50d2c39741d8ef327c2002472d34
|
data/README.md
CHANGED
data/changes.txt
CHANGED
data/lib/intercom/errors.rb
CHANGED
@@ -42,6 +42,9 @@ module Intercom
|
|
42
42
|
# Raised when requesting resources on behalf of a user that doesn't exist in your application on Intercom.
|
43
43
|
class ResourceNotFound < IntercomError; end
|
44
44
|
|
45
|
+
# Raised when trying to create a resource that already exists in Intercom.
|
46
|
+
class ResourceNotUniqueError < IntercomError; end
|
47
|
+
|
45
48
|
# Raised when the request has bad syntax
|
46
49
|
class BadRequestError < IntercomError; end
|
47
50
|
|
@@ -55,13 +58,13 @@ module Intercom
|
|
55
58
|
class MultipleMatchingUsersError < IntercomError; end
|
56
59
|
|
57
60
|
# Raised when restoring a blocked user
|
58
|
-
class BlockedUserError < IntercomError
|
61
|
+
class BlockedUserError < IntercomError; end
|
59
62
|
|
60
63
|
# Raised when you try to call a non-setter method that does not exist on an object
|
61
|
-
class Intercom::AttributeNotSetError < IntercomError
|
64
|
+
class Intercom::AttributeNotSetError < IntercomError; end
|
62
65
|
|
63
66
|
# Raised when unexpected nil returned from server
|
64
|
-
class Intercom::HttpError < IntercomError
|
67
|
+
class Intercom::HttpError < IntercomError; end
|
65
68
|
|
66
69
|
#
|
67
70
|
# Non-public errors (internal to the gem)
|
data/lib/intercom/request.rb
CHANGED
@@ -163,6 +163,8 @@ module Intercom
|
|
163
163
|
raise Intercom::ServiceUnavailableError.new(error_details['message'], error_context)
|
164
164
|
when 'conflict', 'unique_user_constraint'
|
165
165
|
raise Intercom::MultipleMatchingUsersError.new(error_details['message'], error_context)
|
166
|
+
when 'resource_conflict'
|
167
|
+
raise Intercom::ResourceNotUniqueError.new(error_details['message'], error_context)
|
166
168
|
when nil, ''
|
167
169
|
raise Intercom::UnexpectedError.new(message_for_unexpected_error_without_type(error_details, parsed_http_code), error_context)
|
168
170
|
else
|
data/lib/intercom/version.rb
CHANGED
@@ -7,13 +7,13 @@ describe 'Intercom::Request' do
|
|
7
7
|
it 'raises an error when a html error page rendered' do
|
8
8
|
response = OpenStruct.new(:code => 500)
|
9
9
|
req = Intercom::Request.new('path/', 'GET')
|
10
|
-
proc {req.parse_body('<html>
|
10
|
+
proc {req.parse_body('<html>something</html>', response)}.must_raise(Intercom::ServerError)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'raises a RateLimitExceeded error when the response code is 429' do
|
14
14
|
response = OpenStruct.new(:code => 429)
|
15
15
|
req = Intercom::Request.new('path/', 'GET')
|
16
|
-
proc {req.parse_body('<html>
|
16
|
+
proc {req.parse_body('<html>something</html>', response)}.must_raise(Intercom::RateLimitExceeded)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'parse_body raises an error if the decoded_body is "null"' do
|
@@ -23,8 +23,8 @@ describe 'Intercom::Request' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'Intercom::Client' do
|
26
|
-
let
|
27
|
-
let
|
26
|
+
let(:client) { Intercom::Client.new(token: 'foo', handle_rate_limit: true) }
|
27
|
+
let(:uri) {"https://api.intercom.io/users"}
|
28
28
|
|
29
29
|
it 'should have handle_rate_limit set' do
|
30
30
|
client.handle_rate_limit.must_equal(true)
|
@@ -63,6 +63,18 @@ describe 'Intercom::Request' do
|
|
63
63
|
|
64
64
|
end
|
65
65
|
|
66
|
+
|
67
|
+
describe "Application errors on failure" do
|
68
|
+
let(:uri) {"https://api.intercom.io/conversations/reply"}
|
69
|
+
it 'should raise ResourceNotUniqueError error on resource_conflict code' do
|
70
|
+
# Use webmock to mock the HTTP request
|
71
|
+
stub_request(:put, uri).\
|
72
|
+
to_return(status: [409, "Resource Already Exists"], headers: { 'X-RateLimit-Reset' => Time.now.utc + 10 }, body: {type: "error.list", errors: [ code: "resource_conflict" ]}.to_json)
|
73
|
+
req = Intercom::Request.put(uri, "")
|
74
|
+
expect { req.execute(target_base_url=uri, username: "ted", secret: "") }.must_raise(Intercom::ResourceNotUniqueError)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
66
78
|
it 'parse_body returns nil if decoded_body is nil' do
|
67
79
|
response = OpenStruct.new(:code => 500)
|
68
80
|
req = Intercom::Request.new('path/', 'GET')
|
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.
|
4
|
+
version: 3.5.23
|
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-
|
18
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|
@@ -244,30 +244,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
version: '0'
|
245
245
|
requirements: []
|
246
246
|
rubyforge_project: intercom
|
247
|
-
rubygems_version: 2.
|
247
|
+
rubygems_version: 2.5.1
|
248
248
|
signing_key:
|
249
249
|
specification_version: 4
|
250
250
|
summary: Ruby bindings for the Intercom API
|
251
|
-
test_files:
|
252
|
-
- spec/spec_helper.rb
|
253
|
-
- spec/unit/intercom/admin_spec.rb
|
254
|
-
- spec/unit/intercom/client_collection_proxy_spec.rb
|
255
|
-
- spec/unit/intercom/client_spec.rb
|
256
|
-
- spec/unit/intercom/company_spec.rb
|
257
|
-
- spec/unit/intercom/contact_spec.rb
|
258
|
-
- spec/unit/intercom/conversation_spec.rb
|
259
|
-
- spec/unit/intercom/count_spec.rb
|
260
|
-
- spec/unit/intercom/event_spec.rb
|
261
|
-
- spec/unit/intercom/job_spec.rb
|
262
|
-
- spec/unit/intercom/lib/flat_store_spec.rb
|
263
|
-
- spec/unit/intercom/message_spec.rb
|
264
|
-
- spec/unit/intercom/note_spec.rb
|
265
|
-
- spec/unit/intercom/request_spec.rb
|
266
|
-
- spec/unit/intercom/scroll_collection_proxy_spec.rb
|
267
|
-
- spec/unit/intercom/segment_spec.rb
|
268
|
-
- spec/unit/intercom/subscription_spec.rb
|
269
|
-
- spec/unit/intercom/tag_spec.rb
|
270
|
-
- spec/unit/intercom/traits/api_resource_spec.rb
|
271
|
-
- spec/unit/intercom/user_spec.rb
|
272
|
-
- spec/unit/intercom/visitors_spec.rb
|
273
|
-
- spec/unit/intercom_spec.rb
|
251
|
+
test_files: []
|