Skip to content

Commit f3f3b9c

Browse files
committed
Merge pull request #97 from intercom/BL/conversationsapi
Support assignments
2 parents 069a4bc + 56cda03 commit f3f3b9c

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ $intercom->replyToConversation(array(
331331
"message_type" => "comment"
332332
"body" => "bar"
333333
));
334+
// Admin (identified by id) assigns a conversation
335+
$intercom->replyToConversation(array(
336+
"id" => $conversation["id"],
337+
"type" => "admin",
338+
"admin_id" => "1",
339+
"message_type" => "assignment",
340+
"assignee_id" => "2"
341+
));
342+
334343

335344
// MARKING A CONVERSATION AS READ
336345
$intercom->markConversationAsRead(array("id" => $conversation["id"], "read": true));

src/Intercom/Service/config/intercom_public_conversation.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,19 @@
174174
"required": false,
175175
"type": "string"
176176
},
177+
"assignee_id": {
178+
"location": "json",
179+
"required": false,
180+
"type": "string"
181+
},
177182
"type": {
178183
"location": "json",
179184
"required": true,
180185
"type": "string"
181186
},
182187
"body": {
183188
"location": "json",
184-
"required": true,
189+
"required": false,
185190
"type": "string"
186191
},
187192
"message_type": {

tests/Intercom/Resources/ConversationTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testGetAllConversations()
6767
$this->assertEquals('536e564f316c83104c000020', $conversations['0']['user']['id']);
6868
$this->assertEquals('admin', $conversations['0']['assignee']['type']);
6969
}
70-
70+
7171
public function testGetUserConversations()
7272
{
7373
$this->setMockResponse($this->client, 'Conversation/ConversationList.txt');
@@ -76,7 +76,7 @@ public function testGetUserConversations()
7676

7777
$this->assertRequest('GET', '/conversations?type=user');
7878
}
79-
79+
8080
public function testGetAdminConversations()
8181
{
8282
$this->setMockResponse($this->client, 'Conversation/ConversationList.txt');
@@ -111,6 +111,13 @@ public function testReplyToConversationAsAdmin() {
111111
$this->assertRequestJson(['admin_id' => '6', 'type' => 'admin', 'body' => 'my reply', 'message_type' => 'comment']);
112112
}
113113

114+
public function testAssignConversationAsAdmin() {
115+
$this->setMockResponse($this->client, 'Conversation/Conversation.txt');
116+
$this->client->replyToConversation(['id' => '123456', 'admin_id' => '6', 'type' => 'admin', 'message_type' => 'assignment', 'assignee_id' => '7']);
117+
$this->assertRequest('POST', '/conversations/123456/reply');
118+
$this->assertRequestJson(['admin_id' => '6', 'assignee_id' => '7', 'type' => 'admin', 'message_type' => 'assignment']);
119+
}
120+
114121
public function testMarkConversationAsRead()
115122
{
116123
$this->setMockResponse($this->client, 'Conversation/Conversation.txt');

0 commit comments

Comments
 (0)