Skip to content

Commit 7f497dc

Browse files
committed
Add GetDiffData method
Add GetDiffData method so that clients can request PR diff data using RestClient with authentication.
1 parent 3ebf19b commit 7f497dc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Git.hub/PullRequest.cs

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using RestSharp;
33
using System.Collections.Generic;
4+
using System.Threading.Tasks;
45

56
namespace Git.hub
67
{
@@ -89,6 +90,23 @@ public List<PullRequestCommit> GetCommits()
8990
return _client.GetList<PullRequestCommit>(request);
9091
}
9192

93+
/// <summary>
94+
/// Retrieves diff data for all Commits associated with this pull request.
95+
/// </summary>
96+
/// <param name="diffUrl">URL for diff data to retrieve</param>
97+
/// <returns><see cref="string"/> that contains diff data</returns>
98+
public async Task<string> GetDiffData(string diffUrl)
99+
{
100+
if (string.IsNullOrEmpty(diffUrl))
101+
{
102+
throw new ArgumentException("Empty diff URL: ", nameof(diffUrl));
103+
}
104+
105+
var request = new RestRequest(diffUrl);
106+
var diffData = await _client.ExecuteGetAsync<string>(request);
107+
return diffData.Content;
108+
}
109+
92110
public Issue ToIssue()
93111
{
94112
return new Issue { _client = _client, Repository = Repository, Number = Number };

0 commit comments

Comments
 (0)