Skip to content

Commit 6d6d530

Browse files
committed
Added method to get overview with sort, limit, fromTime parameters
1 parent a3712a7 commit 6d6d530

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

RedditSharp/Things/RedditUser.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ public Listing<Subreddit> SubscribedSubreddits
111111
}
112112
}
113113

114+
/// <summary>
115+
/// Get a listing of comments and posts from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/>
116+
/// and limited to <paramref name="limit"/>.
117+
/// </summary>
118+
/// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param>
119+
/// <param name="limit">How many comments to fetch per request. Max is 100.</param>
120+
/// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param>
121+
/// <returns>The listing of comments requested.</returns>
122+
public Listing<VotableThing> GetOverview(Sort sorting = Sort.New, int limit = 25, FromTime fromTime = FromTime.All)
123+
{
124+
if ((limit < 1) || (limit > MAX_LIMIT))
125+
throw new ArgumentOutOfRangeException("limit", "Valid range: [1," + MAX_LIMIT + "]");
126+
string overviewUrl = string.Format(OverviewUrl, Name);
127+
overviewUrl += string.Format("?sort={0}&limit={1}&t={2}", Enum.GetName(typeof(Sort), sorting), limit, Enum.GetName(typeof(FromTime), fromTime));
128+
129+
return new Listing<VotableThing>(Reddit, overviewUrl, WebAgent);
130+
}
131+
114132
/// <summary>
115133
/// Get a listing of comments from the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/>
116134
/// and limited to <paramref name="limit"/>.

0 commit comments

Comments
 (0)