Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ APIs:
* [Organization](organization.md)
* [Members](organization/members.md)
* [Teams](organization/teams.md)
* [Projects](project/projects.md)
* [Columns](project/columns.md)
* [Cards](project/cards.md)
* [Pull Requests](pull_requests.md)
* [Comments](pull_request/comments.md)
* [Rate Limits](rate_limits.md)
* [Repositories](repos.md)
* [Contents](repo/contents.md)
* [Deployments](repo/deployments.md)
* [Projects](repo/projects.md)
* [Columns](repo/columns.md)
* [Cards](repo/cards.md)
* [Releases](repo/releases.md)
* [Assets](repo/assets.md)
* [Stargazers](repo/stargazers.md)
Expand Down
16 changes: 10 additions & 6 deletions doc/repo/cards.md → doc/project/cards.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,54 @@
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.

Both repositories and organisations have projects. The api is only different for getting all project or retrieving a single project.
All the example use the repository projects column card api but this also works form the organization api (`$client->api('org_projects')->columns()->cards()`)


```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);
$cards = $client->api('repo')->projects()->columns()->cards()->all($columnId);
```

### List one card

```php
$card = $client->api('repo')->projects()->columns()->cards()->show('twbs', 'bootstrap', $cardId);
$card = $client->api('repo')->projects()->columns()->cards()->show($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'));
$card = $client->api('repo')->projects()->columns()->cards()->create($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'));
$card = $client->api('repo')->project()->columns()->cards()->update($cardId, array('note' => 'card note'));
```

### Remove a card

> Requires [authentication](../security.md).

```php
$card = $client->api('repo')->projects()->columns()->cards()->deleteCard('twbs', 'bootstrap', $cardId);
$card = $client->api('repo')->projects()->columns()->cards()->deleteCard($cardId);
```

### Move a card

> Requires [authentication](../security.md).

```php
$card = $client->api('repo')->projects()->columns()->cards()->move('twbs', 'bootstrap', $cardId, array('position' => 'top));
$card = $client->api('repo')->projects()->columns()->cards()->move($cardId, array('position' => 'top));
```
16 changes: 10 additions & 6 deletions doc/repo/columns.md → doc/project/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,54 @@
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.

Both repositories and organisations have projects. The api is only different for getting all project or retrieving a single project.
All the example use the repository projects column api but this also works form the organization api (`$client->api('org_projects')->columns()`)


```php
$client->api('repo')->projects()->columns()->configure();
```

### List all columns of a project

```php
$columns = $client->api('repo')->projects()->columns()->all('twbs', 'bootstrap', $projectId);
$columns = $client->api('repo')->projects()->columns()->all($projectId);
```

### List one column

```php
$column = $client->api('repo')->projects()->columns()->show('twbs', 'bootstrap', $columnId);
$column = $client->api('repo')->projects()->columns()->show($columnId);
```

### Create a column

> Requires [authentication](../security.md).

```php
$column = $client->api('repo')->projects()->columns()->create('twbs', 'bootstrap', $projectId, array('name' => 'Column name'));
$column = $client->api('repo')->projects()->columns()->create($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'));
$column = $client->api('repo')->project()->columns()->update($columnId, array('name' => 'New name'));
```

### Remove a column

> Requires [authentication](../security.md).

```php
$column = $client->api('repo')->projects()->columns()->deleteColumn('twbs', 'bootstrap', $columnId);
$column = $client->api('repo')->projects()->columns()->deleteColumn($columnId);
```

### Move a column

> Requires [authentication](../security.md).

```php
$column = $client->api('repo')->projects()->columns()->move('twbs', 'bootstrap', $columnId, array('position' => 'first));
$column = $client->api('repo')->projects()->columns()->move($columnId, array('position' => 'first));
```
15 changes: 11 additions & 4 deletions doc/repo/projects.md → doc/project/projects.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Repo / Projects API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
[Back to the "Repos API"](../) | [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.

Both repositories and organisations have projects. The api is only different for gettings all or a single project.
All the example use the repository projects api but this also works form the organization api (`$client->api('org_projects')`)

```php
$client->api('repo')->projects()->configure();
```
Expand All @@ -12,12 +15,16 @@ $client->api('repo')->projects()->configure();

```php
$projects = $client->api('repo')->projects()->all('twbs', 'bootstrap');

//or

$projects = $client->api('org_projects')->all('twbs');
```

### List one project

```php
$project = $client->api('repo')->projects()->show('twbs', 'bootstrap', $projectId);
$project = $client->api('repo')->projects()->show($projectId);
```

### Create a project
Expand All @@ -33,13 +40,13 @@ $project = $client->api('repo')->projects()->create('twbs', 'bootstrap', array('
> Requires [authentication](../security.md).

```php
$project = $client->api('repo')->project()->update('twbs', 'bootstrap', $projectId, array('name' => 'New name'));
$project = $client->api('repo')->project()->update($projectId, array('name' => 'New name'));
```

### Remove a project

> Requires [authentication](../security.md).

```php
$project = $client->api('repo')->projects()->deleteProject('twbs', 'bootstrap', $projectId);
$project = $client->api('repo')->projects()->deleteProject($projectId);
```
23 changes: 23 additions & 0 deletions lib/Github/Api/Organization/Projects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Github\Api\Organization;

use Github\Api\Project\AbstractProjectApi;
use Github\Exception\MissingArgumentException;

class Projects extends AbstractProjectApi
{
public function all($organization, array $params = array())
{
return $this->get('/orgs/'.rawurlencode($organization).'/projects', array_merge(array('page' => 1), $params));
}

public function create($organization, array $params)
{
if (!isset($params['name'])) {
throw new MissingArgumentException(array('name'));
}

return $this->post('/orgs/'.rawurlencode($organization).'/projects', $params);
}
}
41 changes: 41 additions & 0 deletions lib/Github/Api/Project/AbstractProjectApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Github\Api\Project;

use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;

abstract class AbstractProjectApi 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 show($id, array $params = array())
{
return $this->get('/projects/' . rawurlencode($id), array_merge(array('page' => 1), $params));
}

public function update($id, array $params)
{
return $this->patch('/projects/'.rawurlencode($id), $params);
}

public function deleteProject($id)
{
return $this->delete('/projects/'.rawurlencode($id));
}

public function columns()
{
return new Columns($this->client);
}
}
56 changes: 56 additions & 0 deletions lib/Github/Api/Project/Cards.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace Github\Api\Project;

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($columnId, array $params = array())
{
return $this->get('/projects/columns/' . rawurlencode($columnId) . '/cards', array_merge(array('page' => 1), $params));
}

public function show($id)
{
return $this->get('/projects/columns/cards/'.rawurlencode($id));
}

public function create($columnId, array $params)
{
return $this->post('/projects/columns/' . rawurlencode($columnId) . '/cards', $params);
}

public function update($id, array $params)
{
return $this->patch('/projects/columns/cards/' . rawurlencode($id), $params);
}

public function deleteCard($id)
{
return $this->delete('/projects/columns/cards/'.rawurlencode($id));
}

public function move($id, array $params)
{
if (!isset($params['position'])) {
throw new MissingArgumentException(array('position'));
}

return $this->post('/projects/columns/cards/' . rawurlencode($id) . '/moves', $params);
}
}
69 changes: 69 additions & 0 deletions lib/Github/Api/Project/Columns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Github\Api\Project;

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($projectId, array $params = array())
{
return $this->get('/projects/' . rawurlencode($projectId) . '/columns', array_merge(array('page' => 1), $params));
}

public function show($id)
{
return $this->get('/projects/columns/'.rawurlencode($id));
}

public function create($projectId, array $params)
{
if (!isset($params['name'])) {
throw new MissingArgumentException(array('name'));
}

return $this->post('/projects/' . rawurlencode($projectId) . '/columns', $params);
}

public function update($id, array $params)
{
if (!isset($params['name'])) {
throw new MissingArgumentException(array('name'));
}

return $this->patch('/projects/columns/' . rawurlencode($id), $params);
}

public function deleteColumn($id)
{
return $this->delete('/projects/columns/'.rawurlencode($id));
}

public function move($id, array $params)
{
if (!isset($params['position'])) {
throw new MissingArgumentException(array('position'));
}

return $this->post('/projects/columns/' . rawurlencode($id) . '/moves', $params);
}

public function cards()
{
return new Cards($this->client);
}
}
Loading