class SlackCi::SlackCiApi

SlackAPI Class

Public Class Methods

new(team, token) click to toggle source

Initialize the URI for the team and Integration Token.

# File lib/slack_ci/slack_ci_api.rb, line 8
def initialize(team, token)
  @uri = URI.parse("https://#{team}.slack.com/services/hooks/incoming-webhook?token=#{token}")
  @header = { 'Content-Type' => 'text/json' }
end

Public Instance Methods

say(message) click to toggle source

Say Method to create an HTTP Post request with a JSON string as the post request body.

# File lib/slack_ci/slack_ci_api.rb, line 15
def say(message)
  http = Net::HTTP.new(@uri.host, @uri.port)
  http.use_ssl = true
  req = Net::HTTP::Post.new(@uri.request_uri, @header)
  req.body = message.to_json
  http.request(req).code
end