Skip to content

Commit 6b2d292

Browse files
authored
Merge pull request KnpLabs#449 from acrobat/api-projects
Added support for the projects api
2 parents 862c23d + 55a6a78 commit 6b2d292

File tree

11 files changed

+755
-0
lines changed

11 files changed

+755
-0
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/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/Repo.php

Lines changed: 6 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;
@@ -510,4 +511,9 @@ public function milestones($username, $repository)
510511
{
511512
return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/milestones');
512513
}
514+
515+
public function projects()
516+
{
517+
return new Projects($this->client);
518+
}
513519
}

lib/Github/Api/Repository/Cards.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Github\Api\Repository;
4+
5+
use Github\Api\AbstractApi;
6+
use Github\Api\AcceptHeaderTrait;
7+
use Github\Exception\MissingArgumentException;
8+
9+
class Cards extends AbstractApi
10+
{
11+
use AcceptHeaderTrait;
12+
13+
/**
14+
* Configure the accept header for Early Access to the projects api
15+
*
16+
* @see https://developer.github.com/v3/repos/projects/#projects
17+
*/
18+
public function configure()
19+
{
20+
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json';
21+
}
22+
23+
public function all($username, $repository, $columnId, array $params = array())
24+
{
25+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($columnId) . '/cards', array_merge(array('page' => 1), $params));
26+
}
27+
28+
public function show($username, $repository, $id)
29+
{
30+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/'.rawurlencode($id));
31+
}
32+
33+
public function create($username, $repository, $columnId, array $params)
34+
{
35+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($columnId) . '/cards', $params);
36+
}
37+
38+
public function update($username, $repository, $id, array $params)
39+
{
40+
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/' . rawurlencode($id), $params);
41+
}
42+
43+
public function deleteCard($username, $repository, $id)
44+
{
45+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/'.rawurlencode($id));
46+
}
47+
48+
public function move($username, $repository, $id, array $params)
49+
{
50+
if (!isset($params['position'])) {
51+
throw new MissingArgumentException(array('position'));
52+
}
53+
54+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/' . rawurlencode($id) . '/moves', $params);
55+
}
56+
}

lib/Github/Api/Repository/Columns.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Github\Api\Repository;
4+
5+
use Github\Api\AbstractApi;
6+
use Github\Api\AcceptHeaderTrait;
7+
use Github\Exception\MissingArgumentException;
8+
9+
class Columns extends AbstractApi
10+
{
11+
use AcceptHeaderTrait;
12+
13+
/**
14+
* Configure the accept header for Early Access to the projects api
15+
*
16+
* @see https://developer.github.com/v3/repos/projects/#projects
17+
*/
18+
public function configure()
19+
{
20+
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json';
21+
}
22+
23+
public function all($username, $repository, $projectId, array $params = array())
24+
{
25+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($projectId) . '/columns', array_merge(array('page' => 1), $params));
26+
}
27+
28+
public function show($username, $repository, $id)
29+
{
30+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/'.rawurlencode($id));
31+
}
32+
33+
public function create($username, $repository, $projectId, array $params)
34+
{
35+
if (!isset($params['name'])) {
36+
throw new MissingArgumentException(array('name'));
37+
}
38+
39+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($projectId) . '/columns', $params);
40+
}
41+
42+
public function update($username, $repository, $id, array $params)
43+
{
44+
if (!isset($params['name'])) {
45+
throw new MissingArgumentException(array('name'));
46+
}
47+
48+
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($id), $params);
49+
}
50+
51+
public function deleteColumn($username, $repository, $id)
52+
{
53+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/'.rawurlencode($id));
54+
}
55+
56+
public function move($username, $repository, $id, array $params)
57+
{
58+
if (!isset($params['position'])) {
59+
throw new MissingArgumentException(array('position'));
60+
}
61+
62+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($id) . '/moves', $params);
63+
}
64+
65+
public function cards()
66+
{
67+
return new Cards($this->client);
68+
}
69+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Github\Api\Repository;
4+
5+
use Github\Api\AbstractApi;
6+
use Github\Api\AcceptHeaderTrait;
7+
use Github\Exception\MissingArgumentException;
8+
9+
class Projects extends AbstractApi
10+
{
11+
use AcceptHeaderTrait;
12+
13+
/**
14+
* Configure the accept header for Early Access to the projects api
15+
*
16+
* @see https://developer.github.com/v3/repos/projects/#projects
17+
*/
18+
public function configure()
19+
{
20+
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json';
21+
}
22+
23+
public function all($username, $repository, array $params = array())
24+
{
25+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', array_merge(array('page' => 1), $params));
26+
}
27+
28+
public function show($username, $repository, $id, array $params = array())
29+
{
30+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($id), array_merge(array('page' => 1), $params));
31+
}
32+
33+
public function create($username, $repository, array $params)
34+
{
35+
if (!isset($params['name'])) {
36+
throw new MissingArgumentException(array('name'));
37+
}
38+
39+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', $params);
40+
}
41+
42+
public function update($username, $repository, $id, array $params)
43+
{
44+
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/'.rawurlencode($id), $params);
45+
}
46+
47+
public function deleteProject($username, $repository, $id)
48+
{
49+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/'.rawurlencode($id));
50+
}
51+
52+
public function columns()
53+
{
54+
return new Columns($this->client);
55+
}
56+
}

0 commit comments

Comments
 (0)