class MsteamsWebhook::Message
Public Class Methods
new(text, title=nil)
click to toggle source
# File lib/msteams_webhook/message.rb, line 9 def initialize(text, title=nil) @text = text @title = title end
Public Instance Methods
add_action(text,url)
click to toggle source
# File lib/msteams_webhook/message.rb, line 69 def add_action(text,url) @potential_action = [] unless @potential_action @potential_action << { :@context => 'http://schema.org', :@type => 'ViewAction', :name => text, :target => [url] } end
add_activity(text,title=nil,image=nil)
click to toggle source
# File lib/msteams_webhook/message.rb, line 35 def add_activity(text,title=nil,image=nil) activity = {} activity[:activityTitle] = title if title activity[:activityText] = text if text activity[:activityImage] = image if image @sections = [] unless @sections @sections << activity end
add_facts(title,array)
click to toggle source
# File lib/msteams_webhook/message.rb, line 45 def add_facts(title,array) section = {} section[:title] = title if title section[:facts] = [] array.each { |name,value| section[:facts] << { :name => name, :value => value } } @sections = [] unless @sections @sections << section end
add_image(title,image)
click to toggle source
# File lib/msteams_webhook/message.rb, line 55 def add_image(title,image) add_images(title,[image]) end
add_images(title,images)
click to toggle source
# File lib/msteams_webhook/message.rb, line 59 def add_images(title,images) section = {} section[:title] = title section[:images] = [] images.each { |image| section[:images] << { :image => image } } @sections = [] unless @sections @sections << section end
as_json()
click to toggle source
# File lib/msteams_webhook/message.rb, line 14 def as_json msg = {} msg[:summary] = @summary if @summary msg[:title] = @title if @title msg[:text] = @text if @text msg[:themeColor] = @color if @color msg[:sections] = @sections if @sections msg[:potentialAction] = @potential_action if @potential_action msg end
send(url, async=true)
click to toggle source
# File lib/msteams_webhook/message.rb, line 79 def send(url, async=true) client = HTTPClient.new client.ssl_config.cert_store.set_default_paths client.ssl_config.ssl_version = :auto if async client.post_async url, to_json else client.post url, to_json end end
set_color(color)
click to toggle source
# File lib/msteams_webhook/message.rb, line 31 def set_color(color) @color = color end
to_json()
click to toggle source
# File lib/msteams_webhook/message.rb, line 27 def to_json as_json.to_json end