Class: RedditApi::Requestor
- Inherits:
-
Object
- Object
- RedditApi::Requestor
- Defined in:
- lib/reddit_api/requestor.rb
Instance Method Summary collapse
- #build(query) ⇒ Object
-
#initialize(args = {}) ⇒ Requestor
constructor
A new instance of Requestor.
Constructor Details
#initialize(args = {}) ⇒ Requestor
Returns a new instance of Requestor.
5 6 7 8 9 10 11 12 13 |
# File 'lib/reddit_api/requestor.rb', line 5 def initialize(args = {}) @agent = ENV["REDDIT_AGENT"] @base_url = "https://oauth.reddit.com/" @client = args.fetch(:client, HTTParty) @id = ENV["REDDIT_ID"] @password = ENV["REDDIT_PASSWORD"] @secret = ENV["REDDIT_SECRET"] @username = ENV["REDDIT_USERNAME"] end |
Instance Method Details
#build(query) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/reddit_api/requestor.rb', line 15 def build(query) url = base_url + query.endpoint headers = generate_headers api_query = generate_query(query) [url, { headers: headers, query: api_query }] end |