Class: Teams
- Inherits:
-
Object
- Object
- Teams
- Defined in:
- lib/teams.rb,
lib/teams/version.rb
Constant Summary collapse
- VERSION =
'0.3.0'.freeze
Instance Method Summary collapse
-
#initialize(webhook_url = nil) ⇒ Teams
constructor
A new instance of Teams.
- #post(text, options = {}) ⇒ Object
Constructor Details
#initialize(webhook_url = nil) ⇒ Teams
Returns a new instance of Teams.
2 3 4 |
# File 'lib/teams.rb', line 2 def initialize(webhook_url = nil) @webhook_url = webhook_url || ENV['MSTEAMS_RUBY_CLIENT_WEBHOOK_URL'] end |
Instance Method Details
#post(text, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/teams.rb', line 6 def post(text, = {}) uri = URI.parse(@webhook_url) request = Net::HTTP::Post.new(uri.request_uri) request['Content-Type'] = 'application/json' request.body = { text: text, summary: [:summary] || text }.to_json http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.start { |h| h.request(request) } end |