intercom 3.1.0 → 3.2.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 +4 -2
- data/changes.txt +4 -0
- data/lib/intercom/lib/dynamic_accessors_on_method_missing.rb +5 -1
- data/lib/intercom/request.rb +2 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/conversation_spec.rb +5 -0
- data/spec/unit/intercom/user_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5ef9d6fa028f29130786bb4e260112ddbbce668
|
4
|
+
data.tar.gz: 23112e23cdf9f44f20d4a55d20bf7070aae80385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e1c851b4481a5a17faf27240766e94b0b92060d0758e079a7f04cac11a9eb1725710b3744149d263737903f0c805d8cdf405d95d7bab8e36106ebe25e814672
|
7
|
+
data.tar.gz: ab37cc7e537610f7fb6748dab499b975a1926043aac9ba313c15a7f097db5aec8ecf6611458675bf7aa716527903d55cb5534227a1e2afd97d9f5bc6c0e49df7
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ This version of the gem is compatible with `Ruby 2.1` and above.
|
|
22
22
|
|
23
23
|
Using bundler:
|
24
24
|
|
25
|
-
gem 'intercom', "~> 3.
|
25
|
+
gem 'intercom', "~> 3.2.0"
|
26
26
|
|
27
27
|
## Basic Usage
|
28
28
|
|
@@ -177,6 +177,8 @@ conversation.conversation_parts[1].body
|
|
177
177
|
intercom.conversations.reply(:id => conversation.id, :type => 'user', :email => 'joe@example.com', :message_type => 'comment', :body => 'foo')
|
178
178
|
# Admin (identified by id) replies with a comment
|
179
179
|
intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'comment', :body => 'bar')
|
180
|
+
# User (identified by email) replies with a comment and attachment
|
181
|
+
intercom.conversations.reply(:id => conversation.id, :type => 'user', :email => 'joe@example.com', :message_type => 'comment', :body => 'foo', :attachment => ['http://www.example.com/attachment.jpg'])
|
180
182
|
|
181
183
|
# Open
|
182
184
|
intercom.conversations.open(id: conversation.id, admin_id: '123')
|
@@ -333,7 +335,7 @@ contacts = intercom.contacts.find_all(email: "some_contact@example.com")
|
|
333
335
|
intercom.contacts.convert(contact, user)
|
334
336
|
|
335
337
|
# Delete a contact
|
336
|
-
intercom.contacts.
|
338
|
+
intercom.contacts.delete(contact)
|
337
339
|
```
|
338
340
|
|
339
341
|
### Counts
|
data/changes.txt
CHANGED
@@ -18,7 +18,7 @@ module Intercom
|
|
18
18
|
Lib::DynamicAccessors.define_accessors(attribute_name, *arguments, object)
|
19
19
|
object.send(method_sym, *arguments)
|
20
20
|
else # getter
|
21
|
-
if trying_to_access_private_variable?
|
21
|
+
if trying_to_access_private_variable? || trying_to_access_print_method?
|
22
22
|
yield
|
23
23
|
else
|
24
24
|
raise Intercom::AttributeNotSetError, attribute_not_set_error_message
|
@@ -44,6 +44,10 @@ module Intercom
|
|
44
44
|
object.instance_variable_defined?("@#{method_string}")
|
45
45
|
end
|
46
46
|
|
47
|
+
def trying_to_access_print_method?
|
48
|
+
[:to_ary, :to_s].include? method_sym
|
49
|
+
end
|
50
|
+
|
47
51
|
def attribute_not_set_error_message
|
48
52
|
"'#{method_string}' called on #{klass} but it has not been set an " +
|
49
53
|
"attribute or does not exist as a method"
|
data/lib/intercom/request.rb
CHANGED
@@ -136,7 +136,7 @@ module Intercom
|
|
136
136
|
case error_code
|
137
137
|
when 'unauthorized', 'forbidden'
|
138
138
|
raise Intercom::AuthenticationError.new(error_details['message'], error_context)
|
139
|
-
when "bad_request", "missing_parameter", 'parameter_invalid'
|
139
|
+
when "bad_request", "missing_parameter", 'parameter_invalid', 'parameter_not_found'
|
140
140
|
raise Intercom::BadRequestError.new(error_details['message'], error_context)
|
141
141
|
when "not_found"
|
142
142
|
raise Intercom::ResourceNotFound.new(error_details['message'], error_context)
|
@@ -144,7 +144,7 @@ module Intercom
|
|
144
144
|
raise Intercom::RateLimitExceeded.new(error_details['message'], error_context)
|
145
145
|
when 'service_unavailable'
|
146
146
|
raise Intercom::ServiceUnavailableError.new(error_details['message'], error_context)
|
147
|
-
when 'conflict'
|
147
|
+
when 'conflict', 'unique_user_constraint'
|
148
148
|
raise Intercom::MultipleMatchingUsersError.new(error_details['message'], error_context)
|
149
149
|
when nil, ''
|
150
150
|
raise Intercom::UnexpectedError.new(message_for_unexpected_error_without_type(error_details, parsed_http_code), error_context)
|
data/lib/intercom/version.rb
CHANGED
@@ -18,6 +18,11 @@ describe "Intercom::Conversation" do
|
|
18
18
|
client.conversations.reply(id: '147', type: 'user', body: 'Thanks again', message_type: 'comment', user_id: 'ac4')
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'replies to a conversation with an attachment' do
|
22
|
+
client.expects(:post).with('/conversations/147/reply', { type: 'user', body: 'Thanks again', message_type: 'comment', user_id: 'ac4', conversation_id: '147', attachment_urls: ["http://www.example.com/attachment.jpg"] }).returns(test_conversation)
|
23
|
+
client.conversations.reply(id: '147', type: 'user', body: 'Thanks again', message_type: 'comment', user_id: 'ac4', attachment_urls: ["http://www.example.com/attachment.jpg"])
|
24
|
+
end
|
25
|
+
|
21
26
|
it 'opens a conversation' do
|
22
27
|
client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'open', conversation_id: '147', admin_id: '123'}).returns(test_conversation)
|
23
28
|
client.conversations.open(id: '147', admin_id: '123')
|
@@ -235,4 +235,11 @@ describe "Intercom::User" do
|
|
235
235
|
all.must_be_instance_of(Intercom::ClientCollectionProxy)
|
236
236
|
end
|
237
237
|
|
238
|
+
it 'can print users without crashing' do
|
239
|
+
client.expects(:get).with("/users", {"email" => "bo@example.com"}).returns(test_user)
|
240
|
+
user = client.users.find("email" => "bo@example.com")
|
241
|
+
puts user
|
242
|
+
p user
|
243
|
+
end
|
244
|
+
|
238
245
|
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.
|
4
|
+
version: 3.2.0
|
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: 2015-
|
18
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|