Skip to content

Commit

Permalink
Add support for teams (#305)
Browse files Browse the repository at this point in the history
* Add support for teams

* Typo fix
  • Loading branch information
soarecostin authored May 22, 2020
1 parent d1199e9 commit 3392907
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,17 @@ $client->notes->getNotes([
$client->notes->getNote("42");
```

## Teams

```php
/** List teams */
$client->teams->getTeams();

/** Get a single Team by id */
$client->teams->getTeam("1188");
```


## Rate Limits

Rate limit info is passed via the rate limit headers.
Expand Down
6 changes: 6 additions & 0 deletions src/IntercomClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ class IntercomClient
*/
public $notes;

/**
* @var IntercomTeams $teams
*/
public $teams;

/**
* @var array $rateLimitDetails
*/
Expand Down Expand Up @@ -149,6 +154,7 @@ public function __construct(string $appIdOrToken, string $password = null, array
$this->counts = new IntercomCounts($this);
$this->bulk = new IntercomBulk($this);
$this->notes = new IntercomNotes($this);
$this->teams = new IntercomTeams($this);

$this->appIdOrToken = $appIdOrToken;
$this->passwordPart = $password;
Expand Down
48 changes: 48 additions & 0 deletions src/IntercomTeams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Intercom;

use Http\Client\Exception;
use stdClass;

class IntercomTeams extends IntercomResource
{
/**
* Returns list of Teams.
*
* @see https://developers.intercom.io/reference#list-teams
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getTeams($options = [])
{
return $this->client->get("teams", $options);
}

/**
* Gets a single Team based on the Intercom ID.
*
* @see https://developers.intercom.com/reference#view-a-team
* @param integer $id
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getTeam($id, $options = [])
{
$path = $this->teamPath($id);
return $this->client->get($path, $options);
}

/**
* Returns endpoint path to Team with given ID.
*
* @param string $id
* @return string
*/
public function teamPath($id)
{
return 'teams/' . $id;
}
}
30 changes: 30 additions & 0 deletions test/IntercomTeamsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Intercom\Test;

use Intercom\IntercomTeams;

class IntercomTeamsTest extends TestCase
{
public function testTeamsList()
{
$this->client->method('get')->willReturn('foo');

$teams = new IntercomTeams($this->client);
$this->assertSame('foo', $teams->getTeams());
}

public function testTeamsGet()
{
$this->client->method('get')->willReturn('foo');

$teams = new IntercomTeams($this->client);
$this->assertSame('foo', $teams->getTeam(1));
}

public function testTeamsGetPath()
{
$teams = new IntercomTeams($this->client);
$this->assertSame('teams/1', $teams->teamPath(1));
}
}

0 comments on commit 3392907

Please sign in to comment.