diff --git a/README.md b/README.md index e5b14ab..43790d2 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ * [Team](#team) * [List an organization's teams](#list-an-organizations-teams) * [Create a New Team](#create-a-new-team) + * [Show a Team](#show-a-team) * [Edit a Team](#edit-a-team) * [Delete a Team](#delete-a-team) * [Add Member to Team (by User ID)](#add-member-to-team-by-user-id) @@ -113,7 +114,7 @@ * [Validate incoming webhook payloads](#validate-incoming-webhook-payloads) * [License](#license) - + @@ -214,6 +215,14 @@ $team = $client->teams()->create('New Team Name', $permissions); ``` Creates a team and sets permissions applied to team members. Returns the newly-created team. +#### Show a Team +```php + +$team = $client->teams()->show($teamId); +``` +Returns the team including all its members. + + #### Edit a Team ```php use PrivatePackagist\ApiClient\TeamPermissions; diff --git a/src/Api/Teams.php b/src/Api/Teams.php index 9ded3c3..815f9ff 100644 --- a/src/Api/Teams.php +++ b/src/Api/Teams.php @@ -34,6 +34,11 @@ public function create(string $name, TeamPermissions $permissions): array return $this->post('/teams/', $parameters); } + public function show($teamId) + { + return $this->get(sprintf('/teams/%s/', $teamId)); + } + public function edit($teamId, string $name, TeamPermissions $permissions): array { $parameters = [ diff --git a/tests/Api/TeamsTest.php b/tests/Api/TeamsTest.php index 59c7421..2145dc3 100644 --- a/tests/Api/TeamsTest.php +++ b/tests/Api/TeamsTest.php @@ -130,6 +130,33 @@ public function testCreateTeam(): void $this->assertSame($expected, $api->create('New Team', $permissions)); } + public function testShowTeam(): void + { + $expected = [ + 'id' => 1, + 'name' => 'New Team', + 'permissions' => [ + 'canEditTeamPackages' => true, + 'canAddPackages' => false, + 'canCreateSubrepositories' => false, + 'canViewVendorCustomers' => true, + 'canManageVendorCustomers' => false, + ], + ]; + + /** @var Teams&MockObject $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/teams/123/')) + ->willReturn($expected); + + $permissions = new TeamPermissions; + $permissions->canEditTeamPackages = true; + $permissions->canViewVendorCustomers = true; + $this->assertSame($expected, $api->show(123)); + } + public function testEditTeam(): void { $expected = [