33namespace Github \Api \Repository ;
44
55use Github \Api \AbstractApi ;
6+ use Github \Exception \MissingArgumentException ;
67
78/**
9+ * @link http://developer.github.com/v3/repos/releases/
810 * @author Matthew Simo <matthew.a.simo@gmail.com>
11+ * @author Evgeniy Guseletov <d46k16@gmail.com>
912 */
1013class Releases extends AbstractApi
1114{
@@ -19,25 +22,60 @@ class Releases extends AbstractApi
1922 */
2023 public function all ($ username , $ repository )
2124 {
22- return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repository ).'/releases ' );
25+ return $ this ->get ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases ' );
2326 }
2427
2528 /**
2629 * Get a release in selected repository
2730 *
2831 * @param string $username the user who owns the repo
2932 * @param string $repository the name of the repo
30- * @param integer $id the id of the release
33+ * @param integer $id the id of the release
3134 *
3235 * @return array
3336 */
3437 public function show ($ username , $ repository , $ id )
3538 {
36- return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repository ).'/releases/ ' .urlencode ($ id ));
39+ return $ this ->get ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases/ ' .rawurlencode ($ id ));
40+ }
41+
42+ /**
43+ * Create new release in selected repository
44+ *
45+ * @param string $username
46+ * @param string $repository
47+ * @param array $params
48+ *
49+ * @throws MissingArgumentException
50+ *
51+ * @return array
52+ */
53+ public function create ($ username , $ repository , array $ params )
54+ {
55+ if (!isset ($ params ['tag_name ' ])) {
56+ throw new MissingArgumentException ('tag_name ' );
57+ }
58+
59+ return $ this ->post ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases ' , $ params );
60+ }
61+
62+ /**
63+ * Edit release in selected repository
64+ *
65+ * @param string $username
66+ * @param string $repository
67+ * @param integer $id
68+ * @param array $params
69+ *
70+ * @return array
71+ */
72+ public function edit ($ username , $ repository , $ id , array $ params )
73+ {
74+ return $ this ->patch ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases/ ' .rawurlencode ($ id ), $ params );
3775 }
3876
3977 /**
40- * Delete a download in selected repository (Not thoroughly tested!)
78+ * Delete a release in selected repository (Not thoroughly tested!)
4179 *
4280 * @param string $username the user who owns the repo
4381 * @param string $repository the name of the repo
@@ -47,6 +85,14 @@ public function show($username, $repository, $id)
4785 */
4886 public function remove ($ username , $ repository , $ id )
4987 {
50- return $ this ->delete ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repository ).'/releases/ ' .urlencode ($ id ));
88+ return $ this ->delete ('repos/ ' .rawurlencode ($ username ).'/ ' .rawurlencode ($ repository ).'/releases/ ' .rawurlencode ($ id ));
89+ }
90+
91+ /**
92+ * @return Assets
93+ */
94+ public function assets ()
95+ {
96+ return new Assets ($ this ->client );
5197 }
5298}
0 commit comments