Class: TweetSearch::TwitterClient
- Inherits:
-
Object
- Object
- TweetSearch::TwitterClient
- Defined in:
- lib/tweetsearch/twitter_client.rb
Constant Summary collapse
- API_BASE =
'https://api.twitter.com/'
- API_VERSION =
'1.1/'
- SEARCH_TWEET_ENDPOINT =
URI.join(API_BASE, API_VERSION, 'search/tweets.json')
Class Method Summary collapse
- .authorization_header ⇒ Object
- .config ⇒ Object
- .config=(conf) ⇒ Object
- .search_tweets(*tags) ⇒ Object
Class Method Details
.authorization_header ⇒ Object
25 26 27 |
# File 'lib/tweetsearch/twitter_client.rb', line 25 def self. @authorization_header ||= { Authorization: "Bearer #{config[:access_token]}" } end |
.config ⇒ Object
15 16 17 |
# File 'lib/tweetsearch/twitter_client.rb', line 15 def self.config @config ||= { access_token: ENV['ACCESS_TOKEN'] } end |
.config=(conf) ⇒ Object
11 12 13 |
# File 'lib/tweetsearch/twitter_client.rb', line 11 def self.config=(conf) @config ? @config.update(conf) : (@config = conf) end |
.search_tweets(*tags) ⇒ Object
19 20 21 22 23 |
# File 'lib/tweetsearch/twitter_client.rb', line 19 def self.search_tweets(*) HTTParty.get(SEARCH_TWEET_ENDPOINT, headers: , query: { q: .join(' ') }).parsed_response['statuses'] end |