@@ -13,6 +13,7 @@ public class RedditUser : Thing
13
13
private const string SubscribedSubredditsUrl = "/subreddits/mine.json" ;
14
14
private const string LikedUrl = "/user/{0}/liked.json" ;
15
15
private const string DislikedUrl = "/user/{0}/disliked.json" ;
16
+ private const string SavedUrl = "/user/{0}/saved.json" ;
16
17
17
18
private const int MAX_LIMIT = 100 ;
18
19
@@ -164,6 +165,24 @@ public Listing<Post> GetPosts(Sort sorting = Sort.New, int limit = 25, FromTime
164
165
return new Listing < Post > ( Reddit , linksUrl , WebAgent ) ;
165
166
}
166
167
168
+ /// <summary>
169
+ /// Get a listing of comments and posts saved by the user sorted by <paramref name="sorting"/>, from time <paramref name="fromTime"/>
170
+ /// and limited to <paramref name="limit"/>.
171
+ /// </summary>
172
+ /// <param name="sorting">How to sort the comments (hot, new, top, controversial).</param>
173
+ /// <param name="limit">How many comments to fetch per request. Max is 100.</param>
174
+ /// <param name="fromTime">What time frame of comments to show (hour, day, week, month, year, all).</param>
175
+ /// <returns>The listing of posts and/or comments requested that the user saved.</returns>
176
+ public Listing < VotableThing > GetSaved ( Sort sorting = Sort . New , int limit = 25 , FromTime fromTime = FromTime . All )
177
+ {
178
+ if ( ( limit < 1 ) || ( limit > MAX_LIMIT ) )
179
+ throw new ArgumentOutOfRangeException ( "limit" , "Valid range: [1," + MAX_LIMIT + "]" ) ;
180
+ string savedUrl = string . Format ( SavedUrl , Name ) ;
181
+ savedUrl += string . Format ( "?sort={0}&limit={1}&t={2}" , Enum . GetName ( typeof ( Sort ) , sorting ) , limit , Enum . GetName ( typeof ( FromTime ) , fromTime ) ) ;
182
+
183
+ return new Listing < VotableThing > ( Reddit , savedUrl , WebAgent ) ;
184
+ }
185
+
167
186
public override string ToString ( )
168
187
{
169
188
return Name ;
0 commit comments