Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds company attached contacts endpoint support #362

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
24 changes: 24 additions & 0 deletions src/IntercomCompanies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/IntercomCompaniesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down