@@ -7,48 +7,79 @@ class MergeRequests extends AbstractApi
7
7
const STATE_OPENED = 'opened ' ;
8
8
const STATE_CLOSED = 'closed ' ;
9
9
10
+ const ORDER_BY = 'created_at ' ;
11
+ const SORT = 'asc ' ;
12
+
13
+ /**
14
+ * @param int $project_id
15
+ * @param int $page
16
+ * @param int $per_page
17
+ * @param string $state
18
+ * @param string $order_by
19
+ * @param string $sort
20
+ * @return mixed
21
+ */
22
+ public function getList ($ project_id , $ page , $ per_page , $ state = self ::STATE_ALL , $ order_by = self ::ORDER_BY , $ sort = self ::SORT )
23
+ {
24
+ return $ this ->get ($ this ->getProjectPath ($ project_id , 'merge_requests ' ), array (
25
+ 'page ' => $ page ,
26
+ 'per_page ' => $ per_page ,
27
+ 'state ' => $ state ,
28
+ 'order_by ' => $ order_by ,
29
+ 'sort ' => $ sort
30
+ ));
31
+ }
32
+
10
33
/**
11
34
* @param int $project_id
12
35
* @param int $page
13
36
* @param int $per_page
37
+ * @param string $order_by
38
+ * @param string $sort
14
39
* @return mixed
15
40
*/
16
- public function all ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE )
41
+ public function all ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self :: ORDER_BY , $ sort = self :: SORT )
17
42
{
18
- return $ this ->getMrList ($ project_id , $ page , $ per_page , self ::STATE_ALL );
43
+ return $ this ->getList ($ project_id , $ page , $ per_page , self ::STATE_ALL , $ order_by , $ sort );
19
44
}
20
45
21
46
/**
22
47
* @param int $project_id
23
48
* @param int $page
24
49
* @param int $per_page
50
+ * @param string $order_by
51
+ * @param string $sort
25
52
* @return mixed
26
53
*/
27
- public function merged ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE )
54
+ public function merged ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self :: ORDER_BY , $ sort = self :: SORT )
28
55
{
29
- return $ this ->getMrList ($ project_id , $ page , $ per_page , self ::STATE_MERGED );
56
+ return $ this ->getList ($ project_id , $ page , $ per_page , self ::STATE_MERGED , $ order_by , $ sort );
30
57
}
31
58
32
59
/**
33
60
* @param int $project_id
34
61
* @param int $page
35
62
* @param int $per_page
63
+ * @param string $order_by
64
+ * @param string $sort
36
65
* @return mixed
37
66
*/
38
- public function opened ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE )
67
+ public function opened ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self :: ORDER_BY , $ sort = self :: SORT )
39
68
{
40
- return $ this ->getMrList ($ project_id , $ page , $ per_page , self ::STATE_OPENED );
69
+ return $ this ->getList ($ project_id , $ page , $ per_page , self ::STATE_OPENED , $ order_by , $ sort );
41
70
}
42
71
43
72
/**
44
73
* @param int $project_id
45
74
* @param int $page
46
75
* @param int $per_page
76
+ * @param string $order_by
77
+ * @param string $sort
47
78
* @return mixed
48
79
*/
49
- public function closed ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE )
80
+ public function closed ($ project_id , $ page = 1 , $ per_page = self ::PER_PAGE , $ order_by = self :: ORDER_BY , $ sort = self :: SORT )
50
81
{
51
- return $ this ->getMrList ($ project_id , $ page , $ per_page , self ::STATE_CLOSED );
82
+ return $ this ->getList ($ project_id , $ page , $ per_page , self ::STATE_CLOSED , $ order_by , $ sort );
52
83
}
53
84
54
85
/**
@@ -141,20 +172,4 @@ public function changes($project_id, $mr_id)
141
172
{
142
173
return $ this ->get ($ this ->getProjectPath ($ project_id , 'merge_request/ ' .urlencode ($ mr_id ).'/changes ' ));
143
174
}
144
-
145
- /**
146
- * @param int $project_id
147
- * @param int $page
148
- * @param int $per_page
149
- * @param string $state
150
- * @return mixed
151
- */
152
- protected function getMrList ($ project_id , $ page , $ per_page , $ state = self ::STATE_ALL )
153
- {
154
- return $ this ->get ($ this ->getProjectPath ($ project_id , 'merge_requests ' ), array (
155
- 'page ' => $ page ,
156
- 'per_page ' => $ per_page ,
157
- 'state ' => $ state
158
- ));
159
- }
160
175
}
0 commit comments