Class: Sapphire::RestClientReddit

Inherits:
Object
  • Object
show all
Defined in:
lib/apiclients/restclient.rb

Constant Summary collapse

BASE_URL =
'https://www.reddit.com'

Instance Method Summary collapse

Constructor Details

#initializeRestClientReddit

Returns a new instance of RestClientReddit.



7
8
9
# File 'lib/apiclients/restclient.rb', line 7

def initialize
  @headers = { params: { limit: 10, sort: 'hot' } }
end

Instance Method Details

#get_posts(subreddit) ⇒ Object



11
12
13
14
15
# File 'lib/apiclients/restclient.rb', line 11

def get_posts(subreddit)
  url = "#{BASE_URL}/r/#{subreddit}/hot.json"
  response = RestClient.get(url, @headers)
  parse_response(response)
end