Class: Mechmarket::Client
- Inherits:
-
Object
- Object
- Mechmarket::Client
- Includes:
- HTTParty
- Defined in:
- lib/mechmarket/client.rb
Constant Summary collapse
- USER_AGENT =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'
Instance Method Summary collapse
Instance Method Details
#posts ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mechmarket/client.rb', line 10 def posts response = get('/r/mechmarket/new.json') if response.code == 200 response.parsed_response['data']['children'].map { |child| child['data'] }.map do |raw| Post.new( 'reddit_id' => raw['id'], 'created_utc' => raw['created_utc'], 'url' => raw['url'], 'author' => raw['author'], 'title' => raw['title'], 'body' => raw['selftext'] ) end else # Log error. puts response.parsed_response.inspect [] end end |