Class: ActionMessenger::Providers::Slack
- Inherits:
-
Object
- Object
- ActionMessenger::Providers::Slack
- Defined in:
- lib/action_messenger/providers/slack.rb
Constant Summary collapse
- TokenError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize ⇒ Slack
constructor
A new instance of Slack.
-
#message(channel, options) ⇒ Object
message to slack.
-
#upload_file(channels, file, options) ⇒ Object
upload file to slack.
Constructor Details
#initialize ⇒ Slack
Returns a new instance of Slack.
11 12 13 14 15 16 17 |
# File 'lib/action_messenger/providers/slack.rb', line 11 def initialize raise(TokenError.new('slack api token is blank.')) if ActionMessenger.config.slack_api_token.blank? @client = ::Slack::Web::Client.new.tap do |client| client.token = ActionMessenger.config.slack_api_token end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/action_messenger/providers/slack.rb', line 9 def client @client end |
Instance Method Details
#message(channel, options) ⇒ Object
message to slack
22 23 24 25 |
# File 'lib/action_messenger/providers/slack.rb', line 22 def (channel, ) = {channel: channel}.merge(()) client.chat_postMessage() end |
#upload_file(channels, file, options) ⇒ Object
upload file to slack
33 34 35 36 |
# File 'lib/action_messenger/providers/slack.rb', line 33 def upload_file(channels, file, ) = {channels: channels, file: file}.merge(upload_file_option_to_api_hash()) client.files_upload() end |