Class: StandupMD::Post::Adapters::Slack
- Inherits:
-
StandupMD::Post::Adapter
- Object
- StandupMD::Post::Adapter
- StandupMD::Post::Adapters::Slack
- Defined in:
- lib/standup_md/post/adapters/slack.rb
Overview
Posts standup entries to Slack using the chat.postMessage Web API.
Constant Summary collapse
- DEFAULT_ENDPOINT =
Slack chat.postMessage endpoint.
"https://slack.com/api/chat.postMessage"- DEFAULT_TOKEN_ENV =
Environment variable used for the Slack token by default.
"STANDUP_MD_SLACK_TOKEN"
Instance Attribute Summary
Attributes inherited from StandupMD::Post::Adapter
Instance Method Summary collapse
-
#post(message) ⇒ StandupMD::Post::Result
Sends a message to Slack.
Methods inherited from StandupMD::Post::Adapter
Constructor Details
This class inherits a constructor from StandupMD::Post::Adapter
Instance Method Details
#post(message) ⇒ StandupMD::Post::Result
Sends a message to Slack.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/standup_md/post/adapters/slack.rb', line 35 def post() channel = .channel || [:channel] token = ENV[token_env] return failure(, channel, "No Slack channel configured") if blank?(channel) return failure(, channel, "Missing Slack token in $#{token_env}") if blank?(token) response = perform_request(channel, .text, token) parsed = parse_response(response.body) return success(, channel, response, parsed) if response.is_a?(Net::HTTPSuccess) && parsed["ok"] failure(, channel, (response, parsed), parsed) rescue => e failure(, channel, e.) end |