Commit 52746022 authored by Christophe Labouisse's avatar Christophe Labouisse
Browse files

Cleanup milestone:

@BREAKING CHANGES!i

- Make symetric constructor for group & project milestone
- Merge `Milestone::create*` method by removing thei
  `project_id`/`group_id` parameter

Issue #23
parent 71c00d51
Pipeline #158181 passed with stages
in 5 minutes and 52 seconds
......@@ -1198,32 +1198,15 @@ impl Gitlab {
}
/// Create a new milestone
pub fn create_milestone(
&self,
project: ProjectId,
milestone: Milestone,
) -> GitlabResult<Milestone> {
let path = format!("projects/{}/milestones", project);
self.create_generic_milestone(path, milestone)
}
pub fn create_milestone(&self, milestone: Milestone) -> GitlabResult<Milestone> {
let path: String;
/// Create a new group milestone
pub fn create_group_milestone(
&self,
group: GroupId,
milestone: Milestone,
) -> GitlabResult<Milestone> {
let path = format!("groups/{}/milestones", group);
self.create_generic_milestone(path, milestone)
}
if let Some(project) = milestone.project_id {
path = format!("projects/{}/milestones", project);
} else {
path = format!("groups/{}/milestones", milestone.group_id.unwrap());
}
fn create_generic_milestone(
&self,
path: String,
milestone: Milestone,
) -> GitlabResult<Milestone> {
let mut params: Vec<(&str, String)> = Vec::new();
params.push(("title", milestone.title));
......
......@@ -1189,7 +1189,7 @@ pub struct Milestone {
impl Milestone {
/// Create a new blank milestone: it needs at least the ProjectId and title
/// ProjectId and title are mandatory for new milestone API of Gitlab
pub fn new(project_id: ProjectId, title: String) -> Milestone {
pub fn new_for_project(project_id: ProjectId, title: String) -> Milestone {
Milestone {
id: MilestoneId::new(0),
iid: MilestoneInternalId::new(0),
......@@ -1206,7 +1206,7 @@ impl Milestone {
}
/// Create a new blank group milestone: it needs at least the GroupId and title
/// GroupId and title are mandatory for new milestone API of Gitlab
pub fn new_group(group_id: GroupId, title: String) -> Milestone {
pub fn new_for_group(group_id: GroupId, title: String) -> Milestone {
Milestone {
id: MilestoneId::new(0),
iid: MilestoneInternalId::new(0),
......
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