Created
May 14, 2017 19:29
-
-
Save jeanpaulsio/e08330de2921cbbaa939da47a503c22a to your computer and use it in GitHub Desktop.
Twitter Wrapper Refactored
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterWrapper | |
attr_accessor :twitter_handle, :message, :client | |
def initialize(token=ENV['TWITTER_ACCESS_TOKEN'], secret=ENV['TWITTER_ACCESS_TOKEN_SECRET']) | |
boot_twitter(token, secret) | |
end | |
def tweet | |
@client.update("@#{twitter_handle} #{message}") | |
end | |
private | |
def boot_twitter(token, secret) | |
@client = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV['TWITTER_CONSUMER_KEY'] | |
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET'] | |
config.access_token = token | |
config.access_token_secret = secret | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment