diff --git a/README.md b/README.md index 3fd8ad3..e463377 100644 --- a/README.md +++ b/README.md @@ -392,6 +392,9 @@ $client->companies->getCompany('531ee472cce572a6ec000006'); /** List users belonging to a company by ID */ $client->companies->getCompanyUsers('531ee472cce572a6ec000006'); +/** List attached contacts belonging to a company by ID */ +$client->companies->getCompanyContacts('531ee472cce572a6ec000006'); + /** List users belonging to a company by company_id */ $client->companies->getCompanies([ 'company_id' => '3', diff --git a/src/IntercomCompanies.php b/src/IntercomCompanies.php index e3256ad..897fbe6 100644 --- a/src/IntercomCompanies.php +++ b/src/IntercomCompanies.php @@ -110,6 +110,21 @@ public function getCompanyUsers($id, $options = []) return $this->client->get($path, $options); } + /** + * Returns a list of contacts belonging to a single Company based on the Intercom ID. + * + * @see https://developers.intercom.com/intercom-api-reference/reference/listattachedcontacts + * @param string $id + * @param array $options + * @return stdClass + * @throws Exception + */ + public function getCompanyContacts($id, $options = []) + { + $path = $this->companyContactsPath($id); + return $this->client->get($path, $options); + } + /** * @param string $id * @return string @@ -128,6 +143,15 @@ public function companyUsersPath($id) return 'companies/' . $id . '/users'; } + /** + * @param string $id + * @return string + */ + public function companyContactsPath($id) + { + return 'companies/' . $id . '/contacts'; + } + /** * @param string $contactId * @return string diff --git a/tests/IntercomCompaniesTest.php b/tests/IntercomCompaniesTest.php index 7c3bd1d..322bf4f 100644 --- a/tests/IntercomCompaniesTest.php +++ b/tests/IntercomCompaniesTest.php @@ -52,6 +52,14 @@ public function testCompanyGetUsers() $this->assertSame('foo', $companies->getCompanyUsers("foo")); } + public function testCompanyGetContacts() + { + $this->client->method('get')->willReturn('foo'); + + $companies = new IntercomCompanies($this->client); + $this->assertSame('foo', $companies->getCompanyContacts("foo")); + } + public function testCompanyUsersPath() { $users = new IntercomCompanies($this->client);