|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api\Repository; |
| 4 | + |
| 5 | +use Github\Api\AbstractApi; |
| 6 | +use Github\Exception\MissingArgumentException; |
| 7 | + |
| 8 | +/** |
| 9 | + * @link http://developer.github.com/v3/repos/releases/ |
| 10 | + * @author Matthew Simo <matthew.a.simo@gmail.com> |
| 11 | + * @author Evgeniy Guseletov <d46k16@gmail.com> |
| 12 | + */ |
| 13 | +class Releases extends AbstractApi |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @deprecated Will be removed as soon as gh releases api gets stable |
| 17 | + */ |
| 18 | + public function configure() |
| 19 | + { |
| 20 | + $this->client->setHeaders(array( |
| 21 | + 'Accept: application/vnd.github.manifold-preview' |
| 22 | + )); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * List releases in selected repository |
| 27 | + * |
| 28 | + * @param string $username the user who owns the repo |
| 29 | + * @param string $repository the name of the repo |
| 30 | + * |
| 31 | + * @return array |
| 32 | + */ |
| 33 | + public function all($username, $repository) |
| 34 | + { |
| 35 | + return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases'); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Get a release in selected repository |
| 40 | + * |
| 41 | + * @param string $username the user who owns the repo |
| 42 | + * @param string $repository the name of the repo |
| 43 | + * @param integer $id the id of the release |
| 44 | + * |
| 45 | + * @return array |
| 46 | + */ |
| 47 | + public function show($username, $repository, $id) |
| 48 | + { |
| 49 | + return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id)); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Create new release in selected repository |
| 54 | + * |
| 55 | + * @param string $username |
| 56 | + * @param string $repository |
| 57 | + * @param array $params |
| 58 | + * |
| 59 | + * @throws MissingArgumentException |
| 60 | + * |
| 61 | + * @return array |
| 62 | + */ |
| 63 | + public function create($username, $repository, array $params) |
| 64 | + { |
| 65 | + if (!isset($params['tag_name'])) { |
| 66 | + throw new MissingArgumentException('tag_name'); |
| 67 | + } |
| 68 | + |
| 69 | + return $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases', $params); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Edit release in selected repository |
| 74 | + * |
| 75 | + * @param string $username |
| 76 | + * @param string $repository |
| 77 | + * @param integer $id |
| 78 | + * @param array $params |
| 79 | + * |
| 80 | + * @return array |
| 81 | + */ |
| 82 | + public function edit($username, $repository, $id, array $params) |
| 83 | + { |
| 84 | + return $this->patch('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id), $params); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Delete a release in selected repository (Not thoroughly tested!) |
| 89 | + * |
| 90 | + * @param string $username the user who owns the repo |
| 91 | + * @param string $repository the name of the repo |
| 92 | + * @param integer $id the id of the release |
| 93 | + * |
| 94 | + * @return array |
| 95 | + */ |
| 96 | + public function remove($username, $repository, $id) |
| 97 | + { |
| 98 | + return $this->delete('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id)); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * @return Assets |
| 103 | + */ |
| 104 | + public function assets() |
| 105 | + { |
| 106 | + return new Assets($this->client); |
| 107 | + } |
| 108 | +} |
0 commit comments