class TweetSearch::TwitterClient

Constants

API_BASE
API_VERSION
SEARCH_TWEET_ENDPOINT

Public Class Methods

authorization_header() click to toggle source
# File lib/tweetsearch/twitter_client.rb, line 25
def self.authorization_header
  @authorization_header ||= { Authorization: "Bearer #{config[:access_token]}" }
end
config() click to toggle source
# File lib/tweetsearch/twitter_client.rb, line 15
def self.config
  @config ||= { access_token: ENV['ACCESS_TOKEN'] }
end
config=(conf) click to toggle source
# File lib/tweetsearch/twitter_client.rb, line 11
def self.config=(conf)
  @config ? @config.update(conf) : (@config = conf)
end
search_tweets(*tags) click to toggle source
# File lib/tweetsearch/twitter_client.rb, line 19
def self.search_tweets(*tags)
  HTTParty.get(SEARCH_TWEET_ENDPOINT,
               headers: authorization_header,
               query: { q: tags.join(' ') }).parsed_response['statuses']
end