|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api\Repository; |
| 4 | + |
| 5 | +use Github\Api\AbstractApi; |
| 6 | +use Github\Api\AcceptHeaderTrait; |
| 7 | +use Github\Exception\MissingArgumentException; |
| 8 | + |
| 9 | +class Columns extends AbstractApi |
| 10 | +{ |
| 11 | + use AcceptHeaderTrait; |
| 12 | + |
| 13 | + /** |
| 14 | + * Configure the accept header for Early Access to the projects api |
| 15 | + * |
| 16 | + * @see https://developer.github.com/v3/repos/projects/#projects |
| 17 | + */ |
| 18 | + public function configure() |
| 19 | + { |
| 20 | + $this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; |
| 21 | + } |
| 22 | + |
| 23 | + public function all($username, $repository, $projectId, array $params = array()) |
| 24 | + { |
| 25 | + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($projectId) . '/columns', array_merge(array('page' => 1), $params)); |
| 26 | + } |
| 27 | + |
| 28 | + public function show($username, $repository, $id) |
| 29 | + { |
| 30 | + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/'.rawurlencode($id)); |
| 31 | + } |
| 32 | + |
| 33 | + public function create($username, $repository, $projectId, array $params) |
| 34 | + { |
| 35 | + if (!isset($params['name'])) { |
| 36 | + throw new MissingArgumentException(array('name')); |
| 37 | + } |
| 38 | + |
| 39 | + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/' . rawurlencode($projectId) . '/columns', $params); |
| 40 | + } |
| 41 | + |
| 42 | + public function update($username, $repository, $id, array $params) |
| 43 | + { |
| 44 | + if (!isset($params['name'])) { |
| 45 | + throw new MissingArgumentException(array('name')); |
| 46 | + } |
| 47 | + |
| 48 | + return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($id), $params); |
| 49 | + } |
| 50 | + |
| 51 | + public function deleteColumn($username, $repository, $id) |
| 52 | + { |
| 53 | + return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/'.rawurlencode($id)); |
| 54 | + } |
| 55 | + |
| 56 | + public function move($username, $repository, $id, array $params) |
| 57 | + { |
| 58 | + if (!isset($params['position'])) { |
| 59 | + throw new MissingArgumentException(array('position')); |
| 60 | + } |
| 61 | + |
| 62 | + return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects/columns/' . rawurlencode($id) . '/moves', $params); |
| 63 | + } |
| 64 | + |
| 65 | + public function cards() |
| 66 | + { |
| 67 | + return new Cards($this->client); |
| 68 | + } |
| 69 | +} |
0 commit comments