-
Notifications
You must be signed in to change notification settings - Fork 140
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 #281 from intercom/AP/customer-search
Add customer search
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Intercom; | ||
|
||
use Http\Client\Exception; | ||
use stdClass; | ||
|
||
class IntercomCustomers | ||
{ | ||
|
||
/** | ||
* @var IntercomClient | ||
*/ | ||
private $client; | ||
|
||
/** | ||
* IntercomCustomers constructor. | ||
* | ||
* @param IntercomClient $client | ||
*/ | ||
public function __construct($client) | ||
{ | ||
$this->client = $client; | ||
} | ||
|
||
/** | ||
* Search Customers | ||
* | ||
* @see https://developers.intercom.com/intercom-api-reference/v0/reference#customers | ||
* @param array query | ||
* @return stdClass | ||
* @throws Exception | ||
*/ | ||
public function search($query) | ||
{ | ||
return $this->client->post('customers/search', $query); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Intercom\Test; | ||
|
||
use Intercom\IntercomCustomers; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IntercomCustomersTest extends TestCase | ||
{ | ||
public function testCustomerSearch() | ||
{ | ||
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock(); | ||
$stub->method('post')->willReturn('foo'); | ||
|
||
$customers = new IntercomCustomers($stub); | ||
$this->assertEquals('foo', $customers->search(["query" => []])); | ||
} | ||
} |