Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php namespace Gitlab\Api;
class MergeRequests extends AbstractApi
{
const STATE_ALL = 'all';
const STATE_MERGED = 'merged';
const STATE_OPENED = 'opened';
const STATE_CLOSED = 'closed';
const ORDER_BY = 'created_at';
const SORT = 'asc';
/**
* @param int $project_id
* @param string $state
* @param int $page
* @param int $per_page
* @param string $order_by
* @param string $sort
* @return mixed
*/
public function getList($project_id, $state = self::STATE_ALL, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
{
return $this->get($this->getProjectPath($project_id, 'merge_requests'), array(
'page' => $page,
'per_page' => $per_page,
'state' => $state,
'order_by' => $order_by,
'sort' => $sort
));
}
/**
* @param int $project_id
* @param int $page
* @param int $per_page
* @param string $order_by
* @param string $sort
* @return mixed
*/
public function all($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
{
return $this->getList($project_id, self::STATE_ALL, $page, $per_page, $order_by, $sort);
}
/**
* @param int $project_id
* @param int $page
* @param int $per_page
* @param string $order_by
* @param string $sort
* @return mixed
*/
public function merged($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
{
return $this->getList($project_id, self::STATE_MERGED, $page, $per_page, $order_by, $sort);
}
/**
* @param int $project_id
* @param int $page
* @param int $per_page
* @param string $order_by
* @param string $sort
* @return mixed
*/
public function opened($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
{
return $this->getList($project_id, self::STATE_OPENED, $page, $per_page, $order_by, $sort);
}
/**
* @param int $project_id
* @param int $page
* @param int $per_page
* @param string $order_by
* @param string $sort
* @return mixed
*/
public function closed($project_id, $page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
{
return $this->getList($project_id, self::STATE_CLOSED, $page, $per_page, $order_by, $sort);
}
/**
* @param int $project_id
* @param int $mr_id
* @return mixed
*/
public function show($project_id, $mr_id)
{
return $this->get($this->getProjectPath($project_id, 'merge_request/'.$this->encodePath($mr_id)));
}
/**
* @param int $project_id
* @param string $source
* @param string $target
* @param string $title
* @param int $assignee
* @param int $target_project_id
* @param string $description
* @return mixed
*/
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null)
{
return $this->post($this->getProjectPath($project_id, 'merge_requests'), array(
'source_branch' => $source,
'target_branch' => $target,
'title' => $title,
'assignee_id' => $assignee,
'target_project_id' => $target_project_id,
'description' => $description
));
}
/**
* @param int $project_id
* @param int $mr_id
* @param array $params
* @return mixed
*/
public function update($project_id, $mr_id, array $params)
{
return $this->put($this->getProjectPath($project_id, 'merge_request/'.$this->encodePath($mr_id)), $params);
}
/**
* @param int $project_id
* @param int $mr_id
* @param string $message
* @return mixed
*/
public function merge($project_id, $mr_id, $message = null)
{
if (is_array($message)) {
$params = $message;
} else {
$params = array('merge_commit_message' => $message);
}
return $this->put($this->getProjectPath($project_id, 'merge_request/'.$this->encodePath($mr_id).'/merge'), $params);
}
/**
* @param int $project_id
* @param int $mr_id
* @return mixed
*/
public function showComments($project_id, $mr_id)
{
return $this->get($this->getProjectPath($project_id, 'merge_request/'.$this->encodePath($mr_id).'/comments'));
}
/**
* @param int $project_id
* @param int $mr_id
* @param int $note
* @return mixed
*/
public function addComment($project_id, $mr_id, $note)
{
return $this->post($this->getProjectPath($project_id, 'merge_request/'.$this->encodePath($mr_id).'/comments'), array(
'note' => $note
));
}
/**
* @param int $project_id
* @param int $mr_id
* @return mixed
*/
public function changes($project_id, $mr_id)
{
return $this->get($this->getProjectPath($project_id, 'merge_request/'.$this->encodePath($mr_id).'/changes'));
}
}