Skip to content

Commit

Permalink
Merge pull request #57 from packagist/team-show
Browse files Browse the repository at this point in the history
Teams: add endpoints to fetch a single team
  • Loading branch information
glaubinix authored Jan 24, 2023
2 parents c382497 + e3cef3e commit 7c01112
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -113,7 +114,7 @@
* [Validate incoming webhook payloads](#validate-incoming-webhook-payloads)
* [License](#license)

<!-- Added by: zanbaldwin, at: Fri 16 Sep 09:48:23 CEST 2022 -->
<!-- Added by: glaubinix, at: Tue 24 Jan 2023 14:03:21 GMT -->

<!--te-->

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/Api/Teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
27 changes: 27 additions & 0 deletions tests/Api/TeamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 7c01112

Please sign in to comment.