Class: Msteams::Ruby::Client
- Inherits:
-
Object
- Object
- Msteams::Ruby::Client
- Defined in:
- lib/msteams/ruby/client.rb,
lib/msteams/ruby/client/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'.freeze
Instance Method Summary collapse
-
#initialize(webhook_url = '') ⇒ Client
constructor
A new instance of Client.
- #post(text) ⇒ Object
Constructor Details
#initialize(webhook_url = '') ⇒ Client
Returns a new instance of Client.
4 5 6 |
# File 'lib/msteams/ruby/client.rb', line 4 def initialize(webhook_url = '') @webhook_url = webhook_url || ENV['MSTEAMS_RUBY_CLIENT_WEBHOOK_URL'] end |
Instance Method Details
#post(text) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/msteams/ruby/client.rb', line 8 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 }.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 |