forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReleases.php
More file actions
127 lines (116 loc) · 3.49 KB
/
Copy pathReleases.php
File metadata and controls
127 lines (116 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
namespace Github\Api\Repository;
use Github\Api\AbstractApi;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/repos/releases/
*
* @author Matthew Simo <matthew.a.simo@gmail.com>
* @author Evgeniy Guseletov <d46k16@gmail.com>
*/
class Releases extends AbstractApi
{
/**
* Get the latest release.
*
* @param string $username
* @param string $repository
*
* @return array
*/
public function latest($username, $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/latest');
}
/**
* List releases for a tag.
*
* @param string $username
* @param string $repository
* @param string $tag
*
* @return array
*/
public function tag($username, $repository, $tag)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/tags/'.rawurlencode($tag));
}
/**
* List releases in selected repository.
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
* @param array $params the additional parameters like milestone, assignees, labels, sort, direction
*
* @return array
*/
public function all($username, $repository, array $params = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases', $params);
}
/**
* Get a release in selected repository.
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
* @param int $id the id of the release
*
* @return array
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id));
}
/**
* Create new release in selected repository.
*
* @param string $username
* @param string $repository
* @param array $params
*
* @throws MissingArgumentException
*
* @return array
*/
public function create($username, $repository, array $params)
{
if (!isset($params['tag_name'])) {
throw new MissingArgumentException('tag_name');
}
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases', $params);
}
/**
* Edit release in selected repository.
*
* @param string $username
* @param string $repository
* @param int $id
* @param array $params
*
* @return array
*/
public function edit($username, $repository, $id, array $params)
{
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id), $params);
}
/**
* Delete a release in selected repository (Not thoroughly tested!).
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
* @param int $id the id of the release
*
* @return array
*/
public function remove($username, $repository, $id)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id));
}
/**
* @return Assets
*/
public function assets()
{
return new Assets($this->client);
}
}