Class: FlimperNikita::Notifications::Send
- Inherits:
-
Object
- Object
- FlimperNikita::Notifications::Send
- Defined in:
- lib/flimper_nikita/notifications/send.rb
Instance Method Summary collapse
-
#initialize(source:, severity:, message:, jwt_token:) ⇒ Send
constructor
A new instance of Send.
- #issue! ⇒ Object
- #nikita_api_endpoint ⇒ Object
- #security_data ⇒ Object
Constructor Details
#initialize(source:, severity:, message:, jwt_token:) ⇒ Send
Returns a new instance of Send.
7 8 9 10 11 12 |
# File 'lib/flimper_nikita/notifications/send.rb', line 7 def initialize(source:, severity:, message:, jwt_token:) @source = source @severity = severity @message = @jwt_token = jwt_token end |
Instance Method Details
#issue! ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flimper_nikita/notifications/send.rb', line 22 def issue! nikita_response = Faraday.new.post do |request| request.url(nikita_api_endpoint) request.headers['Content-Type'] = 'application/json' request.headers['Authorization'] = @jwt_token request.body = security_data end return unless nikita_response.success? end |
#nikita_api_endpoint ⇒ Object
14 15 16 |
# File 'lib/flimper_nikita/notifications/send.rb', line 14 def nikita_api_endpoint "#{ENV.fetch('NIKITA_API_URL')}/notifications" end |
#security_data ⇒ Object
18 19 20 |
# File 'lib/flimper_nikita/notifications/send.rb', line 18 def security_data { source: @source, severity: @severity, message: @message }.to_json end |