Class: Fluent::SlackClient::WebApi

Inherits:
Base
  • Object
show all
Defined in:
lib/fluent/plugin/slack_client.rb

Overview

Slack client for Web API

Constant Summary collapse

DEFAULT_ENDPOINT =
"https://slack.com/api/".freeze

Instance Attribute Summary

Attributes inherited from Base

#debug_dev, #https_proxy, #log

Instance Method Summary collapse

Methods inherited from Base

#initialize, #post, #proxy_class

Constructor Details

This class inherits a constructor from Fluent::SlackClient::Base

Instance Method Details

#apiObject



194
195
196
# File 'lib/fluent/plugin/slack_client.rb', line 194

def api
  self
end

#channels_create(params = {}, opts = {}) ⇒ Object

Creates a channel.

NOTE: Bot user can not create a channel. Token must be issued by Normal User Account



230
231
232
233
# File 'lib/fluent/plugin/slack_client.rb', line 230

def channels_create(params = {}, opts = {})
  log.info { "out_slack: channels_create #{filter_params(params)}" }
  post(channels_create_endpoint, params)
end

#channels_create_endpointObject



206
207
208
# File 'lib/fluent/plugin/slack_client.rb', line 206

def channels_create_endpoint
  @channels_create_endpoint ||= URI.join(endpoint, "channels.create")
end

#endpointObject



198
199
200
# File 'lib/fluent/plugin/slack_client.rb', line 198

def endpoint
  @endpoint ||= URI.parse(DEFAULT_ENDPOINT)
end

#post_message(params = {}, opts = {}) ⇒ Object

Sends a message to a channel.



215
216
217
218
219
220
# File 'lib/fluent/plugin/slack_client.rb', line 215

def post_message(params = {}, opts = {})
  with_channels_create(params, opts) do
    log.info { "out_slack: post_message #{filter_params(params)}" }
    post(post_message_endpoint, params)
  end
end

#post_message_endpointObject



202
203
204
# File 'lib/fluent/plugin/slack_client.rb', line 202

def post_message_endpoint
  @post_message_endpoint    ||= URI.join(endpoint, "chat.postMessage")
end