Last active
December 18, 2015 10:09
-
-
Save stympy/5765996 to your computer and use it in GitHub Desktop.
Easy post to a campfire room using faraday
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 Campfire | |
def initialize(domain, token) | |
@client = Faraday.new(:url => "https://#{domain}.campfirenow.com") do |faraday| | |
faraday.basic_auth(token, 'X') | |
faraday.request :url_encoded | |
faraday.adapter Faraday.default_adapter | |
end | |
end | |
def speak(room, message) | |
@client.post do |p| | |
p.url "/room/#{room}/speak.json" | |
p.headers['Content-Type'] = 'application/json' | |
p.body = { message: { body: message } }.to_json | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should package this as a Gem!