Skip to content

Commit cc02174

Browse files
author
Kevin Antoine
authored
Merge pull request #207 from bviolier/master
Add getAdmin function for IntercomAdmins
2 parents d37974c + e71cd91 commit cc02174

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/IntercomAdmins.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,23 @@ public function getAdmins($options = [])
2828
{
2929
return $this->client->get("admins", $options);
3030
}
31+
32+
/**
33+
* Gets a single Admin based on the Intercom ID.
34+
* @see https://developers.intercom.com/v2.0/reference#view-an-admin
35+
* @param integer $id
36+
* @param array $options
37+
* @return mixed
38+
* @throws \GuzzleHttp\Exception\GuzzleException
39+
*/
40+
public function getAdmin($id, $options = [])
41+
{
42+
$path = $this->adminPath($id);
43+
return $this->client->get($path, $options);
44+
}
45+
46+
public function adminPath($id)
47+
{
48+
return 'admins/' . $id;
49+
}
3150
}

test/IntercomAdminsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,21 @@ public function testAdminsList()
1111
$users = new IntercomAdmins($stub);
1212
$this->assertEquals('foo', $users->getAdmins());
1313
}
14+
15+
public function testAdminsGet()
16+
{
17+
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
18+
$stub->method('get')->willReturn('foo');
19+
20+
$users = new IntercomAdmins($stub);
21+
$this->assertEquals('foo', $users->getAdmin(1));
22+
}
23+
24+
public function testAdminsGetPath()
25+
{
26+
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
27+
28+
$users = new IntercomAdmins($stub);
29+
$this->assertEquals('admins/1', $users->adminPath(1));
30+
}
1431
}

0 commit comments

Comments
 (0)