forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request KnpLabs#449 from acrobat/api-projects
Added support for the projects api
- Loading branch information
Showing
11 changed files
with
755 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## Repo / Cards API | ||
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md) | ||
|
||
This api is currently only available to developers in Early Access. To access the API during the Early Access period, | ||
you must provide a custom media type in the Accept header. | ||
|
||
```php | ||
$client->api('repo')->projects()->columns()->cards()->configure(); | ||
``` | ||
|
||
### List all cards of a column | ||
|
||
```php | ||
$cards = $client->api('repo')->projects()->columns()->cards()->all('twbs', 'bootstrap', $columnId); | ||
``` | ||
|
||
### List one card | ||
|
||
```php | ||
$card = $client->api('repo')->projects()->columns()->cards()->show('twbs', 'bootstrap', $cardId); | ||
``` | ||
|
||
### Create a card | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$card = $client->api('repo')->projects()->columns()->cards()->create('twbs', 'bootstrap', $columnId, array('content_type' => 'Issue', 'content_id' => '452')); | ||
``` | ||
|
||
### Edit a card | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$card = $client->api('repo')->project()->columns()->cards()->update('twbs', 'bootstrap', $cardId, array('note' => 'card note')); | ||
``` | ||
|
||
### Remove a card | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$card = $client->api('repo')->projects()->columns()->cards()->deleteCard('twbs', 'bootstrap', $cardId); | ||
``` | ||
|
||
### Move a card | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$card = $client->api('repo')->projects()->columns()->cards()->move('twbs', 'bootstrap', $cardId, array('position' => 'top)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## Repo / Columns API | ||
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md) | ||
|
||
This api is currently only available to developers in Early Access. To access the API during the Early Access period, | ||
you must provide a custom media type in the Accept header. | ||
|
||
```php | ||
$client->api('repo')->projects()->columns()->configure(); | ||
``` | ||
|
||
### List all columns of a project | ||
|
||
```php | ||
$columns = $client->api('repo')->projects()->columns()->all('twbs', 'bootstrap', $projectId); | ||
``` | ||
|
||
### List one column | ||
|
||
```php | ||
$column = $client->api('repo')->projects()->columns()->show('twbs', 'bootstrap', $columnId); | ||
``` | ||
|
||
### Create a column | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$column = $client->api('repo')->projects()->columns()->create('twbs', 'bootstrap', $projectId, array('name' => 'Column name')); | ||
``` | ||
|
||
### Edit a column | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$column = $client->api('repo')->project()->columns()->update('twbs', 'bootstrap', $columnId, array('name' => 'New name')); | ||
``` | ||
|
||
### Remove a column | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$column = $client->api('repo')->projects()->columns()->deleteColumn('twbs', 'bootstrap', $columnId); | ||
``` | ||
|
||
### Move a column | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$column = $client->api('repo')->projects()->columns()->move('twbs', 'bootstrap', $columnId, array('position' => 'first)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## Repo / Projects API | ||
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md) | ||
|
||
This api is currently only available to developers in Early Access. To access the API during the Early Access period, | ||
you must provide a custom media type in the Accept header. | ||
|
||
```php | ||
$client->api('repo')->projects()->configure(); | ||
``` | ||
|
||
### List all projects | ||
|
||
```php | ||
$projects = $client->api('repo')->projects()->all('twbs', 'bootstrap'); | ||
``` | ||
|
||
### List one project | ||
|
||
```php | ||
$project = $client->api('repo')->projects()->show('twbs', 'bootstrap', $projectId); | ||
``` | ||
|
||
### Create a project | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$project = $client->api('repo')->projects()->create('twbs', 'bootstrap', array('name' => 'Project name')); | ||
``` | ||
|
||
### Edit a project | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$project = $client->api('repo')->project()->update('twbs', 'bootstrap', $projectId, array('name' => 'New name')); | ||
``` | ||
|
||
### Remove a project | ||
|
||
> Requires [authentication](../security.md). | ||
```php | ||
$project = $client->api('repo')->projects()->deleteProject('twbs', 'bootstrap', $projectId); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Github\Api\Repository; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Api\AcceptHeaderTrait; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
class Cards extends AbstractApi | ||
{ | ||
use AcceptHeaderTrait; | ||
|
||
/** | ||
* Configure the accept header for Early Access to the projects api | ||
* | ||
* @see https://developer.github.com/v3/repos/projects/#projects | ||
*/ | ||
public function configure() | ||
{ | ||
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; | ||
} | ||
|
||
public function all($username, $repository, $columnId, array $params = array()) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($columnId) . '/cards', array_merge(array('page' => 1), $params)); | ||
} | ||
|
||
public function show($username, $repository, $id) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/'.rawurlencode($id)); | ||
} | ||
|
||
public function create($username, $repository, $columnId, array $params) | ||
{ | ||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($columnId) . '/cards', $params); | ||
} | ||
|
||
public function update($username, $repository, $id, array $params) | ||
{ | ||
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/' . rawurlencode($id), $params); | ||
} | ||
|
||
public function deleteCard($username, $repository, $id) | ||
{ | ||
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/'.rawurlencode($id)); | ||
} | ||
|
||
public function move($username, $repository, $id, array $params) | ||
{ | ||
if (!isset($params['position'])) { | ||
throw new MissingArgumentException(array('position')); | ||
} | ||
|
||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/cards/' . rawurlencode($id) . '/moves', $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Github\Api\Repository; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Api\AcceptHeaderTrait; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
class Columns extends AbstractApi | ||
{ | ||
use AcceptHeaderTrait; | ||
|
||
/** | ||
* Configure the accept header for Early Access to the projects api | ||
* | ||
* @see https://developer.github.com/v3/repos/projects/#projects | ||
*/ | ||
public function configure() | ||
{ | ||
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; | ||
} | ||
|
||
public function all($username, $repository, $projectId, array $params = array()) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($projectId) . '/columns', array_merge(array('page' => 1), $params)); | ||
} | ||
|
||
public function show($username, $repository, $id) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/'.rawurlencode($id)); | ||
} | ||
|
||
public function create($username, $repository, $projectId, array $params) | ||
{ | ||
if (!isset($params['name'])) { | ||
throw new MissingArgumentException(array('name')); | ||
} | ||
|
||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($projectId) . '/columns', $params); | ||
} | ||
|
||
public function update($username, $repository, $id, array $params) | ||
{ | ||
if (!isset($params['name'])) { | ||
throw new MissingArgumentException(array('name')); | ||
} | ||
|
||
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($id), $params); | ||
} | ||
|
||
public function deleteColumn($username, $repository, $id) | ||
{ | ||
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/'.rawurlencode($id)); | ||
} | ||
|
||
public function move($username, $repository, $id, array $params) | ||
{ | ||
if (!isset($params['position'])) { | ||
throw new MissingArgumentException(array('position')); | ||
} | ||
|
||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($id) . '/moves', $params); | ||
} | ||
|
||
public function cards() | ||
{ | ||
return new Cards($this->client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Github\Api\Repository; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Api\AcceptHeaderTrait; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
class Projects extends AbstractApi | ||
{ | ||
use AcceptHeaderTrait; | ||
|
||
/** | ||
* Configure the accept header for Early Access to the projects api | ||
* | ||
* @see https://developer.github.com/v3/repos/projects/#projects | ||
*/ | ||
public function configure() | ||
{ | ||
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; | ||
} | ||
|
||
public function all($username, $repository, array $params = array()) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', array_merge(array('page' => 1), $params)); | ||
} | ||
|
||
public function show($username, $repository, $id, array $params = array()) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($id), array_merge(array('page' => 1), $params)); | ||
} | ||
|
||
public function create($username, $repository, array $params) | ||
{ | ||
if (!isset($params['name'])) { | ||
throw new MissingArgumentException(array('name')); | ||
} | ||
|
||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', $params); | ||
} | ||
|
||
public function update($username, $repository, $id, array $params) | ||
{ | ||
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/'.rawurlencode($id), $params); | ||
} | ||
|
||
public function deleteProject($username, $repository, $id) | ||
{ | ||
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/'.rawurlencode($id)); | ||
} | ||
|
||
public function columns() | ||
{ | ||
return new Columns($this->client); | ||
} | ||
} |
Oops, something went wrong.