Class: Fluent::SlackClient::Base
- Inherits:
-
Object
- Object
- Fluent::SlackClient::Base
- Defined in:
- lib/fluent/plugin/slack_client.rb
Overview
The base framework of slack client
Direct Known Subclasses
Instance Attribute Summary collapse
-
#debug_dev ⇒ Object
Returns the value of attribute debug_dev.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#https_proxy ⇒ Object
Returns the value of attribute https_proxy.
-
#log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
-
#initialize(endpoint = nil, https_proxy = nil) ⇒ Base
constructor
A new instance of Base.
- #post(endpoint, params) ⇒ Object
- #proxy_class ⇒ Object
Constructor Details
#initialize(endpoint = nil, https_proxy = nil) ⇒ Base
Returns a new instance of Base.
29 30 31 32 33 |
# File 'lib/fluent/plugin/slack_client.rb', line 29 def initialize(endpoint = nil, https_proxy = nil) self.endpoint = endpoint if endpoint self.https_proxy = https_proxy if https_proxy @log = Logger.new('/dev/null') end |
Instance Attribute Details
#debug_dev ⇒ Object
Returns the value of attribute debug_dev.
11 12 13 |
# File 'lib/fluent/plugin/slack_client.rb', line 11 def debug_dev @debug_dev end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
12 13 14 |
# File 'lib/fluent/plugin/slack_client.rb', line 12 def endpoint @endpoint end |
#https_proxy ⇒ Object
Returns the value of attribute https_proxy.
12 13 14 |
# File 'lib/fluent/plugin/slack_client.rb', line 12 def https_proxy @https_proxy end |
#log ⇒ Object
Returns the value of attribute log.
11 12 13 |
# File 'lib/fluent/plugin/slack_client.rb', line 11 def log @log end |
Instance Method Details
#post(endpoint, params) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fluent/plugin/slack_client.rb', line 48 def post(endpoint, params) http = proxy_class.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.request_uri) 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 |
#proxy_class ⇒ Object
44 45 46 |
# File 'lib/fluent/plugin/slack_client.rb', line 44 def proxy_class @proxy_class ||= Net::HTTP end |