Class: Stenographer::Outputs::SlackOutput

Inherits:
BaseOutput
  • Object
show all
Defined in:
lib/stenographer/outputs/slack_output.rb

Constant Summary collapse

BASE_URI =
'https://slack.com/api/'

Instance Method Summary collapse

Methods inherited from BaseOutput

#initialize

Constructor Details

This class inherits a constructor from Stenographer::Outputs::BaseOutput

Instance Method Details

#channelsObject



8
9
10
11
12
# File 'lib/stenographer/outputs/slack_output.rb', line 8

def channels
  result = get_request(endpoint: 'channels.list', params: { token: token, exclude_archived: true, exclude_members: true })
  channels_data = result[:channels]
  channels_data.map { |channel| [channel[:name], channel[:id]] }
end

#sendObject

Raises:

  • (StandardError)


14
15
16
17
18
19
20
21
22
# File 'lib/stenographer/outputs/slack_output.rb', line 14

def send
  raise StandardError, 'you must pass a Change to send' if @change.blank?

  post_json_request(endpoint: 'chat.postMessage', params: {
                      channel: configuration[:channel],
                      text: "Deployed updates to *#{@change.environments.upcase}*:",
                      attachments: [generate_attachment]
                    })
end