mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 03:30:34 +00:00
RequestParams base class for SearchIssuesRequest
This commit is contained in:
@@ -49,7 +49,7 @@ namespace Octokit
|
||||
public Task<IReadOnlyList<Issue>> SearchIssues(SearchIssuesRequest search)
|
||||
{
|
||||
Ensure.ArgumentNotNull(search, "search");
|
||||
return ApiConnection.GetAll<Issue>("search/issues".FormatUri(), search.Parameters);
|
||||
return ApiConnection.GetAll<Issue>("search/issues".FormatUri(), search.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -9,31 +10,34 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Searching Issues
|
||||
/// </summary>
|
||||
public class SearchIssuesRequest
|
||||
public class SearchIssuesRequest : RequestParameters
|
||||
{
|
||||
public SearchIssuesRequest(string term)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(term,"term");
|
||||
Term = term;
|
||||
Page = 1;
|
||||
PerPage = 100;
|
||||
Order = SortDirection.Descending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The search terms. This can be any combination of the supported repository search parameters:
|
||||
/// http://developer.github.com/v3/search/#search-code
|
||||
/// </summary>
|
||||
[Parameter(Key= "q")]
|
||||
public string Term { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For http://developer.github.com/v3/search/#search-issues
|
||||
/// Optional Sort field. One of comments, created, or updated. If not provided, results are sorted by best match.
|
||||
/// </summary>
|
||||
public string Sort { get; set; }
|
||||
//public string Sort { get; set; } //re-add laters
|
||||
|
||||
/// <summary>
|
||||
/// Optional Sort order if sort parameter is provided. One of asc or desc; the default is desc.
|
||||
/// </summary>
|
||||
public SortDirection? Order { get; set; }
|
||||
public SortDirection Order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Page of paginated results
|
||||
@@ -44,29 +48,5 @@ namespace Octokit
|
||||
/// Number of items per page
|
||||
/// </summary>
|
||||
public int PerPage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// get the params in the correct format...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Int32.ToString")]
|
||||
public System.Collections.Generic.IDictionary<string, string> Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
var d = new System.Collections.Generic.Dictionary<string, string>();
|
||||
d.Add("q", Term);
|
||||
d.Add("page", Page.ToString());
|
||||
d.Add("per_page ", PerPage.ToString());
|
||||
|
||||
if (Sort.IsNotBlank()) //only add if not blank
|
||||
d.Add("sort", Sort);
|
||||
|
||||
if (Order.HasValue)
|
||||
d.Add("order", Order.Value.ToString());
|
||||
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user