Skip to content

Commit debf2b3

Browse files
committed
Merge branch 'master' into patch-2
# Conflicts: # lib/Github/Api/Repository/Comments.php
2 parents a45ce63 + 9b66e47 commit debf2b3

39 files changed

+974
-8
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5-
## 2.0.2
5+
## 2.1.0
6+
7+
### Added
8+
9+
- Add support for retrieving a single notification info using his ID
10+
- Add a function to get user organizations
11+
- Added GraphQL support
12+
- Add page variable to organization repo list (Organization::repositories())
13+
- Add support for pull request review.
14+
- Add support for adding branch protection.
615

716
### Fixed
817

918
- Bug with double slashes when using enterprise URL.
19+
- Bug when headers not being passed to request (#529)
1020

1121
## 2.0.0
1222

doc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ APIs:
1212
* [Comments](gists/comments.md)
1313
* [Integrations](integrations.md)
1414
* [Issues](issues.md)
15+
* [Assignees](issue/assignees.md)
1516
* [Comments](issue/comments.md)
1617
* [Labels](issue/labels.md)
18+
* [Milestones](issue/milestones.md)
19+
* Miscellaneous
20+
* [Emojis](miscellaneous/emojis.md)
21+
* [Gitignore](miscellaneous/gitignore.md)
22+
* [Markdown](miscellaneous/markdown.md)
1723
* [Organization](organization.md)
1824
* [Members](organization/members.md)
1925
* [Teams](organization/teams.md)
@@ -42,3 +48,4 @@ Additional features:
4248
* [Request any Route](request_any_route.md)
4349
* [Customize `php-github-api`](customize.md)
4450
* [Running and writing tests](testing.md)
51+
* [Request / Response info](request_response_info.md)

doc/issue/assignees.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Issues / Assignees API
2+
[Back to the "Issues API"](../issues.md) | [Back to the navigation](../README.md)
3+
4+
Wraps [GitHub Issue Assignees API](https://developer.github.com/v3/issues/assignees/).
5+
6+
### List all available assignees
7+
8+
```php
9+
$assignees = $client->api('issue')->assignees()->listAvailable('KnpLabs', 'php-github-api');
10+
```
11+
12+
### Check if a user is an available assignee
13+
14+
```php
15+
$info = $client->api('issue')->assignees()->check('KnpLabs', 'php-github-api', 'test-user);
16+
```
17+
18+
### Add assignee
19+
20+
```php
21+
$client->api('issue')->assignees()->add('KnpLabs', 'php-github-api', 4, ['assignees' => 'test-user]);
22+
```
23+
24+
### Remove assignee
25+
26+
```php
27+
$client->api('issue')->assignees()->remove('KnpLabs', 'php-github-api', 4, ['assignees' => 'test-user]);
28+
```

doc/issue/labels.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ $labels = $client->api('issue')->labels()->all('KnpLabs', 'php-github-api');
1212
List all project labels by username and repo.
1313
Returns an array of project labels.
1414

15+
### Get a single label
16+
17+
```php
18+
$label = $client->api('issue')->labels()->all('KnpLabs', 'php-github-api', 'label1');
19+
```
20+
1521
### Create a label
1622

1723
```php

doc/issues.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,15 @@ $client->api('issue')->all('KnpLabs', 'php-github-api', array('labels' => 'label
8484
```
8585

8686
Returns an array of issues matching the given label.
87+
88+
### Lock an issue discussion
89+
90+
```php
91+
$client->api('issue')->lock('KnpLabs', 'php-github-api', 4);
92+
```
93+
94+
### Unlock an issue discussion
95+
96+
```php
97+
$client->api('issue')->unlock('KnpLabs', 'php-github-api', 4);
98+
```

doc/miscellaneous/emojis.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Emojis API
2+
[Back to the navigation](../README.md)
3+
4+
### Lists all available emojis on GitHub.
5+
6+
```php
7+
$emojis = $client->api('emojis')->all();
8+
```

doc/miscellaneous/gitignore.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Gitignore API
2+
[Back to the navigation](../README.md)
3+
4+
### Lists all available gitignore templates
5+
6+
```php
7+
$gitignoreTemplates = $client->api('gitignore')->all();
8+
```
9+
10+
### Get a single template
11+
12+
```php
13+
$gitignore = $client->api('gitignore')->show('C');
14+
```

doc/miscellaneous/markdown.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Markdown API
2+
[Back to the navigation](../README.md)
3+
4+
### Render an arbitrary Markdown document
5+
6+
```php
7+
$gitignoreTemplates = $client->api('markdown')->render('Hello world github/linguist#1 **cool**, and #1!', 'markdown');
8+
```
9+
10+
### Render a Markdown document in raw mode
11+
12+
```php
13+
$gitignore = $client->api('markdown')->renderRaw('path/to/file');
14+
```

doc/pull_request/review_request.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Pull Requests / Review Requests API
2+
[Back to the "Pull Requests API"](../pull_requests.md) | [Back to the navigation](../README.md)
3+
4+
The Pull Request Review API is currently available for developers to preview.
5+
To access the API during the preview period, you must provide a custom media type in the Accept header:
6+
7+
```php
8+
$client->api('pull_request')->reviewRequests()->configure();
9+
```
10+
11+
### List all review requests
12+
13+
```php
14+
$reviewRequests = $client->api('pull_request')->reviewRequests()->all('twbs', 'bootstrap', 12);
15+
```
16+
17+
### Create a review request
18+
19+
```php
20+
$client->api('pull_request')->reviewRequests()->create('twbs', 'bootstrap', 12, array('user1', 'user2'));
21+
```
22+
23+
### Remove a review request
24+
25+
```php
26+
$client->api('pull_request')->reviewRequests()->remove('twbs', 'bootstrap', 12, array('user1', 'user2'));
27+
```

doc/request_response_info.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Request / Response information
2+
[Back to the navigation](README.md)
3+
4+
### Get response headers
5+
6+
Get the repsonse header for the latest request
7+
8+
```
9+
$headers = $githubClient->getLastResponse()->getHeaders();
10+
//Example headers
11+
$headers['X-RateLimit-Remaining'];
12+
$headers['X-OAuth-Scopes'];
13+
$headers['X-Accepted-OAuth-Scopes'];
14+
```

lib/Github/Api/CurrentUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function teams()
112112
*
113113
* @param string $type role in the repository
114114
* @param string $sort sort by
115-
* @param string $direction direction of sort, ask or desc
115+
* @param string $direction direction of sort, asc or desc
116116
*
117117
* @return array
118118
*/

lib/Github/Api/GitData/Blobs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ class Blobs extends AbstractApi
1919
* Configure the Accept header depending on the blob type.
2020
*
2121
* @param string|null $bodyType
22+
*
23+
* @return self
2224
*/
2325
public function configure($bodyType = null)
2426
{
2527
if ('raw' === $bodyType) {
2628
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.raw', $this->client->getApiVersion());
2729
}
30+
31+
return $this;
2832
}
2933

3034
/**

lib/Github/Api/Issue.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Github\Api;
44

5+
use Github\Api\Issue\Assignees;
56
use Github\Api\Issue\Comments;
67
use Github\Api\Issue\Events;
78
use Github\Api\Issue\Labels;
@@ -149,6 +150,38 @@ public function update($username, $repository, $id, array $params)
149150
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id), $params);
150151
}
151152

153+
/**
154+
* Lock an issue. Users with push access can lock an issue's conversation.
155+
*
156+
* @link https://developer.github.com/v3/issues/#lock-an-issue
157+
*
158+
* @param string $username
159+
* @param string $repository
160+
* @param string $id
161+
*
162+
* @return string
163+
*/
164+
public function lock($username, $repository, $id)
165+
{
166+
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id).'/lock');
167+
}
168+
169+
/**
170+
* Unlock an issue. Users with push access can unlock an issue's conversation.
171+
*
172+
* @link https://developer.github.com/v3/issues/#lock-an-issue
173+
*
174+
* @param string $username
175+
* @param string $repository
176+
* @param string $id
177+
*
178+
* @return string
179+
*/
180+
public function unlock($username, $repository, $id)
181+
{
182+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id).'/lock');
183+
}
184+
152185
/**
153186
* List an issue comments.
154187
*
@@ -196,4 +229,16 @@ public function milestones()
196229
{
197230
return new Milestones($this->client);
198231
}
232+
233+
/**
234+
* List all assignees.
235+
*
236+
* @link https://developer.github.com/v3/issues/assignees/
237+
*
238+
* @return Assignees
239+
*/
240+
public function assignees()
241+
{
242+
return new Assignees($this->client);
243+
}
199244
}

lib/Github/Api/Issue/Assignees.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace Github\Api\Issue;
4+
5+
use Github\Api\AbstractApi;
6+
use Github\Exception\MissingArgumentException;
7+
8+
class Assignees extends AbstractApi
9+
{
10+
/**
11+
* List all the available assignees to which issues may be assigned.
12+
*
13+
* @param string $username
14+
* @param string $repository
15+
* @param array $parameters
16+
*
17+
* @return array
18+
*/
19+
public function listAvailable($username, $repository, array $parameters = array())
20+
{
21+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees', $parameters);
22+
}
23+
24+
/**
25+
* Check to see if a particular user is an assignee for a repository.
26+
*
27+
* @link https://developer.github.com/v3/issues/assignees/#check-assignee
28+
*
29+
* @param string $username
30+
* @param string $repository
31+
* @param string $assignee
32+
*
33+
* @return array
34+
*/
35+
public function check($username, $repository, $assignee)
36+
{
37+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees/' . rawurlencode($assignee));
38+
}
39+
40+
/**
41+
* Add assignees to an Issue
42+
*
43+
* @link https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue
44+
*
45+
* @param string $username
46+
* @param string $repository
47+
* @param string $issue
48+
* @param array $parameters
49+
*
50+
* @return string
51+
* @throws MissingArgumentException
52+
*/
53+
public function add($username, $repository, $issue, array $parameters)
54+
{
55+
if (!isset($parameters['assignees'])) {
56+
throw new MissingArgumentException('assignees');
57+
}
58+
59+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/assignees', $parameters);
60+
}
61+
62+
/**
63+
* Remove assignees from an Issue
64+
*
65+
* @link https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
66+
*
67+
* @param string $username
68+
* @param string $repository
69+
* @param string $issue
70+
* @param array $parameters
71+
*
72+
* @return string
73+
* @throws MissingArgumentException
74+
*/
75+
public function remove($username, $repository, $issue, array $parameters)
76+
{
77+
if (!isset($parameters['assignees'])) {
78+
throw new MissingArgumentException('assignees');
79+
}
80+
81+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/assignees', $parameters);
82+
}
83+
}

lib/Github/Api/Issue/Comments.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class Comments extends AbstractApi
2020
*
2121
* @link https://developer.github.com/v3/issues/comments/#custom-media-types
2222
* @param string|null $bodyType
23+
*
24+
* @return self
2325
*/
2426
public function configure($bodyType = null)
2527
{
@@ -28,6 +30,8 @@ public function configure($bodyType = null)
2830
}
2931

3032
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->client->getApiVersion(), $bodyType);
33+
34+
return $this;
3135
}
3236

3337
/**

lib/Github/Api/Issue/Labels.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ public function all($username, $repository, $issue = null)
3333
return $this->get($path);
3434
}
3535

36+
/**
37+
* Get a single label.
38+
*
39+
* @link https://developer.github.com/v3/issues/labels/#get-a-single-label
40+
*
41+
* @param string $username
42+
* @param string $repository
43+
* @param string $label
44+
*
45+
* @return array
46+
*/
47+
public function show($username, $repository, $label)
48+
{
49+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label));
50+
}
51+
3652
/**
3753
* Create a label for a repository.
3854
*

0 commit comments

Comments
 (0)