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