Last active
November 3, 2015 17:33
-
-
Save jkronz/fdd095300145fc6d6faa to your computer and use it in GitHub Desktop.
Cat Facts Slack Integration
This file contains hidden or 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 CatFact | |
def self.fact | |
response = Typhoeus.get("http://catfacts-api.appspot.com/api/facts") | |
JSON.parse(response.body)['facts'].first | |
end | |
end |
This file contains hidden or 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
def show | |
url = "https://yourteam.slack.com/services/hooks/incoming-webhook?token=#{some_api_token}" | |
response = Typhoeus.post(url, body: {"channel" => "##{params[:channel_name]}", "text" => CatFact.fact}.to_json) | |
render text: '', status: :ok | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment