diff --git a/README.md b/README.md index b7b1cb5..6d5cb6f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/IntercomClient.php b/src/IntercomClient.php index 253f21c..dadf9b9 100644 --- a/src/IntercomClient.php +++ b/src/IntercomClient.php @@ -121,6 +121,11 @@ class IntercomClient */ public $notes; + /** + * @var IntercomTeams $teams + */ + public $teams; + /** * @var array $rateLimitDetails */ @@ -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; diff --git a/src/IntercomTeams.php b/src/IntercomTeams.php new file mode 100644 index 0000000..b2a344b --- /dev/null +++ b/src/IntercomTeams.php @@ -0,0 +1,48 @@ +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; + } +} diff --git a/test/IntercomTeamsTest.php b/test/IntercomTeamsTest.php new file mode 100644 index 0000000..2385cb9 --- /dev/null +++ b/test/IntercomTeamsTest.php @@ -0,0 +1,30 @@ +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)); + } +}