Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit baec759

Browse files
author
Hariharan Subramanian
committed
Implemented missing methods on Tags 💡
1 parent 18a38cf commit baec759

File tree

6 files changed

+50
-6
lines changed

6 files changed

+50
-6
lines changed

‎StackExchange.NET/StackExchange.NET/Clients/TagsClient.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,26 @@ BaseResponse<TagSynonyms> ITags.GetSynonymsForTags(List<string> tags, TagFilter
9696

9797
BaseResponse<TagScore> ITags.GetTopAnswerersPosts(string tag, string period)
9898
{
99-
throw new System.NotImplementedException();
99+
var url = ApiUrlBuilder
100+
.Initialize(_apiKey)
101+
.ForClient(ClientType.Tags)
102+
.WithTagAndPeriod(tag, $"top-answerers/{period}")
103+
.GetApiUrl();
104+
105+
var response = _httpClient.GetAsync(url).Result.ReadAsJsonAsync<Data<TagScore>>().ValidateApiResponse();
106+
return response;
100107
}
101108

102109
BaseResponse<TagScore> ITags.GetTopAskers(string tag, string period)
103110
{
104-
throw new System.NotImplementedException();
111+
var url = ApiUrlBuilder
112+
.Initialize(_apiKey)
113+
.ForClient(ClientType.Tags)
114+
.WithTagAndPeriod(tag, $"top-askers/{period}")
115+
.GetApiUrl();
116+
117+
var response = _httpClient.GetAsync(url).Result.ReadAsJsonAsync<Data<TagScore>>().ValidateApiResponse();
118+
return response;
105119
}
106120

107121
BaseResponse<TagWiki> ITags.GetTagWiki(List<string> tags)

‎StackExchange.NET/StackExchange.NET/Helpers/ApiUrlBuilder.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public ApiUrlBuilder WithIds(List<string> ids, string route = "")
7070
return this;
7171
}
7272

73+
public ApiUrlBuilder WithTagAndPeriod(string tag, string period)
74+
{
75+
MakeSure.ArgumentNotNull(tag,nameof(tag));
76+
MakeSure.ArgumentNotNull(period,nameof(period));
77+
78+
_apiUrl = _apiUrl + $"{tag}/{period}";
79+
return this;
80+
}
81+
7382
public string GetApiUrl()
7483
{
7584
_apiUrl = $"{_apiUrl}?key={_apiKey}&{_filter}";

‎StackExchange.NET/StackExchange.NET/Helpers/IApiUrlHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public interface IApiUrlHelper
88
ApiUrlBuilder ForClient(ClientType type, string route = "");
99
ApiUrlBuilder WithFilter(Filter filter, string inName = "");
1010
ApiUrlBuilder WithIds(List<string> ids, string route = "");
11+
ApiUrlBuilder WithTagAndPeriod(string tag, string period);
1112
}
1213
}

‎StackExchange.NET/StackExchange.NET/Interfaces/ISuggestedEdits.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace StackExchange.NET.Interfaces
55
{
6+
/// <summary>
7+
/// The SuggestedEdits interface which lists all possible operations.
8+
/// </summary>
69
public interface ISuggestedEdits
710
{
811
/// <summary>

‎StackExchange.NET/StackExchange.NET/Interfaces/ITags.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace StackExchange.NET.Interfaces
55
{
6+
/// <summary>
7+
/// The Tags interface which lists all possible operations.
8+
/// </summary>
69
public interface ITags
710
{
811
/// <summary>
@@ -50,14 +53,16 @@ public interface ITags
5053
/// <returns></returns>
5154
BaseResponse<TagSynonyms> GetSynonymsForTags(List<string> tags, TagFilter filter);
5255
/// <summary>
53-
/// Get the top answer posters in a specific tag, either in the last month or for all time
56+
/// Get the top answer posters in a specific tag, either in the last month or for all time.
57+
/// Enter any tag for param1 and period can be all_time or month
5458
/// </summary>
5559
/// <param name="tag"></param>
5660
/// <param name="period"></param>
5761
/// <returns></returns>
5862
BaseResponse<TagScore> GetTopAnswerersPosts(string tag, string period);
5963
/// <summary>
60-
/// Get the top question askers in a specific tag, either in the last month or for all time
64+
/// Get the top question askers in a specific tag, either in the last month or for all time.
65+
/// Enter any tag for param1 and period can be all_time or month
6166
/// </summary>
6267
/// <param name="tag"></param>
6368
/// <param name="period"></param>

‎StackExchange.NET/StackExchange.NET/StackExchange.NET.xml

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /