|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api; |
| 4 | + |
| 5 | +use Github\Exception\MissingArgumentException; |
| 6 | + |
| 7 | +class Deployment extends AbstractApi |
| 8 | +{ |
| 9 | + |
| 10 | + public function all($username, $repository, array $params = array()) |
| 11 | + { |
| 12 | + return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', array(), |
| 13 | + ['Accept' => 'application/vnd.github.cannonball-preview+json'] |
| 14 | + ); |
| 15 | + } |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + /** |
| 20 | + * Create a new deployment for the given username and repo. |
| 21 | + * |
| 22 | + * @param string $username the username |
| 23 | + * @param string $repository the repository |
| 24 | + * @param array $params the new deployment data |
| 25 | + * @return array information about the deployment |
| 26 | + * |
| 27 | + * @throws MissingArgumentException |
| 28 | + */ |
| 29 | + public function create($username, $repository, array $params) |
| 30 | + { |
| 31 | + if (!isset($params['ref'])) { |
| 32 | + throw new MissingArgumentException(array('ref')); |
| 33 | + } |
| 34 | + |
| 35 | + return $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params, ['Accept' => 'application/vnd.github.cannonball-preview+json']); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Update deployment information's by username, repo and deployment number. Requires authentication. |
| 40 | + * |
| 41 | + * @param string $username the username |
| 42 | + * @param string $repository the repository |
| 43 | + * @param string $id the deployment number |
| 44 | + * @return array information about the deployment |
| 45 | + */ |
| 46 | + public function update($username, $repository, $id, array $params) |
| 47 | + { |
| 48 | + if (!isset($params['state'])) { |
| 49 | + throw new MissingArgumentException(array('state')); |
| 50 | + } |
| 51 | + return $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id).'/statuses', $params, ['Accept' => 'application/vnd.github.cannonball-preview+json']); |
| 52 | + } |
| 53 | +} |
0 commit comments