From efe2d96a90cb5e2cc0c368294a021423aeeaeabe Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Mon, 3 Apr 2017 16:37:23 +0100 Subject: adds initial microsoft teams integration --- lib/microsoft_teams/notifier.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lib/microsoft_teams/notifier.rb (limited to 'lib/microsoft_teams') diff --git a/lib/microsoft_teams/notifier.rb b/lib/microsoft_teams/notifier.rb new file mode 100644 index 00000000000..deff5fd26ee --- /dev/null +++ b/lib/microsoft_teams/notifier.rb @@ -0,0 +1,37 @@ +module MicrosoftTeams + class Notifier + def initialize(webhook) + @webhook = webhook + end + + def ping(options = {}) + HTTParty.post( + @webhook.to_str, + headers: { 'Content-type' => 'application/json' }, + body: body(options) + ) + end + + private + + def body(options = {}) + result = { 'sections' => [] } + + result['title'] = options[:title] if options[:title] + result['summary'] = options[:activity][:title] + result['sections'] << { + 'activityTitle' => options[:activity][:title], + 'activitySubtitle' => options[:activity][:subtitle], + 'activityText' => options[:activity][:text], + 'activityImage' => options[:activity][:image] + } + result['sections'] << { 'title' => 'Details', 'facts' => attachments(options[:attachments]) } if options[:attachments] + + result.to_json + end + + def attachments(content) + [{ 'name' => 'Attachments', 'value' => content }] + end + end +end -- cgit v1.2.1