Skip to content

Commit 80450e8

Browse files
authored
Allow all conversations to be listed (#430)
1 parent 400c6fc commit 80450e8

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ intercom.notes.find_all(user_id: '123').each {|note| puts note.body}
176176

177177
#### Conversations
178178
```ruby
179+
# Iterate over all conversations for your app
180+
intercom.conversations.all.each { |convo| ... }
181+
179182
# FINDING CONVERSATIONS FOR AN ADMIN
180183
# Iterate over all conversations (open and closed) assigned to an admin
181184
intercom.conversations.find_all(type: 'admin', id: '7').each {|convo| ... }

lib/intercom/service/conversation.rb

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Intercom
99
module Service
1010
class Conversation < BaseService
1111
include ApiOperations::FindAll
12+
include ApiOperations::List
1213
include ApiOperations::Find
1314
include ApiOperations::Load
1415
include ApiOperations::Save

spec/spec_helper.rb

+50
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,56 @@ def test_conversation
291291
}
292292
end
293293

294+
def test_conversation_list
295+
{
296+
"type" => "conversation.list",
297+
"pages" => {
298+
"type" => "pages",
299+
"page" => 1,
300+
"per_page" => 20,
301+
"total_pages" => 1
302+
},
303+
"conversations" => [
304+
{
305+
"type" => "conversation",
306+
"id" => "147",
307+
"created_at" => 1400850973,
308+
"updated_at" => 1400857494,
309+
"conversation_message" => {
310+
"type" => "conversation_message",
311+
"subject" => "",
312+
"body" => "<p>Hi Alice,</p>\n\n<p>We noticed you using our Product, do you have any questions?</p> \n<p>- Jane</p>",
313+
"author" => {
314+
"type" => "admin",
315+
"id" => "25"
316+
},
317+
"attachments" => [
318+
{
319+
"name" => "signature",
320+
"url" => "http =>//someurl.com/signature.jpg"
321+
}
322+
]
323+
},
324+
"user" => {
325+
"type" => "user",
326+
"id" => "536e564f316c83104c000020"
327+
},
328+
"assignee" => {
329+
"type" => "admin",
330+
"id" => "25"
331+
},
332+
"open" => true,
333+
"read" => true,
334+
"conversation_parts" => {
335+
"type" => "conversation_part.list",
336+
"conversation_parts" => [
337+
]
338+
}
339+
}
340+
]
341+
}
342+
end
343+
294344
def segment
295345
{
296346
"type" => "segment",

spec/unit/intercom/conversation_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
client.conversations.find(:id => "147")
99
end
1010

11+
it "gets all conversations" do
12+
client.expects(:get).with("/conversations", {}).returns(test_conversation_list)
13+
client.conversations.all.each { |c| }
14+
end
15+
1116
it 'marks a conversation as read' do
1217
client.expects(:put).with('/conversations/147', { read: true })
1318
client.conversations.mark_read('147')

0 commit comments

Comments
 (0)