blob: deff5fd26ee0629865f58830cef8fd7dec73aad7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
|