Last active
August 29, 2015 14:16
-
-
Save j-mcnally/0e30bb4a7fa14e01c224 to your computer and use it in GitHub Desktop.
Automate Slack invites, for slack chat / community websites. Used by http://struct.tv
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
module Slack | |
class Invite | |
def call(options) | |
email = options[:email] | |
throw "You must call this method with an email" unless email.present? | |
invite = agent.post("https://#{ENV['SLACK_SUBDOMAIN']}.slack.com/api/users.admin.invite?t=#{Time.now.to_i}", | |
{"email" => email, | |
"token" => ENV['SLACK_API_TOKEN'], | |
"set_active" => "true", | |
"_attempts" => "1" | |
} | |
) | |
return invite.body | |
end | |
def agent | |
@agent ||= Mechanize.new | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you meant
raise
on line 5, notthrow