Skip to content

Commit 3392907

Browse files
authored
Add support for teams (#305)
* Add support for teams * Typo fix
1 parent d1199e9 commit 3392907

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ $client->notes->getNotes([
423423
$client->notes->getNote("42");
424424
```
425425

426+
## Teams
427+
428+
```php
429+
/** List teams */
430+
$client->teams->getTeams();
431+
432+
/** Get a single Team by id */
433+
$client->teams->getTeam("1188");
434+
```
435+
436+
426437
## Rate Limits
427438

428439
Rate limit info is passed via the rate limit headers.

src/IntercomClient.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ class IntercomClient
121121
*/
122122
public $notes;
123123

124+
/**
125+
* @var IntercomTeams $teams
126+
*/
127+
public $teams;
128+
124129
/**
125130
* @var array $rateLimitDetails
126131
*/
@@ -149,6 +154,7 @@ public function __construct(string $appIdOrToken, string $password = null, array
149154
$this->counts = new IntercomCounts($this);
150155
$this->bulk = new IntercomBulk($this);
151156
$this->notes = new IntercomNotes($this);
157+
$this->teams = new IntercomTeams($this);
152158

153159
$this->appIdOrToken = $appIdOrToken;
154160
$this->passwordPart = $password;

src/IntercomTeams.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Intercom;
4+
5+
use Http\Client\Exception;
6+
use stdClass;
7+
8+
class IntercomTeams extends IntercomResource
9+
{
10+
/**
11+
* Returns list of Teams.
12+
*
13+
* @see https://developers.intercom.io/reference#list-teams
14+
* @param array $options
15+
* @return stdClass
16+
* @throws Exception
17+
*/
18+
public function getTeams($options = [])
19+
{
20+
return $this->client->get("teams", $options);
21+
}
22+
23+
/**
24+
* Gets a single Team based on the Intercom ID.
25+
*
26+
* @see https://developers.intercom.com/reference#view-a-team
27+
* @param integer $id
28+
* @param array $options
29+
* @return stdClass
30+
* @throws Exception
31+
*/
32+
public function getTeam($id, $options = [])
33+
{
34+
$path = $this->teamPath($id);
35+
return $this->client->get($path, $options);
36+
}
37+
38+
/**
39+
* Returns endpoint path to Team with given ID.
40+
*
41+
* @param string $id
42+
* @return string
43+
*/
44+
public function teamPath($id)
45+
{
46+
return 'teams/' . $id;
47+
}
48+
}

test/IntercomTeamsTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Intercom\Test;
4+
5+
use Intercom\IntercomTeams;
6+
7+
class IntercomTeamsTest extends TestCase
8+
{
9+
public function testTeamsList()
10+
{
11+
$this->client->method('get')->willReturn('foo');
12+
13+
$teams = new IntercomTeams($this->client);
14+
$this->assertSame('foo', $teams->getTeams());
15+
}
16+
17+
public function testTeamsGet()
18+
{
19+
$this->client->method('get')->willReturn('foo');
20+
21+
$teams = new IntercomTeams($this->client);
22+
$this->assertSame('foo', $teams->getTeam(1));
23+
}
24+
25+
public function testTeamsGetPath()
26+
{
27+
$teams = new IntercomTeams($this->client);
28+
$this->assertSame('teams/1', $teams->teamPath(1));
29+
}
30+
}

0 commit comments

Comments
 (0)