-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from matt-h/embedded-threads
Support hydrating embedded threads in incoming webhooks
- Loading branch information
Showing
3 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,4 +239,5 @@ public function withQuery(string $query): ConversationFilters | |
|
||
return $filters; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,56 @@ public function testHydrateWhenCustomerExistsButIsNull() | |
$this->assertFalse($conversation->wasCreatedByUser()); | ||
} | ||
|
||
public function testHydrateEmbedded() | ||
{ | ||
$conversation = new Conversation(); | ||
$embeddedFixation = [ | ||
'threads' => [ | ||
[ | ||
'id' => 2198262392, | ||
'assignedTo' => null, | ||
'status' => 'active', | ||
'createdAt' => '2019-02-28T15:48:20Z', | ||
'createdBy' => [ | ||
'id' => 179783313, | ||
'firstName' => 'John', | ||
'lastName' => 'Smith', | ||
'email' => '[email protected]', | ||
'type' => 'customer', | ||
], | ||
'source' => [ | ||
'type' => 'email', | ||
'via' => 'customer', | ||
], | ||
'actionType' => null, | ||
'actionSourceId' => 0, | ||
'fromMailbox' => null, | ||
'type' => 'customer', | ||
'state' => 'published', | ||
'customer' => [ | ||
'id' => 179783313, | ||
'firstName' => 'John', | ||
'lastName' => 'Smith', | ||
'email' => '[email protected]', | ||
'type' => 'customer', | ||
], | ||
'body' => 'Are you still interested in a demo?', | ||
'to' => [], | ||
'cc' => null, | ||
'bcc' => null, | ||
'attachments' => null, | ||
], | ||
], | ||
]; | ||
$conversation->hydrate(['threads' => 1], $embeddedFixation); | ||
|
||
$this->assertSame(1, $conversation->getThreadCount()); | ||
|
||
$thread = $conversation->getThreads()[0]; | ||
$this->assertInstanceOf(CustomerThread::class, $thread); | ||
$this->assertSame(2198262392, $thread->getId()); | ||
} | ||
|
||
public function testExtractsCreatedByUser() | ||
{ | ||
$conversation = new Conversation(); | ||
|