class TocaroWebhook::Sender
Attributes
payload[W]
url[RW]
Public Class Methods
new(web_hook_key)
click to toggle source
# File lib/tocaro_webhook/sender.rb, line 12 def initialize(web_hook_key) @url = web_hook_url(web_hook_key) end
Public Instance Methods
exec(options={})
click to toggle source
# File lib/tocaro_webhook/sender.rb, line 25 def exec(options={}) payload.text ||= options[:text] payload.color ||= options[:color] request = Net::HTTP::Post.new(@url) request.body = payload.to_body uri = URI.parse(@url) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE https.request(request) end
payload()
click to toggle source
# File lib/tocaro_webhook/sender.rb, line 43 def payload @payload ||= TocaroWebhook::Payload.new end
set_color(color)
click to toggle source
color is info, warning, danger, success
# File lib/tocaro_webhook/sender.rb, line 21 def set_color(color) payload.color = color end
set_text(text)
click to toggle source
# File lib/tocaro_webhook/sender.rb, line 16 def set_text(text) payload.text = text end
web_hook_url(web_hook_key)
click to toggle source
# File lib/tocaro_webhook/sender.rb, line 39 def web_hook_url(web_hook_key) "https://hooks.tocaro.im/integrations/inbound_webhook/#{web_hook_key}" end