Skip to content

Commit 1f06686

Browse files
ericdurana-lwilliams
authored andcommitted
Adding basic deployment api support
1 parent 40cbb26 commit 1f06686

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

lib/Github/Api/Deployment.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)