|
1 | | -<?php |
2 | | - |
3 | | -namespace Gitlab\Api; |
4 | | - |
5 | | -class MergeRequests extends AbstractApi |
6 | | -{ |
7 | | - public function all($project_id, $page = 1, $per_page = self::PER_PAGE) |
8 | | - { |
9 | | - return $this->get('projects/'.urlencode($project_id).'/merge_requests', array( |
10 | | - 'page' => $page, |
11 | | - 'per_page' => $per_page |
12 | | - )); |
13 | | - } |
14 | | - |
15 | | - public function show($project_id, $mr_id) |
16 | | - { |
17 | | - return $this->get('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id)); |
18 | | - } |
19 | | - |
20 | | - public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null) |
21 | | - { |
22 | | - if ($target_project_id && ! is_numeric($target_project_id)) { |
23 | | - throw new \InvalidArgumentException('target_project_id should be numeric, the project name is not allowed'); |
24 | | - } |
25 | | - |
26 | | - return $this->post('projects/'.urlencode($project_id).'/merge_requests', array( |
27 | | - 'source_branch' => $source, |
28 | | - 'target_branch' => $target, |
29 | | - 'title' => $title, |
30 | | - 'assignee_id' => $assignee, |
31 | | - 'target_project_id' => $target_project_id, |
32 | | - 'description' => $description |
33 | | - )); |
34 | | - } |
35 | | - |
36 | | - public function update($project_id, $mr_id, array $params) |
37 | | - { |
38 | | - return $this->put('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id), $params); |
39 | | - } |
40 | | - |
41 | | - public function merge($project_id, $mr_id, array $params) |
42 | | - { |
43 | | - return $this->put('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id).'/merge', $params); |
44 | | - } |
45 | | - |
46 | | - public function showComments($project_id, $issue_id) |
47 | | - { |
48 | | - return $this->get('projects/'.urlencode($project_id).'/issues/'.urlencode($issue_id).'/notes'); |
49 | | - } |
50 | | - |
51 | | - public function addComment($project_id, $mr_id, $note) |
52 | | - { |
53 | | - return $this->post('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id).'/comments', array( |
54 | | - 'note' => $note |
55 | | - )); |
56 | | - } |
57 | | -} |
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Gitlab\Api; |
| 4 | + |
| 5 | +class MergeRequests extends AbstractApi |
| 6 | +{ |
| 7 | + public function all($project_id, $page = 1, $per_page = self::PER_PAGE) |
| 8 | + { |
| 9 | + return $this->get('projects/'.urlencode($project_id).'/merge_requests', array( |
| 10 | + 'page' => $page, |
| 11 | + 'per_page' => $per_page |
| 12 | + )); |
| 13 | + } |
| 14 | + |
| 15 | + public function show($project_id, $mr_id) |
| 16 | + { |
| 17 | + return $this->get('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id)); |
| 18 | + } |
| 19 | + |
| 20 | + public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null) |
| 21 | + { |
| 22 | + if ($target_project_id && ! is_numeric($target_project_id)) { |
| 23 | + throw new \InvalidArgumentException('target_project_id should be numeric, the project name is not allowed'); |
| 24 | + } |
| 25 | + |
| 26 | + return $this->post('projects/'.urlencode($project_id).'/merge_requests', array( |
| 27 | + 'source_branch' => $source, |
| 28 | + 'target_branch' => $target, |
| 29 | + 'title' => $title, |
| 30 | + 'assignee_id' => $assignee, |
| 31 | + 'target_project_id' => $target_project_id, |
| 32 | + 'description' => $description |
| 33 | + )); |
| 34 | + } |
| 35 | + |
| 36 | + public function update($project_id, $mr_id, array $params) |
| 37 | + { |
| 38 | + return $this->put('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id), $params); |
| 39 | + } |
| 40 | + |
| 41 | + public function merge($project_id, $mr_id, array $params) |
| 42 | + { |
| 43 | + return $this->put('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id).'/merge', $params); |
| 44 | + } |
| 45 | + |
| 46 | + public function showComments($project_id, $issue_id) |
| 47 | + { |
| 48 | + return $this->get('projects/'.urlencode($project_id).'/issues/'.urlencode($issue_id).'/notes'); |
| 49 | + } |
| 50 | + |
| 51 | + public function addComment($project_id, $mr_id, $note) |
| 52 | + { |
| 53 | + return $this->post('projects/'.urlencode($project_id).'/merge_request/'.urlencode($mr_id).'/comments', array( |
| 54 | + 'note' => $note |
| 55 | + )); |
| 56 | + } |
| 57 | +} |
0 commit comments