From 0005d74ae5b9f07b8af02d429cd1170380974606 Mon Sep 17 00:00:00 2001 From: Matthew Simo Date: Fri, 23 Aug 2013 17:43:33 -0500 Subject: [PATCH 1/2] Add Class for releases. --- lib/Github/Api/Repo.php | 12 ++++++ lib/Github/Api/Repository/Releases.php | 52 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 lib/Github/Api/Repository/Releases.php 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..f027d3194e0 --- /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 + * + * @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)); + } +} From 08e7c7c9e86014526340c031f96bd361ac11caaa Mon Sep 17 00:00:00 2001 From: Matthew Simo Date: Fri, 23 Aug 2013 18:23:29 -0500 Subject: [PATCH 2/2] Docs & a comment --- doc/index.md | 1 + doc/repo/releases.md | 25 +++++++++++++++++++++++++ lib/Github/Api/Repository/Releases.php | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 doc/repo/releases.md 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/Repository/Releases.php b/lib/Github/Api/Repository/Releases.php index f027d3194e0..3def47b154f 100644 --- a/lib/Github/Api/Repository/Releases.php +++ b/lib/Github/Api/Repository/Releases.php @@ -37,7 +37,7 @@ public function show($username, $repository, $id) } /** - * Delete a download in selected repository + * 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