An update will be applied December 9th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit c8361223 authored by Makoto Nakashima's avatar Makoto Nakashima
Browse files

Use additional parameter instead of three methods.

parent c3e90190
......@@ -57,6 +57,27 @@ pub struct CommitStatusInfo<'a> {
pub description: Option<&'a str>,
}
#[derive(Debug)]
/// Optional information for merge requests.
pub enum MergeRequestStateFilter {
/// Get the opened/reopened merge requests.
Opened,
/// Get the closes merge requests.
Closed,
/// Get the merged merge requests.
Merged,
}
impl MergeRequestStateFilter {
fn as_str(&self) -> &str {
use self::MergeRequestStateFilter::*;
match *self {
Opened => "opened",
Closed => "closed",
Merged => "merged",
}
}
}
impl Gitlab {
/// Create a new Gitlab API representation.
///
......@@ -358,29 +379,11 @@ impl Gitlab {
self._get_paged(&format!("projects/{}/merge_requests", project))
}
/// Get the opened/reopened merge requests for a project.
pub fn opened_merge_requests(&self, project: ProjectId) -> GitlabResult<Vec<MergeRequest>> {
/// Get the merge requests with a given state.
pub fn merge_requests_with_state(&self, project: ProjectId, state: MergeRequestStateFilter) -> GitlabResult<Vec<MergeRequest>> {
let mut req = try!(self._mkrequest(&format!("projects/{}/merge_requests", project)));
req.param("state", "opened");
Self::_get_paged_req(req)
}
/// Get the closed merge requests for a project.
pub fn closed_merge_requests(&self, project: ProjectId) -> GitlabResult<Vec<MergeRequest>> {
let mut req = try!(self._mkrequest(&format!("projects/{}/merge_requests", project)));
req.param("state", "closed");
Self::_get_paged_req(req)
}
/// Get the merged merge requests for a project.
pub fn merged_merge_requests(&self, project: ProjectId) -> GitlabResult<Vec<MergeRequest>> {
let mut req = try!(self._mkrequest(&format!("projects/{}/merge_requests", project)));
req.param("state", "merged");
req.param("state", state.as_str());
Self::_get_paged_req(req)
}
......
......@@ -31,6 +31,7 @@ pub mod hooks;
pub use error::Error;
pub use gitlab::CommitStatusInfo;
pub use gitlab::MergeRequestStateFilter;
pub use gitlab::Gitlab;
pub use gitlab::GitlabResult;
pub use types::*;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment