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



223
224
225
# File 'lib/fluent/plugin/slack_client.rb', line 223

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



259
260
261
262
# File 'lib/fluent/plugin/slack_client.rb', line 259

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

#channels_create_endpointObject



235
236
237
# File 'lib/fluent/plugin/slack_client.rb', line 235

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

#endpointObject



227
228
229
# File 'lib/fluent/plugin/slack_client.rb', line 227

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

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

Sends a message to a channel.



244
245
246
247
248
249
# File 'lib/fluent/plugin/slack_client.rb', line 244

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



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

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