From 7f497dc617eaed9e1333b82438714e8772427717 Mon Sep 17 00:00:00 2001 From: Damit Senanayake Date: Sat, 1 May 2021 23:08:10 -0700 Subject: [PATCH] Add GetDiffData method Add GetDiffData method so that clients can request PR diff data using RestClient with authentication. --- Git.hub/PullRequest.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Git.hub/PullRequest.cs b/Git.hub/PullRequest.cs index 90d1368..e7dd219 100644 --- a/Git.hub/PullRequest.cs +++ b/Git.hub/PullRequest.cs @@ -1,6 +1,7 @@ using System; using RestSharp; using System.Collections.Generic; +using System.Threading.Tasks; namespace Git.hub { @@ -89,6 +90,23 @@ public List GetCommits() return _client.GetList(request); } + /// + /// Retrieves diff data for all Commits associated with this pull request. + /// + /// URL for diff data to retrieve + /// that contains diff data + public async Task GetDiffData(string diffUrl) + { + if (string.IsNullOrEmpty(diffUrl)) + { + throw new ArgumentException("Empty diff URL: ", nameof(diffUrl)); + } + + var request = new RestRequest(diffUrl); + var diffData = await _client.ExecuteGetAsync(request); + return diffData.Content; + } + public Issue ToIssue() { return new Issue { _client = _client, Repository = Repository, Number = Number };