Skip to content

Commit 6dbcd96

Browse files
DTeuchertnmklotas
authored andcommitted
Add missing issue weight and issue time statistics (#13)
* Add the issue weight in the model. Modify also the create and update request. * Add issue time statistics in the model. * Update test-case to check the response model of the non-nullable propery timestats.
1 parent b0f1ad9 commit 6dbcd96

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

src/GitLabApiClient/Models/Issues/Requests/CreateIssueRequest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,11 @@ public CreateIssueRequest(string projectId, string title)
9494
/// </summary>
9595
[JsonProperty("discussion_to_resolve")]
9696
public int? DiscussionToResolveId { get; set; }
97+
98+
/// <summary>
99+
/// The weight of an issue. Valid values are greater than or equal to 0.
100+
/// </summary>
101+
[JsonProperty("weight")]
102+
public int? Weight { get; set; }
97103
}
98104
}

src/GitLabApiClient/Models/Issues/Requests/UpdateIssueRequest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,11 @@ public UpdateIssueRequest(string projectId, int issueId)
9191
/// </summary>
9292
[JsonProperty("due_date")]
9393
public string DueDate { get; set; }
94+
95+
/// <summary>
96+
/// The weight of an issue. Valid values are greater than or equal to 0.
97+
/// </summary>
98+
[JsonProperty("weight")]
99+
public int? Weight { get; set; }
94100
}
95101
}

src/GitLabApiClient/Models/Issues/Responses/Issue.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,11 @@ public sealed class Issue : ModifiableObject
4343

4444
[JsonProperty("web_url")]
4545
public string WebUrl { get; set; }
46+
47+
[JsonProperty("weight")]
48+
public int? Weight { get; set; }
49+
50+
[JsonProperty("time_stats")]
51+
public IssueTimeStatistic TimeStats { get; set; }
4652
}
4753
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Newtonsoft.Json;
2+
3+
namespace GitLabApiClient.Models.Issues.Responses
4+
{
5+
public class IssueTimeStatistic
6+
{
7+
8+
[JsonProperty("time_estimate")]
9+
public int TimeEstimate { get; set; }
10+
11+
[JsonProperty("total_time_spent")]
12+
public int TotalTimeSpent { get; set; }
13+
14+
[JsonProperty("human_time_estimate")]
15+
public string HumanTimeEstimate { get; set; }
16+
17+
[JsonProperty("human_total_time_spent")]
18+
public string HumanTotalTimeSpent { get; set; }
19+
}
20+
}

test/GitLabApiClient.Test/IssuesClientTest.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public async Task CreatedIssueCanBeUpdated()
3131
Labels = new[] { "Label1" },
3232
MilestoneId = 2,
3333
DiscussionToResolveId = 3,
34-
MergeRequestIdToResolveDiscussions = 4
34+
MergeRequestIdToResolveDiscussions = 4,
35+
Weight = 3
3536
});
3637

3738
//act
@@ -42,7 +43,8 @@ public async Task CreatedIssueCanBeUpdated()
4243
Description = "Description11",
4344
Labels = new[] { "Label11" },
4445
Title = "Title11",
45-
MilestoneId = 22
46+
MilestoneId = 22,
47+
Weight = 33
4648
});
4749

4850
//assert
@@ -51,7 +53,8 @@ public async Task CreatedIssueCanBeUpdated()
5153
i.Confidential == false &&
5254
i.Description == "Description11" &&
5355
i.Labels.SequenceEqual(new[] { "Label11" }) &&
54-
i.Title == "Title11");
56+
i.Title == "Title11" &&
57+
i.Weight == 33);
5558
}
5659

5760
[Fact]
@@ -81,7 +84,10 @@ public async Task CreatedIssueCanBeListedFromProject()
8184
var listedIssues = await _sut.GetAsync(TestProjectTextId, o => o.Filter = title);
8285

8386
//assert
84-
listedIssues.Single().Title.Should().Be(title);
87+
listedIssues.Single().Should().Match<Issue>(i =>
88+
i.ProjectId == TestProjectTextId &&
89+
i.Title == title &&
90+
i.TimeStats != null);
8591
}
8692

8793
[Fact]

0 commit comments

Comments
 (0)