-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9fc3cc
commit 89c14b1
Showing
5 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Bitbucket.Cloud.Net/v2/PullRequests/BitbucketCloudClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Bitbucket.Cloud.Net.Common.Converters; | ||
using Bitbucket.Cloud.Net.Common.Models; | ||
using Bitbucket.Cloud.Net.Models; | ||
using Flurl.Http; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Bitbucket.Cloud.Net | ||
{ | ||
public partial class BitbucketCloudClient | ||
{ | ||
private IFlurlRequest GetPullRequestsUrl() => GetBaseUrl("2.0/pullrequests"); | ||
|
||
private IFlurlRequest GetPullRequestsUrl(string userName) => GetPullRequestsUrl().AppendPathSegment(userName); | ||
|
||
public async Task<IEnumerable<PullRequest>> GetPullRequestsAsync(string userName, int? maxPages = null, PullRequestStates? state = null, string q = null, string sort = null) | ||
{ | ||
var queryParamValues = new Dictionary<string, object> | ||
{ | ||
[nameof(state)] = PullRequestStatesConverter.ToString(state), | ||
[nameof(q)] = q, | ||
[nameof(sort)] = sort | ||
}; | ||
|
||
return await GetPagedResultsAsync(maxPages, queryParamValues, async qpv => | ||
await GetPullRequestsUrl(userName) | ||
.SetQueryParams(qpv) | ||
.GetJsonAsync<PagedResults<PullRequest>>() | ||
.ConfigureAwait(false)) | ||
.ConfigureAwait(false); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test/Bitbucket.Cloud.Net.Tests/v2/PullRequests/BitbucketCloudClientShould.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Bitbucket.Cloud.Net.Tests | ||
{ | ||
public partial class BitbucketCloudClientShould | ||
{ | ||
[Theory] | ||
[InlineData("luve")] | ||
public async Task GetPullRequestsAsync(string userName) | ||
{ | ||
var result = await _client.GetPullRequestsAsync(userName).ConfigureAwait(false); | ||
Assert.NotNull(result); | ||
} | ||
} | ||
} |