intercom 3.0.6 → 3.1.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/.travis.yml +1 -0
- data/README.md +28 -10
- data/changes.txt +3 -0
- data/lib/intercom/service/conversation.rb +13 -0
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/conversation_spec.rb +15 -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: 31f3539ed98058a5c24a7cf551db9526f5e1530d
|
4
|
+
data.tar.gz: 94d747068a98e5effc4fc3304e2b7d844c2e48bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3ff736bf9162f1a4cafe237c72d8ef1ba5bce906cab9c9264376bba4d5c7c277f86f0e17259faa6950413363598d1b15562c099b15cffdef0ffea39ff401a6a
|
7
|
+
data.tar.gz: 156f6ca74ac7ca7bffb4367d9b0efb95ef889c1b36addecfe938b17552b75c58a3c07dc9c6ffbac5805fc2bba0de714333e73a8babe19d053ee4e93dd81bcf4b
|
data/.travis.yml
CHANGED
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.0
|
25
|
+
gem 'intercom', "~> 3.1.0"
|
26
26
|
|
27
27
|
## Basic Usage
|
28
28
|
|
@@ -145,21 +145,21 @@ intercom.notes.find_all(:user_id => '123').each {|note| puts note.body}
|
|
145
145
|
```ruby
|
146
146
|
# FINDING CONVERSATIONS FOR AN ADMIN
|
147
147
|
# Iterate over all conversations (open and closed) assigned to an admin
|
148
|
-
intercom.conversations.find_all(:type => 'admin', :id => '7').each
|
148
|
+
intercom.conversations.find_all(:type => 'admin', :id => '7').each {|convo| ... }
|
149
149
|
# Iterate over all open conversations assigned to an admin
|
150
|
-
intercom.conversations.find_all(:type => 'admin', :id => 7, :open => true).each
|
150
|
+
intercom.conversations.find_all(:type => 'admin', :id => 7, :open => true).each {|convo| ... }
|
151
151
|
# Iterate over closed conversations assigned to an admin
|
152
|
-
intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false).each
|
152
|
+
intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false).each {|convo| ... }
|
153
153
|
# Iterate over closed conversations for assigned an admin, before a certain moment in time
|
154
|
-
intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false, :before => 1374844930).each
|
154
|
+
intercom.conversations.find_all(:type => 'admin', :id => 7, :open => false, :before => 1374844930).each {|convo| ... }
|
155
155
|
|
156
156
|
# FINDING CONVERSATIONS FOR A USER
|
157
157
|
# Iterate over all conversations (read + unread, correct) with a user based on the users email
|
158
|
-
intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user').each
|
158
|
+
intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user').each {|convo| ... }
|
159
159
|
# Iterate over through all conversations (read + unread) with a user based on the users email
|
160
|
-
intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => false).each
|
160
|
+
intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => false).each {|convo| ... }
|
161
161
|
# Iterate over all unread conversations with a user based on the users email
|
162
|
-
intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => true).each
|
162
|
+
intercom.conversations.find_all(:email => 'joe@example.com', :type => 'user', :unread => true).each {|convo| ... }
|
163
163
|
|
164
164
|
# FINDING A SINGLE CONVERSATION
|
165
165
|
conversation = intercom.conversations.find(:id => '1')
|
@@ -175,8 +175,26 @@ conversation.conversation_parts[1].body
|
|
175
175
|
# REPLYING TO CONVERSATIONS
|
176
176
|
# User (identified by email) replies with a comment
|
177
177
|
intercom.conversations.reply(:id => conversation.id, :type => 'user', :email => 'joe@example.com', :message_type => 'comment', :body => 'foo')
|
178
|
-
# Admin (identified by
|
179
|
-
intercom.conversations.reply(:id => conversation.id, :type => 'admin', :
|
178
|
+
# Admin (identified by id) replies with a comment
|
179
|
+
intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'comment', :body => 'bar')
|
180
|
+
|
181
|
+
# Open
|
182
|
+
intercom.conversations.open(id: conversation.id, admin_id: '123')
|
183
|
+
|
184
|
+
# Close
|
185
|
+
intercom.conversations.close(id: conversation.id, admin_id: '123')
|
186
|
+
|
187
|
+
# Assign
|
188
|
+
intercom.conversations.assign(id: conversation.id, admin_id: '123', assignee_id: '124')
|
189
|
+
|
190
|
+
# Reply and Open
|
191
|
+
intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'open', :body => 'bar')
|
192
|
+
|
193
|
+
# Reply and Close
|
194
|
+
intercom.conversations.reply(:id => conversation.id, :type => 'admin', :admin_id => '123', :message_type => 'close', :body => 'bar')
|
195
|
+
|
196
|
+
# ASSIGNING CONVERSATIONS TO ADMINS
|
197
|
+
intercom.conversations.reply(:id => conversation.id, :type => 'admin', :assignee_id => assignee_admin.id, :admin_id => admin.id, :message_type => 'assignment')
|
180
198
|
|
181
199
|
# MARKING A CONVERSATION AS READ
|
182
200
|
intercom.conversations.mark_read(conversation.id)
|
data/changes.txt
CHANGED
@@ -26,6 +26,19 @@ module Intercom
|
|
26
26
|
response = @client.post("/#{collection_name}/#{id}/reply", reply_data.merge(:conversation_id => id))
|
27
27
|
collection_class.new.from_response(response)
|
28
28
|
end
|
29
|
+
|
30
|
+
def open(reply_data)
|
31
|
+
reply reply_data.merge(message_type: 'open', type: 'admin')
|
32
|
+
end
|
33
|
+
|
34
|
+
def close(reply_data)
|
35
|
+
reply reply_data.merge(message_type: 'close', type: 'admin')
|
36
|
+
end
|
37
|
+
|
38
|
+
def assign(reply_data)
|
39
|
+
assignee_id = reply_data.fetch(:assignee_id) { fail 'assignee_id is required' }
|
40
|
+
reply reply_data.merge(message_type: 'assignment', assignee_id: assignee_id, type: 'admin')
|
41
|
+
end
|
29
42
|
end
|
30
43
|
end
|
31
44
|
end
|
data/lib/intercom/version.rb
CHANGED
@@ -18,6 +18,21 @@ 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 'opens a conversation' do
|
22
|
+
client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'open', conversation_id: '147', admin_id: '123'}).returns(test_conversation)
|
23
|
+
client.conversations.open(id: '147', admin_id: '123')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'closes a conversation' do
|
27
|
+
client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'close', conversation_id: '147', admin_id: '123'}).returns(test_conversation)
|
28
|
+
client.conversations.close(id: '147', admin_id: '123')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'assigns a conversation' do
|
32
|
+
client.expects(:post).with('/conversations/147/reply', { type: 'admin', message_type: 'assignment', conversation_id: '147', admin_id: '123', assignee_id: '124'}).returns(test_conversation)
|
33
|
+
client.conversations.assign(id: '147', admin_id: '123', assignee_id: '124')
|
34
|
+
end
|
35
|
+
|
21
36
|
# it "creates a subscription" do
|
22
37
|
# client.expects(:post).with("/subscriptions", {'url' => "http://example.com", 'topics' => ["user.created"]}).returns(test_subscription)
|
23
38
|
# subscription = client.subscriptions.create(:url => "http://example.com", :topics => ["user.created"])
|
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.0
|
4
|
+
version: 3.1.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-07-
|
18
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|