diff --git a/.gitignore b/.gitignore index b827cff..262e733 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /spec/reports/ /spec/examples.txt /tmp/ +.idea/ diff --git a/lib/redd/models/session.rb b/lib/redd/models/session.rb index 96b95bd..a5acff0 100644 --- a/lib/redd/models/session.rb +++ b/lib/redd/models/session.rb @@ -193,6 +193,34 @@ def my_subreddits(type, **params) def trending_subreddits client.get('/api/trending_subreddits').body end + + # Return a listing of subreddits + # + # @param order ['default', 'popular', 'new', 'gold'] the order of returned subreddits + # @param params [Hash] a list of optional params to be send with the request + # @option params [String] :after return results after the given fullname + # @option params [String] :before return results before the given fullname + # @option params [Integer] :count (0) the number of items already seen in the listing + # @option params [1..100] :limit (25) the maximum number of things to return + # @return [Listing] + def list_subreddits(order = 'default', **params) + client.model(:get, "/subreddits/#{order}", params) + end + + # Search subreddits + # + # @param query [String] the search query + # @param params [Hash] the search params + # @option params [String] :after return results after the given fullname + # @option params [String] :before return results before the given fullname + # @option params [Integer] :count the number of items already seen in the listing + # @option params [1..100] :limit the maximum number of things to return + # @option params [:relevance, :activity] :sort the sort order of results + # @return [Listing] the search results + def search_subreddits(query, **params) + params[:q] = query + client.model(:get, '/subreddits/search', params) + end end end end diff --git a/lib/redd/models/subreddit.rb b/lib/redd/models/subreddit.rb index d792482..9912fb9 100644 --- a/lib/redd/models/subreddit.rb +++ b/lib/redd/models/subreddit.rb @@ -620,6 +620,14 @@ def delete_image(upload_type:, image_name: nil) # @return [Boolean] whether images are allowed property :allow_images?, from: :allow_images + # @!attribute [r] allow_videos? + # @return [Boolean] whether videos are allowed + property :allow_videos?, from: :allow_videos + + # @!attribute [r] allow_videogifs? + # @return [Boolean] whether videogifs are allowed + property :allow_videogifs?, from: :allow_videogifs + # @!attribute [r] show_media_preview # @return [Boolean] whether media previews are shown property :show_media_preview?, from: :show_media_preview