Skip to content

Commit a9959cf

Browse files
authored
Merge pull request #243 from asknicely/get-single-company
Get a single company by ID
2 parents c8cd326 + 2215f1b commit a9959cf

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ $client->companies->update([
270270

271271
/** List Companies */
272272
$client->companies->getCompanies([]);
273+
274+
/** Get a company by ID */
275+
$client->companies->getCompany("531ee472cce572a6ec000006");
273276
```
274277

275278
## Admins

src/IntercomCompanies.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,28 @@ public function getCompanies($options)
5858
{
5959
return $this->client->get("companies", $options);
6060
}
61+
62+
/**
63+
* Gets a single Company based on the Intercom ID.
64+
*
65+
* @see https://developers.intercom.com/reference#view-a-company
66+
* @param string $id
67+
* @param array $options
68+
* @return mixed
69+
* @throws \GuzzleHttp\Exception\GuzzleException
70+
*/
71+
public function getCompany($id, $options = [])
72+
{
73+
$path = $this->companyPath($id);
74+
return $this->client->get($path, $options);
75+
}
76+
77+
/**
78+
* @param string $id
79+
* @return string
80+
*/
81+
public function companyPath($id)
82+
{
83+
return 'companies/' . $id;
84+
}
6185
}

test/IntercomCompaniesTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,20 @@ public function testCompanyGet()
3636
$companies = new IntercomCompanies($stub);
3737
$this->assertEquals('foo', $companies->getCompanies([]));
3838
}
39+
40+
public function testCompanyPath()
41+
{
42+
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
43+
$users = new IntercomCompanies($stub);
44+
$this->assertEquals('companies/foo', $users->companyPath("foo"));
45+
}
46+
47+
public function testCompanyGetById()
48+
{
49+
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
50+
$stub->method('get')->willReturn('foo');
51+
52+
$users = new IntercomCompanies($stub);
53+
$this->assertEquals('foo', $users->getCompany("foo"));
54+
}
3955
}

0 commit comments

Comments
 (0)