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

Added params argument for Labels and Search #1008

Open
wants to merge 2 commits into
base: master
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Github/Api/Issue/Labels.php
Expand Up @@ -21,18 +21,19 @@ class Labels extends AbstractApi
* @param string $username
* @param string $repository
* @param int|null $issue
* @param array $params
*
* @return array
*/
public function all($username, $repository, $issue = null)
public function all($username, $repository, $issue = null, array $params = [])
{
if ($issue === null) {
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels';
} else {
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels';
}

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

/**
Expand Down
62 changes: 34 additions & 28 deletions lib/Github/Api/Search.php
Expand Up @@ -18,98 +18,104 @@ class Search extends AbstractApi
*
* @link https://developer.github.com/v3/search/#search-repositories
*
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param array $params
*
* @return array list of repositories found
*/
public function repositories($q, $sort = 'updated', $order = 'desc')
public function repositories($q, $sort = 'updated', $order = 'desc', array $params = [])
{
return $this->get('/search/repositories', ['q' => $q, 'sort' => $sort, 'order' => $order]);
return $this->get('/search/repositories', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params));
}

/**
* Search issues by filter (q).
*
* @link https://developer.github.com/v3/search/#search-issues
*
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param array $params
*
* @return array list of issues found
*/
public function issues($q, $sort = 'updated', $order = 'desc')
public function issues($q, $sort = 'updated', $order = 'desc', array $params = [])
{
return $this->get('/search/issues', ['q' => $q, 'sort' => $sort, 'order' => $order]);
return $this->get('/search/issues', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params));
}

/**
* Search code by filter (q).
*
* @link https://developer.github.com/v3/search/#search-code
*
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param array $params
*
* @return array list of code found
*/
public function code($q, $sort = 'updated', $order = 'desc')
public function code($q, $sort = 'updated', $order = 'desc', array $params = [])
{
return $this->get('/search/code', ['q' => $q, 'sort' => $sort, 'order' => $order]);
return $this->get('/search/code', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params));
}

/**
* Search users by filter (q).
*
* @link https://developer.github.com/v3/search/#search-users
*
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param string $q the filter
* @param string $sort the sort field
* @param string $order asc/desc
* @param array $params
*
* @return array list of users found
*/
public function users($q, $sort = 'updated', $order = 'desc')
public function users($q, $sort = 'updated', $order = 'desc', array $params = [])
{
return $this->get('/search/users', ['q' => $q, 'sort' => $sort, 'order' => $order]);
return $this->get('/search/users', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params));
}

/**
* Search commits by filter (q).
*
* @link https://developer.github.com/v3/search/#search-commits
*
* @param string $q the filter
* @param string $sort the sort field
* @param string $order sort order. asc/desc
* @param string $q the filter
* @param string $sort the sort field
* @param string $order sort order. asc/desc
* @param array $params
*
* @return array
*/
public function commits($q, $sort = null, $order = 'desc')
public function commits($q, $sort = null, $order = 'desc', array $params = [])
{
// This api is in preview mode, so set the correct accept-header
$this->acceptHeaderValue = 'application/vnd.github.cloak-preview';

return $this->get('/search/commits', ['q' => $q, 'sort' => $sort, 'order' => $order]);
return $this->get('/search/commits', array_merge(['q' => $q, 'sort' => $sort, 'order' => $order], $params));
}

/**
* Search topics by filter (q).
*
* @link https://developer.github.com/v3/search/#search-topics
*
* @param string $q the filter
* @param string $q the filter
* @param array $params
*
* @return array
*/
public function topics($q)
public function topics($q, array $params = [])
{
// This api is in preview mode, so set the correct accept-header
$this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json';

return $this->get('/search/topics', ['q' => $q]);
return $this->get('/search/topics', array_merge(['q' => $q], $params));
}
}