Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-04-03 18:37:23 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-04-05 15:57:11 +0300
commitefe2d96a90cb5e2cc0c368294a021423aeeaeabe (patch)
tree95c67a48cfa7e78011da64da1942202d3b4a7a4c /lib/microsoft_teams
parentd4349ba6c4960f50dce7b0beec5f309894dbada9 (diff)
adds initial microsoft teams integration
Diffstat (limited to 'lib/microsoft_teams')
-rw-r--r--lib/microsoft_teams/notifier.rb37
1 files changed, 37 insertions, 0 deletions
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