diff --git a/doc/index.md b/doc/index.md index 45d6622d1c1..68d1540707e 100644 --- a/doc/index.md +++ b/doc/index.md @@ -13,6 +13,7 @@ APIs: * [Pull Requests](pull_requests.md) * [Comments](pull_request/comments.md) * [Repositories](repos.md) + * [Releases](repo/releases.md) * [Users](users.md) Additional features: diff --git a/doc/repo/releases.md b/doc/repo/releases.md new file mode 100644 index 00000000000..63a4241a0b4 --- /dev/null +++ b/doc/repo/releases.md @@ -0,0 +1,25 @@ +## Repo / Releases API +[Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md) + +This Github API Endpoint is currently undocumented because it's new, but works just fine. + + +### List all releases + +```php +$releases = $client->api('repo')->releases()->all('twbs', 'bootstrap'); +``` + +### List one release + +```php +$release = $client->api('repo')->releases()->show('twbs', 'bootstrap', $id); +``` + +### Remove a release + +This works, but isn't thoroughly tested, use at your own risk. + +```php +$response = $client->api('repo')->releases()->remove('twbs', 'bootstrap', $id); +``` diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index e61c9c6c02b..71cd726f380 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -8,6 +8,7 @@ use Github\Api\Repository\Contents; use Github\Api\Repository\DeployKeys; use Github\Api\Repository\Downloads; +use Github\Api\Repository\Releases; use Github\Api\Repository\Forks; use Github\Api\Repository\Hooks; use Github\Api\Repository\Labels; @@ -156,6 +157,17 @@ public function downloads() return new Downloads($this->client); } + /** + * Manage the releases of a repository (Currently Undocumented) + * @link http://developer.github.com/v3/repos/ + * + * @return Releases + */ + public function releases() + { + return new Releases($this->client); + } + /** * Manage the deploy keys of a repository * @link http://developer.github.com/v3/repos/keys/ diff --git a/lib/Github/Api/Repository/Releases.php b/lib/Github/Api/Repository/Releases.php new file mode 100644 index 00000000000..3def47b154f --- /dev/null +++ b/lib/Github/Api/Repository/Releases.php @@ -0,0 +1,52 @@ + + */ +class Releases extends AbstractApi +{ + /** + * List releases in selected repository + * + * @param string $username the user who owns the repo + * @param string $repository the name of the repo + * + * @return array + */ + public function all($username, $repository) + { + return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/releases'); + } + + /** + * Get a release in selected repository + * + * @param string $username the user who owns the repo + * @param string $repository the name of the repo + * @param integer $id the id of the release + * + * @return array + */ + public function show($username, $repository, $id) + { + return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/releases/'.urlencode($id)); + } + + /** + * Delete a download in selected repository (Not thoroughly tested!) + * + * @param string $username the user who owns the repo + * @param string $repository the name of the repo + * @param integer $id the id of the release + * + * @return array + */ + public function remove($username, $repository, $id) + { + return $this->delete('repos/'.urlencode($username).'/'.urlencode($repository).'/releases/'.urlencode($id)); + } +}