Class: Fluent::SlackClient::Base

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

Overview

The base framework of slack client

Direct Known Subclasses

IncomingWebhook, WebApi

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



12
13
14
# File 'lib/fluent/plugin/slack_client.rb', line 12

def initialize
  @log = Logger.new('/dev/null')
end

Instance Attribute Details

#debug_devObject

Returns the value of attribute debug_dev.



10
11
12
# File 'lib/fluent/plugin/slack_client.rb', line 10

def debug_dev
  @debug_dev
end

#logObject

Returns the value of attribute log.



10
11
12
# File 'lib/fluent/plugin/slack_client.rb', line 10

def log
  @log
end

Instance Method Details

#post(endpoint, params) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fluent/plugin/slack_client.rb', line 16

def post(endpoint, params)
  http = Net::HTTP.new(endpoint.host, endpoint.port)
  http.use_ssl = (endpoint.scheme == 'https')
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  http.set_debug_output(debug_dev) if debug_dev

  req = Net::HTTP::Post.new(endpoint.path)
  req['Host'] = endpoint.host
  req['Accept'] = 'application/json; charset=utf-8'
  req['User-Agent'] = 'fluent-plugin-slack'
  req.body = encode_body(params)

  res = http.request(req)
  response_check(res, params)
end