Skip to content

Instantly share code, notes, and snippets.

@mPanasiewicz
Created September 24, 2019 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mPanasiewicz/6c929ae289836540508d571e5d9b2892 to your computer and use it in GitHub Desktop.
Save mPanasiewicz/6c929ae289836540508d571e5d9b2892 to your computer and use it in GitHub Desktop.
class TwitterWelcomeMessageService
def self.call(*args)
new(*args).call
end
private
def call(twitter_handle)
client.update("@#{twitter_handle} welcome to 'Oranges & Apples', we hope you enjoy our juicy fruit!")
end
def client
@client ||= Twitter::REST::Client.new do |config|
config.consumer_key = "..."
config.consumer_secret = "..."
config.access_token = "..."
config.access_token_secret = "..."
end
end
end
class UsersController
def create
# ...
TwitterWelcomeMessageService.call(user.twitter_handle)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment