Skip to content

Commit 0b4e539

Browse files
committed
added Issue.CreateComment
1 parent 3d9024f commit 0b4e539

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Git.hub/Issue.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,30 @@ public class Issue
1616

1717
public List<IssueComment> GetComments()
1818
{
19-
var request = new RestRequest("/repos/{user}/{repo}/issues/{pull}/comments");
19+
var request = new RestRequest("/repos/{user}/{repo}/issues/{issue}/comments");
2020
request.AddUrlSegment("user", Repository.Owner.Login);
2121
request.AddUrlSegment("repo", Repository.Name);
22-
request.AddUrlSegment("pull", Number.ToString());
22+
request.AddUrlSegment("issue", Number.ToString());
2323

2424
return _client.Get<List<IssueComment>>(request).Data;
2525
}
26+
27+
public IssueComment CreateComment(string body)
28+
{
29+
if (_client.Authenticator == null)
30+
throw new ArgumentException("no authentication details");
31+
32+
var request = new RestRequest("/repos/{user}/{repo}/issues/{issue}/comments");
33+
request.AddUrlSegment("user", Repository.Owner.Login);
34+
request.AddUrlSegment("repo", Repository.Name);
35+
request.AddUrlSegment("issue", Number.ToString());
36+
37+
request.RequestFormat = DataFormat.Json;
38+
request.AddBody(new {
39+
body = body
40+
});
41+
return _client.Post<IssueComment>(request).Data;
42+
}
2643
}
2744

2845
public class IssueComment

0 commit comments

Comments
 (0)