From 089dc658f0f6633b4b72283d87865539b3cae5ff Mon Sep 17 00:00:00 2001 From: Abdelilah Date: Sat, 12 Aug 2023 03:03:54 +0100 Subject: [PATCH 1/4] adds company attached contacts path --- src/IntercomCompanies.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/IntercomCompanies.php b/src/IntercomCompanies.php index e3256ad9..cf76aeb1 100644 --- a/src/IntercomCompanies.php +++ b/src/IntercomCompanies.php @@ -128,6 +128,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 From e3951d53ee37972586121063ce7ae2b5fe9879a5 Mon Sep 17 00:00:00 2001 From: Abdelilah Date: Sat, 12 Aug 2023 03:05:02 +0100 Subject: [PATCH 2/4] adds company contacts method --- src/IntercomCompanies.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/IntercomCompanies.php b/src/IntercomCompanies.php index cf76aeb1..897fbe6e 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 From 294bce597c31392933344a7969425972db2fef86 Mon Sep 17 00:00:00 2001 From: Abdelilah Date: Sat, 12 Aug 2023 03:05:29 +0100 Subject: [PATCH 3/4] adds tests --- tests/IntercomCompaniesTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/IntercomCompaniesTest.php b/tests/IntercomCompaniesTest.php index 7c3bd1d9..322bf4f2 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); From f806cfa8e87213183d274f345ad99305b3feb584 Mon Sep 17 00:00:00 2001 From: Abdelilah Date: Sat, 12 Aug 2023 03:06:24 +0100 Subject: [PATCH 4/4] lists the function in the readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3fd8ad38..e4633776 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',