Skip to content

Commit 8271a82

Browse files
committed
merge
2 parents 2d72db0 + ddca58d commit 8271a82

File tree

17 files changed

+812
-19
lines changed

17 files changed

+812
-19
lines changed

doc/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ APIs:
2020
* [Repositories](repos.md)
2121
* [Contents](repo/contents.md)
2222
* [Deployments](repo/deployments.md)
23+
* [Projects](repo/projects.md)
24+
* [Columns](repo/columns.md)
25+
* [Cards](repo/cards.md)
2326
* [Releases](repo/releases.md)
2427
* [Assets](repo/assets.md)
2528
* [Stargazers](repo/stargazers.md)

doc/issue/comments.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $comments = $client->api('issue')->comments()->all('KnpLabs', 'php-github-api',
1111

1212
* `KnpLabs` : the owner of the repository
1313
* `php-github-api` : the name of the repository
14-
* `4` : the id of the issue
14+
* `4` : the issue number
1515
* You can select another page of comments using one more parameter (default: 1)
1616

1717
Returns an array of comments.
@@ -41,7 +41,7 @@ $client->api('issue')->comments()->create('KnpLabs', 'php-github-api', 4, array(
4141

4242
* `KnpLabs` : the owner of the repository
4343
* `php-github-api` : the name of the repository
44-
* `4` : the id of the issue
44+
* `4` : the issue number
4545
* You can set a `body` and optionally a `title`
4646

4747

doc/repo/cards.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Repo / Cards API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
This api is currently only available to developers in Early Access. To access the API during the Early Access period,
5+
you must provide a custom media type in the Accept header.
6+
7+
```php
8+
$client->api('repo')->projects()->columns()->cards()->configure();
9+
```
10+
11+
### List all cards of a column
12+
13+
```php
14+
$cards = $client->api('repo')->projects()->columns()->cards()->all('twbs', 'bootstrap', $columnId);
15+
```
16+
17+
### List one card
18+
19+
```php
20+
$card = $client->api('repo')->projects()->columns()->cards()->show('twbs', 'bootstrap', $cardId);
21+
```
22+
23+
### Create a card
24+
25+
> Requires [authentication](../security.md).
26+
27+
```php
28+
$card = $client->api('repo')->projects()->columns()->cards()->create('twbs', 'bootstrap', $columnId, array('content_type' => 'Issue', 'content_id' => '452'));
29+
```
30+
31+
### Edit a card
32+
33+
> Requires [authentication](../security.md).
34+
35+
```php
36+
$card = $client->api('repo')->project()->columns()->cards()->update('twbs', 'bootstrap', $cardId, array('note' => 'card note'));
37+
```
38+
39+
### Remove a card
40+
41+
> Requires [authentication](../security.md).
42+
43+
```php
44+
$card = $client->api('repo')->projects()->columns()->cards()->deleteCard('twbs', 'bootstrap', $cardId);
45+
```
46+
47+
### Move a card
48+
49+
> Requires [authentication](../security.md).
50+
51+
```php
52+
$card = $client->api('repo')->projects()->columns()->cards()->move('twbs', 'bootstrap', $cardId, array('position' => 'top));
53+
```

doc/repo/columns.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Repo / Columns API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
This api is currently only available to developers in Early Access. To access the API during the Early Access period,
5+
you must provide a custom media type in the Accept header.
6+
7+
```php
8+
$client->api('repo')->projects()->columns()->configure();
9+
```
10+
11+
### List all columns of a project
12+
13+
```php
14+
$columns = $client->api('repo')->projects()->columns()->all('twbs', 'bootstrap', $projectId);
15+
```
16+
17+
### List one column
18+
19+
```php
20+
$column = $client->api('repo')->projects()->columns()->show('twbs', 'bootstrap', $columnId);
21+
```
22+
23+
### Create a column
24+
25+
> Requires [authentication](../security.md).
26+
27+
```php
28+
$column = $client->api('repo')->projects()->columns()->create('twbs', 'bootstrap', $projectId, array('name' => 'Column name'));
29+
```
30+
31+
### Edit a column
32+
33+
> Requires [authentication](../security.md).
34+
35+
```php
36+
$column = $client->api('repo')->project()->columns()->update('twbs', 'bootstrap', $columnId, array('name' => 'New name'));
37+
```
38+
39+
### Remove a column
40+
41+
> Requires [authentication](../security.md).
42+
43+
```php
44+
$column = $client->api('repo')->projects()->columns()->deleteColumn('twbs', 'bootstrap', $columnId);
45+
```
46+
47+
### Move a column
48+
49+
> Requires [authentication](../security.md).
50+
51+
```php
52+
$column = $client->api('repo')->projects()->columns()->move('twbs', 'bootstrap', $columnId, array('position' => 'first));
53+
```

doc/repo/projects.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Repo / Projects API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
This api is currently only available to developers in Early Access. To access the API during the Early Access period,
5+
you must provide a custom media type in the Accept header.
6+
7+
```php
8+
$client->api('repo')->projects()->configure();
9+
```
10+
11+
### List all projects
12+
13+
```php
14+
$projects = $client->api('repo')->projects()->all('twbs', 'bootstrap');
15+
```
16+
17+
### List one project
18+
19+
```php
20+
$project = $client->api('repo')->projects()->show('twbs', 'bootstrap', $projectId);
21+
```
22+
23+
### Create a project
24+
25+
> Requires [authentication](../security.md).
26+
27+
```php
28+
$project = $client->api('repo')->projects()->create('twbs', 'bootstrap', array('name' => 'Project name'));
29+
```
30+
31+
### Edit a project
32+
33+
> Requires [authentication](../security.md).
34+
35+
```php
36+
$project = $client->api('repo')->project()->update('twbs', 'bootstrap', $projectId, array('name' => 'New name'));
37+
```
38+
39+
### Remove a project
40+
41+
> Requires [authentication](../security.md).
42+
43+
```php
44+
$project = $client->api('repo')->projects()->deleteProject('twbs', 'bootstrap', $projectId);
45+
```

lib/Github/Api/AbstractApi.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function setPerPage($perPage)
6565
*
6666
* @return array|string
6767
*/
68-
protected function get($path, array $parameters = array(), $requestHeaders = array())
68+
protected function get($path, array $parameters = array(), array $requestHeaders = array())
6969
{
7070
if (null !== $this->perPage && !isset($parameters['per_page'])) {
7171
$parameters['per_page'] = $this->perPage;
@@ -92,7 +92,7 @@ protected function get($path, array $parameters = array(), $requestHeaders = arr
9292
*
9393
* @return \Psr\Http\Message\ResponseInterface
9494
*/
95-
protected function head($path, array $parameters = array(), $requestHeaders = array())
95+
protected function head($path, array $parameters = array(), array $requestHeaders = array())
9696
{
9797
if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) {
9898
unset($parameters['ref']);
@@ -109,8 +109,10 @@ protected function head($path, array $parameters = array(), $requestHeaders = ar
109109
* @param string $path Request path.
110110
* @param array $parameters POST parameters to be JSON encoded.
111111
* @param array $requestHeaders Request headers.
112+
*
113+
* @return array|string
112114
*/
113-
protected function post($path, array $parameters = array(), $requestHeaders = array())
115+
protected function post($path, array $parameters = array(), array $requestHeaders = array())
114116
{
115117
return $this->postRaw(
116118
$path,
@@ -128,7 +130,7 @@ protected function post($path, array $parameters = array(), $requestHeaders = ar
128130
*
129131
* @return array|string
130132
*/
131-
protected function postRaw($path, $body, $requestHeaders = array())
133+
protected function postRaw($path, $body, array $requestHeaders = array())
132134
{
133135
$response = $this->client->getHttpClient()->post(
134136
$path,
@@ -145,8 +147,10 @@ protected function postRaw($path, $body, $requestHeaders = array())
145147
* @param string $path Request path.
146148
* @param array $parameters POST parameters to be JSON encoded.
147149
* @param array $requestHeaders Request headers.
150+
*
151+
* @return array|string
148152
*/
149-
protected function patch($path, array $parameters = array(), $requestHeaders = array())
153+
protected function patch($path, array $parameters = array(), array $requestHeaders = array())
150154
{
151155
$response = $this->client->getHttpClient()->patch(
152156
$path,
@@ -163,8 +167,10 @@ protected function patch($path, array $parameters = array(), $requestHeaders = a
163167
* @param string $path Request path.
164168
* @param array $parameters POST parameters to be JSON encoded.
165169
* @param array $requestHeaders Request headers.
170+
*
171+
* @return array|string
166172
*/
167-
protected function put($path, array $parameters = array(), $requestHeaders = array())
173+
protected function put($path, array $parameters = array(), array $requestHeaders = array())
168174
{
169175
$response = $this->client->getHttpClient()->put(
170176
$path,
@@ -181,8 +187,10 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr
181187
* @param string $path Request path.
182188
* @param array $parameters POST parameters to be JSON encoded.
183189
* @param array $requestHeaders Request headers.
190+
*
191+
* @return array|string
184192
*/
185-
protected function delete($path, array $parameters = array(), $requestHeaders = array())
193+
protected function delete($path, array $parameters = array(), array $requestHeaders = array())
186194
{
187195
$response = $this->client->getHttpClient()->delete(
188196
$path,

lib/Github/Api/AcceptHeaderTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@ trait AcceptHeaderTrait
1111
{
1212
protected $acceptHeaderValue = null;
1313

14-
protected function get($path, array $parameters = array(), $requestHeaders = array())
14+
protected function get($path, array $parameters = array(), array $requestHeaders = array())
1515
{
1616
return parent::get($path, $parameters, $this->mergeHeaders($requestHeaders));
1717
}
1818

19-
protected function head($path, array $parameters = array(), $requestHeaders = array())
19+
protected function head($path, array $parameters = array(), array $requestHeaders = array())
2020
{
2121
return parent::head($path, $parameters, $this->mergeHeaders($requestHeaders));
2222
}
2323

24-
protected function post($path, array $parameters = array(), $requestHeaders = array())
24+
protected function post($path, array $parameters = array(), array $requestHeaders = array())
2525
{
2626
return parent::post($path, $parameters, $this->mergeHeaders($requestHeaders));
2727
}
2828

29-
protected function postRaw($path, $body, $requestHeaders = array())
29+
protected function postRaw($path, $body, array $requestHeaders = array())
3030
{
3131
return parent::postRaw($path, $body, $this->mergeHeaders($requestHeaders));
3232
}
3333

34-
protected function patch($path, array $parameters = array(), $requestHeaders = array())
34+
protected function patch($path, array $parameters = array(), array $requestHeaders = array())
3535
{
3636
return parent::patch($path, $parameters, $this->mergeHeaders($requestHeaders));
3737
}
3838

39-
protected function put($path, array $parameters = array(), $requestHeaders = array())
39+
protected function put($path, array $parameters = array(), array $requestHeaders = array())
4040
{
4141
return parent::put($path, $parameters, $this->mergeHeaders($requestHeaders));
4242
}
4343

44-
protected function delete($path, array $parameters = array(), $requestHeaders = array())
44+
protected function delete($path, array $parameters = array(), array $requestHeaders = array())
4545
{
4646
return parent::delete($path, $parameters, $this->mergeHeaders($requestHeaders));
4747
}

lib/Github/Api/Repo.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Github\Api\Repository\Contents;
99
use Github\Api\Repository\DeployKeys;
1010
use Github\Api\Repository\Downloads;
11+
use Github\Api\Repository\Projects;
1112
use Github\Api\Repository\Releases;
1213
use Github\Api\Repository\Forks;
1314
use Github\Api\Repository\Hooks;
@@ -88,6 +89,36 @@ public function statistics($username, $repository)
8889
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/contributors');
8990
}
9091

92+
/**
93+
* Get a weekly aggregate of the number of additions and deletions pushed to a repository.
94+
*
95+
* @link http://developer.github.com/v3/repos/statistics/#code-frequency
96+
*
97+
* @param string $username the user who owns the repository
98+
* @param string $repository the name of the repository
99+
*
100+
* @return array list of weeks and their commit statistics
101+
*/
102+
public function frequency($username, $repository)
103+
{
104+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/code_frequency');
105+
}
106+
107+
/**
108+
* Get the weekly commit count for the repository owner and everyone else.
109+
*
110+
* @link http://developer.github.com/v3/repos/statistics/#participation
111+
*
112+
* @param string $username the user who owns the repository
113+
* @param string $repository the name of the repository
114+
*
115+
* @return array list of weekly commit count grouped by 'all' and 'owner'
116+
*/
117+
public function participation($username, $repository)
118+
{
119+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/participation');
120+
}
121+
91122
/**
92123
* List all repositories for an organization.
93124
*
@@ -510,4 +541,9 @@ public function milestones($username, $repository)
510541
{
511542
return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/milestones');
512543
}
544+
545+
public function projects()
546+
{
547+
return new Projects($this->client);
548+
}
513549
}

0 commit comments

Comments
 (0)