Class: Alerty::Plugin::Slack::SlackClient::Base
- Inherits:
-
Object
- Object
- Alerty::Plugin::Slack::SlackClient::Base
- Defined in:
- lib/alerty/plugin/slack/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.
48 49 50 51 52 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 48 def initialize(endpoint = nil, https_proxy = nil) self.endpoint = endpoint if endpoint self.https_proxy = https_proxy if https_proxy @log = Logger.new(nil) end |
Instance Attribute Details
#debug_dev ⇒ Object
Returns the value of attribute debug_dev.
30 31 32 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 30 def debug_dev @debug_dev end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
31 32 33 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 31 def endpoint @endpoint end |
#https_proxy ⇒ Object
Returns the value of attribute https_proxy.
31 32 33 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 31 def https_proxy @https_proxy end |
#log ⇒ Object
Returns the value of attribute log.
30 31 32 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 30 def log @log end |
Instance Method Details
#post(endpoint, params) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 67 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 # http.open_timeout = # default: 60s # http.read_timeout = # default: 60s 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
63 64 65 |
# File 'lib/alerty/plugin/slack/slack_client.rb', line 63 def proxy_class @proxy_class ||= Net::HTTP end |