Skip to content

Commit 8319421

Browse files
authored
Add create conversation method (intercom#338)
* Add create conversation method * Add test of create conversation method * Add create conversation method's description to README Co-authored-by: mass-min <[email protected]>
1 parent 51982e4 commit 8319421

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Diff for: README.md

+12
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,18 @@ $client->messages->create([
432432
## Conversations
433433

434434
```php
435+
/**
436+
* Create a conversation
437+
* See more options here: https://developers.intercom.com/intercom-api-reference/reference#create-a-conversation
438+
*/
439+
$client->conversations->create([
440+
'body' => 'Hello.',
441+
'from' => [
442+
'id' => '1234',
443+
'type' => 'user',
444+
],
445+
]);
446+
435447
/**
436448
* List conversations for an admin
437449
* See more options here: https://developers.intercom.io/reference#list-conversations

Diff for: src/IntercomConversations.php

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77

88
class IntercomConversations extends IntercomResource
99
{
10+
/**
11+
* Creates a Conversation.
12+
*
13+
* @see https://developers.intercom.com/intercom-api-reference/reference#create-a-conversation
14+
* @param array $options
15+
* @return stdClass
16+
* @throws Exception
17+
*/
18+
public function create(array $options)
19+
{
20+
return $this->client->post('conversations', $options);
21+
}
22+
1023
/**
1124
* Returns list of Conversations.
1225
*

Diff for: tests/IntercomConversationsTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88
class IntercomConversationsTest extends TestCase
99
{
10+
public function testConversationCreate()
11+
{
12+
$this->client->method('post')->willReturn('foo');
13+
14+
$conversations = new IntercomConversations($this->client);
15+
$this->assertSame('foo', $conversations->create([]));
16+
}
17+
1018
public function testConversationsList()
1119
{
1220
$this->client->method('get')->willReturn('foo');

0 commit comments

Comments
 (0)