Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the new "List workspace pull requests for a user" endpoint #90

Open
wants to merge 1 commit into
base: 4.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Api/PullRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class PullRequests extends AbstractApi
*
* @throws \Http\Client\Exception
*
* @deprecated use the workspaces pull requests instead
*
* @return array
*/
public function list(string $username, array $params = [])
Expand Down
9 changes: 9 additions & 0 deletions src/Api/Workspaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Bitbucket\Api\Workspaces\Permissions;
use Bitbucket\Api\Workspaces\PipelinesConfig;
use Bitbucket\Api\Workspaces\Projects;
use Bitbucket\Api\Workspaces\PullRequests as WorkspacesPullRequests;
use Bitbucket\Client;
use Bitbucket\HttpClient\Util\UriBuilder;

Expand Down Expand Up @@ -117,6 +118,14 @@ public function projects()
return new Projects($this->getClient(), $this->workspace);
}

/**
* @return \Bitbucket\Api\Workspaces\PullRequests
*/
public function pullRequests()
{
return new WorkspacesPullRequests($this->getClient(), $this->workspace);
}

/**
* Build the workspaces URI from the given parts.
*
Expand Down
51 changes: 51 additions & 0 deletions src/Api/Workspaces/PullRequests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Bitbucket API Client.
*
* (c) Graham Campbell <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Bitbucket\Api\Workspaces;

use Bitbucket\HttpClient\Util\UriBuilder;

/**
* The pull requests API class.
*
* @author Graham Campbell <[email protected]>
*/
class PullRequests extends AbstractWorkspacesApi
{
/**
* @param string $username
* @param array $params
*
* @throws \Http\Client\Exception
*
* @return array
*/
public function list(string $username, array $params = [])
{
$uri = $this->buildPullRequestsUri($username);

return $this->get($uri, $params);
}

/**
* Build the projects URI from the given parts.
*
* @param string ...$parts
*
* @return string
*/
protected function buildPullRequestsUri(string ...$parts)
{
return UriBuilder::build('workspaces', $this->workspace, 'pullrequests', ...$parts);
}
}