Skip to content

Commit fec5a4d

Browse files
committed
Add getAdmin by id to IntercomAdmins
1 parent 9ebffdf commit fec5a4d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/IntercomAdmins.php

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

test/IntercomAdminsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ 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+
}
1423
}

0 commit comments

Comments
 (0)