diff options
Diffstat (limited to 'lib/microsoft_teams')
-rw-r--r-- | lib/microsoft_teams/activity.rb | 19 | ||||
-rw-r--r-- | lib/microsoft_teams/notifier.rb | 23 |
2 files changed, 27 insertions, 15 deletions
diff --git a/lib/microsoft_teams/activity.rb b/lib/microsoft_teams/activity.rb new file mode 100644 index 00000000000..e25ce262cbf --- /dev/null +++ b/lib/microsoft_teams/activity.rb @@ -0,0 +1,19 @@ +module MicrosoftTeams + class Activity + def initialize(title, subtitle, text, image) + @title = title + @subtitle = subtitle + @text = text + @image = image + end + + def to_json + { + 'activityTitle' => @title, + 'activitySubtitle' => @subtitle, + 'activityText' => @text, + 'activityImage' => @image + }.to_json + end + end +end diff --git a/lib/microsoft_teams/notifier.rb b/lib/microsoft_teams/notifier.rb index 8e422575636..a5d2fe15ab6 100644 --- a/lib/microsoft_teams/notifier.rb +++ b/lib/microsoft_teams/notifier.rb @@ -15,26 +15,19 @@ module MicrosoftTeams private def body(options = {}) + attachments = options[:attachments] 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['title'] = options[:title] + result['summary'] = options[:pretext] + result['sections'] << options[:activity] - if options[:attachments].present? && !options[:attachments].empty? - result['sections'] << { 'title' => 'Details', 'facts' => attachments(options[:attachments]) } - end + result['sections'] << { + 'title' => 'Details', + 'facts' => [{ 'name' => 'Attachments', 'value' => attachments }] + } if attachments.present? && attachments.empty? result.to_json end - - def attachments(content) - [{ 'name' => 'Attachments', 'value' => content }] - end end end |