Skip to content

Commit 9e40d8b

Browse files
author
Evgeniy Guseletov
committed
Merge remote-tracking branch '1/releases-class' into feature/gh-api-release
2 parents ce011c3 + 08e7c7c commit 9e40d8b

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ APIs:
1414
* [Pull Requests](pull_requests.md)
1515
* [Comments](pull_request/comments.md)
1616
* [Repositories](repos.md)
17+
* [Releases](repo/releases.md)
1718
* [Users](users.md)
1819

1920
Additional features:

doc/repo/releases.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Repo / Releases API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md)
3+
4+
This Github API Endpoint is currently undocumented because it's new, but works just fine.
5+
6+
7+
### List all releases
8+
9+
```php
10+
$releases = $client->api('repo')->releases()->all('twbs', 'bootstrap');
11+
```
12+
13+
### List one release
14+
15+
```php
16+
$release = $client->api('repo')->releases()->show('twbs', 'bootstrap', $id);
17+
```
18+
19+
### Remove a release
20+
21+
This works, but isn't thoroughly tested, use at your own risk.
22+
23+
```php
24+
$response = $client->api('repo')->releases()->remove('twbs', 'bootstrap', $id);
25+
```

lib/Github/Api/Repo.php

Lines changed: 12 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\Releases;
1112
use Github\Api\Repository\Forks;
1213
use Github\Api\Repository\Hooks;
1314
use Github\Api\Repository\Labels;
@@ -198,6 +199,17 @@ public function downloads()
198199
return new Downloads($this->client);
199200
}
200201

202+
/**
203+
* Manage the releases of a repository (Currently Undocumented)
204+
* @link http://developer.github.com/v3/repos/
205+
*
206+
* @return Releases
207+
*/
208+
public function releases()
209+
{
210+
return new Releases($this->client);
211+
}
212+
201213
/**
202214
* Manage the deploy keys of a repository
203215
* @link http://developer.github.com/v3/repos/keys/
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace Github\Api\Repository;
4+
5+
use Github\Api\AbstractApi;
6+
7+
/**
8+
* @author Matthew Simo <[email protected]>
9+
*/
10+
class Releases extends AbstractApi
11+
{
12+
/**
13+
* List releases in selected repository
14+
*
15+
* @param string $username the user who owns the repo
16+
* @param string $repository the name of the repo
17+
*
18+
* @return array
19+
*/
20+
public function all($username, $repository)
21+
{
22+
return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/releases');
23+
}
24+
25+
/**
26+
* Get a release in selected repository
27+
*
28+
* @param string $username the user who owns the repo
29+
* @param string $repository the name of the repo
30+
* @param integer $id the id of the release
31+
*
32+
* @return array
33+
*/
34+
public function show($username, $repository, $id)
35+
{
36+
return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/releases/'.urlencode($id));
37+
}
38+
39+
/**
40+
* Delete a download in selected repository (Not thoroughly tested!)
41+
*
42+
* @param string $username the user who owns the repo
43+
* @param string $repository the name of the repo
44+
* @param integer $id the id of the release
45+
*
46+
* @return array
47+
*/
48+
public function remove($username, $repository, $id)
49+
{
50+
return $this->delete('repos/'.urlencode($username).'/'.urlencode($repository).'/releases/'.urlencode($id));
51+
}
52+
}

0 commit comments

Comments
 (0)