Merge pull request #1096 from Sarmad93/new-parameters-on-ListYourRepository

added new parameters to RepositoryRequest.cs
This commit is contained in:
Phil Haack
2016-02-11 15:50:11 -08:00
3 changed files with 126 additions and 1 deletions
@@ -376,6 +376,47 @@ namespace Octokit.Tests.Clients
Arg.Is<Dictionary<string, string>>(d =>
d["type"] == "member" && d["sort"] == "updated" && d["direction"] == "asc"));
}
[Fact]
public void CanFilterByVisibility()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var request = new RepositoryRequest
{
Visibility = RepositoryVisibility.Private
};
client.GetAllForCurrent(request);
connection.Received()
.GetAll<Repository>(
Arg.Is<Uri>(u => u.ToString() == "user/repos"),
Arg.Is<Dictionary<string, string>>(d =>
d["visibility"] == "private"));
}
[Fact]
public void CanFilterByAffiliation()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var request = new RepositoryRequest
{
Affiliation = RepositoryAffiliation.Owner,
Sort = RepositorySort.FullName
};
client.GetAllForCurrent(request);
connection.Received()
.GetAll<Repository>(
Arg.Is<Uri>(u => u.ToString() == "user/repos"),
Arg.Is<Dictionary<string, string>>(d =>
d["affiliation"] == "owner" && d["sort"] == "full_name"));
}
}
public class TheGetAllForUserMethod
+1 -1
View File
@@ -10,7 +10,7 @@ namespace Octokit
public static class UriExtensions
{
/// <summary>
/// Merge a dictionary of valeus with an existing <see cref="Uri"/>
/// Merge a dictionary of values with an existing <see cref="Uri"/>
/// </summary>
/// <param name="uri">Original request Uri</param>
/// <param name="parameters">Collection of key-value pairs</param>
@@ -37,6 +37,22 @@ namespace Octokit
/// </value>
public SortDirection Direction { get; set; }
/// <summary>
/// Gets or sets the visibility property.
/// </summary>
/// <value>
/// The visibility.
/// </value>
public RepositoryVisibility Visibility { get; set; }
/// <summary>
/// Gets or sets the affiliation property.
/// </summary>
/// <value>
/// The affiliation.
/// </value>
public RepositoryAffiliation Affiliation { get; set; }
internal string DebuggerDisplay
{
get
@@ -103,4 +119,72 @@ namespace Octokit
[Parameter(Value = "full_name")]
FullName
}
/// <summary>
/// The properties that repositories can be visible by.
/// </summary>
public enum RepositoryVisibility
{
/// <summary>
/// Returns only public repositories
/// </summary>
Public,
/// <summary>
/// Returns only private repositories
/// </summary>
Private,
/// <summary>
/// Return both public and private repositories
/// </summary>
All,
}
/// <summary>
/// The properties that repositories can be affiliated by.
/// </summary>
public enum RepositoryAffiliation
{
/// <summary>
/// Repositories that are owned by the authenticated user
/// </summary>
Owner,
/// <summary>
/// Repositories that the user has been added to as a collaborator.
/// </summary>
Collaborator,
/// <summary>
/// Repositories that the user has access to through being a member of an organization.
/// This includes every repository on every team that the user is on.
/// </summary>
[Parameter(Value = "organization_member")]
OrganizationMember,
/// <summary>
/// Return repositories that are owned by authenticated user and added to as a collaborator.
/// </summary>
[Parameter(Value = "owner, collaborator")]
OwnerAndCollaborator,
/// <summary>
/// Return repositories that are owned by authenticated user or user is a organization member.
/// </summary>
[Parameter(Value = "owner, organization_member")]
OwnerAndOrganizationMember,
/// <summary>
/// Return repositories that user has been added as collaborator or user is a organization member.
/// </summary>
[Parameter(Value = "collaborator, organization_member")]
CollaboratorAndOrganizationMember,
/// <summary>
/// Returns all repositories where user is owner,collaborator or organization member.
/// </summary>
[Parameter(Value = "owner, collaborator, organization_member")]
All
}
}