Class: Flock::Notifier::Connection
- Inherits:
-
Object
- Object
- Flock::Notifier::Connection
- Defined in:
- lib/flock/notifier/connection.rb
Instance Method Summary collapse
-
#initialize(incoming_webhook_url) ⇒ Connection
constructor
A new instance of Connection.
- #post(message) ⇒ Object
Constructor Details
#initialize(incoming_webhook_url) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 |
# File 'lib/flock/notifier/connection.rb', line 10 def initialize(incoming_webhook_url) uri = URI.parse(incoming_webhook_url) header = { 'Content-Type': 'application/json' } @http = Net::HTTP.new(uri.host, uri.port) @http.use_ssl = true @request = Net::HTTP::Post.new(uri.request_uri, header) end |
Instance Method Details
#post(message) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/flock/notifier/connection.rb', line 20 def post() payload = { "text": } @request.body = payload.to_json # Send the request @http.request(@request) end |