Class: Capistrano::Teams::WebHook
- Inherits:
-
Object
- Object
- Capistrano::Teams::WebHook
- Defined in:
- lib/capistrano/teams/web_hook.rb
Overview
Teams Webhook class
Instance Method Summary collapse
- #notify(status = fetch(:teams_default_status), theme_color = fetch(:teams_default_color), facts = []) ⇒ Object
-
#send_message_to_webhook(body) ⇒ Object
Post to Teams.
Instance Method Details
#notify(status = fetch(:teams_default_status), theme_color = fetch(:teams_default_color), facts = []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/capistrano/teams/web_hook.rb', line 11 def notify( status = fetch(:teams_default_status), theme_color = fetch(:teams_default_color), facts = [] ) content = Message::Builder.of_type( fetch(:teams_message_type), { status: status }, theme_color, facts ).content (content) end |
#send_message_to_webhook(body) ⇒ Object
Post to Teams.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/capistrano/teams/web_hook.rb', line 28 def (body) uri = URI.parse(fetch(:teams_webhook_url).to_s) request = Net::HTTP::Post.new(uri.path) request.content_type = 'application/json' request.body = body opts = { use_ssl: uri.scheme == 'https' } \ .merge(fetch(:teams_http_options)) Net::HTTP.start(uri.host, uri.port, opts) do |http| http.request(request) end end |